[alsa-devel] How to post cleanup patches ?
Hi Mark
Now codec driver and component driver has duplicated callback function, and snd_soc_register_codec() just copied it to component side.
int snd_soc_register_codec(xxx) { ...
if (codec_drv->controls) { codec->component.controls = codec_drv->controls; codec->component.num_controls = codec_drv->num_controls; } if (codec_drv->dapm_widgets) { codec->component.dapm_widgets = codec_drv->dapm_widgets; codec->component.num_dapm_widgets = codec_drv->num_dapm_widgets; } if (codec_drv->dapm_routes) { codec->component.dapm_routes = codec_drv->dapm_routes; codec->component.num_dapm_routes = codec_drv->num_dapm_routes; } ... }
I think we can cleanup this duplicated function, similar things happen on .probe, .remove, and platform side too.
I would like to post cleanup patches for these. As 1st step, remove codec duplicate callback.
But my concern is that you hate big-patch-set, and it is almost 70 patches. Can I post these patches to ML ? or should I use git pull request ? or I shouldn't post ?
I will post main patches as sample patch
Best regards --- Kuninori Morimoto
snd_soc_component_driver requests some struct xxx, and int num_xxx. To make initialize easy, this patch adds COMPONENT_FUNC() macro.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 6144882..41c21f9 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -795,6 +795,9 @@ struct snd_soc_component_driver { int probe_order; int remove_order; }; +#define COMPONENT_FUNC(name, func) \ + .name = func, \ + .num_##name = ARRAY_SIZE(func)
struct snd_soc_component { const char *name;
On 08/03/2016 03:13 AM, Kuninori Morimoto wrote:
snd_soc_component_driver requests some struct xxx, and int num_xxx. To make initialize easy, this patch adds COMPONENT_FUNC() macro.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
include/sound/soc.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 6144882..41c21f9 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -795,6 +795,9 @@ struct snd_soc_component_driver { int probe_order; int remove_order; }; +#define COMPONENT_FUNC(name, func) \
- .name = func, \
- .num_##name = ARRAY_SIZE(func)
I'd avoid like to a void this kind of macro. Sure it slightly reduces boilerplate code, but it is difficult to parse for both humans as well as machines. Makes the code much less intuitive to understand and also breaks automated scripts.
Hi Lars
Thank you for your feedback
snd_soc_component_driver requests some struct xxx, and int num_xxx. To make initialize easy, this patch adds COMPONENT_FUNC() macro.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
include/sound/soc.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 6144882..41c21f9 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -795,6 +795,9 @@ struct snd_soc_component_driver { int probe_order; int remove_order; }; +#define COMPONENT_FUNC(name, func) \
- .name = func, \
- .num_##name = ARRAY_SIZE(func)
I'd avoid like to a void this kind of macro. Sure it slightly reduces boilerplate code, but it is difficult to parse for both humans as well as machines. Makes the code much less intuitive to understand and also breaks automated scripts.
Thanks, and yes agree. Now, I'm creating many patches without above macro.
codec driver and component driver has duplicated callback functions, and codec side functions are just copied to component side when register timing. This was quick-hack, but no longer needed. This patch moves these functions from codec driver to component driver.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8978.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index d36d600..6a6828c 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c @@ -999,12 +999,11 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8978 = { .resume = wm8978_resume, .set_bias_level = wm8978_set_bias_level,
- .controls = wm8978_snd_controls, - .num_controls = ARRAY_SIZE(wm8978_snd_controls), - .dapm_widgets = wm8978_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets), - .dapm_routes = wm8978_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes), + .component_driver = { + COMPONENT_FUNC(controls, wm8978_snd_controls), + COMPONENT_FUNC(dapm_widgets, wm8978_dapm_widgets), + COMPONENT_FUNC(dapm_routes, wm8978_dapm_routes), + }, };
static const struct regmap_config wm8978_regmap_config = {
codec driver and component driver has duplicated callback functions, and codec side functions are just copied to component side when register timing. This was quick-hack, but no longer needed. This patch removes codec side duplicated callback function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 8 -------- sound/soc/soc-core.c | 13 ------------- 2 files changed, 21 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 41c21f9..4e36538 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -901,14 +901,6 @@ struct snd_soc_codec_driver { int (*resume)(struct snd_soc_codec *); struct snd_soc_component_driver component_driver;
- /* Default control and setup, added after probe() is run */ - const struct snd_kcontrol_new *controls; - int num_controls; - const struct snd_soc_dapm_widget *dapm_widgets; - int num_dapm_widgets; - const struct snd_soc_dapm_route *dapm_routes; - int num_dapm_routes; - /* codec wide operations */ int (*set_sysclk)(struct snd_soc_codec *codec, int clk_id, int source, unsigned int freq, int dir); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 16369ca..edba975 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3333,19 +3333,6 @@ int snd_soc_register_codec(struct device *dev, if (ret) goto err_free;
- if (codec_drv->controls) { - codec->component.controls = codec_drv->controls; - codec->component.num_controls = codec_drv->num_controls; - } - if (codec_drv->dapm_widgets) { - codec->component.dapm_widgets = codec_drv->dapm_widgets; - codec->component.num_dapm_widgets = codec_drv->num_dapm_widgets; - } - if (codec_drv->dapm_routes) { - codec->component.dapm_routes = codec_drv->dapm_routes; - codec->component.num_dapm_routes = codec_drv->num_dapm_routes; - } - if (codec_drv->probe) codec->component.probe = snd_soc_codec_drv_probe; if (codec_drv->remove)
The patch
ASoC: remove codec duplicated callback function
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 8073aefa60823acf205a1e6a5ea118297179d766 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Mon, 8 Aug 2016 09:36:49 +0000 Subject: [PATCH] ASoC: remove codec duplicated callback function
codec driver and component driver has duplicated callback functions, and codec side functions are just copied to component side when register timing. This was quick-hack, but no longer needed. This patch removes codec side duplicated callback function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/soc.h | 8 -------- sound/soc/soc-core.c | 13 ------------- 2 files changed, 21 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 6144882cc96a..5eb2b38c3437 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -898,14 +898,6 @@ struct snd_soc_codec_driver { int (*resume)(struct snd_soc_codec *); struct snd_soc_component_driver component_driver;
- /* Default control and setup, added after probe() is run */ - const struct snd_kcontrol_new *controls; - int num_controls; - const struct snd_soc_dapm_widget *dapm_widgets; - int num_dapm_widgets; - const struct snd_soc_dapm_route *dapm_routes; - int num_dapm_routes; - /* codec wide operations */ int (*set_sysclk)(struct snd_soc_codec *codec, int clk_id, int source, unsigned int freq, int dir); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 16369cad4803..edba975d893e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3333,19 +3333,6 @@ int snd_soc_register_codec(struct device *dev, if (ret) goto err_free;
- if (codec_drv->controls) { - codec->component.controls = codec_drv->controls; - codec->component.num_controls = codec_drv->num_controls; - } - if (codec_drv->dapm_widgets) { - codec->component.dapm_widgets = codec_drv->dapm_widgets; - codec->component.num_dapm_widgets = codec_drv->num_dapm_widgets; - } - if (codec_drv->dapm_routes) { - codec->component.dapm_routes = codec_drv->dapm_routes; - codec->component.num_dapm_routes = codec_drv->num_dapm_routes; - } - if (codec_drv->probe) codec->component.probe = snd_soc_codec_drv_probe; if (codec_drv->remove)
On Wed, Aug 03, 2016 at 01:12:25AM +0000, Kuninori Morimoto wrote:
But my concern is that you hate big-patch-set, and it is almost 70 patches. Can I post these patches to ML ? or should I use git pull request ? or I shouldn't post ?
A very repetitive patch series which does the same thing to multiple drivers (so is essentially the same patch lots of times) is not such a problem, the problem is huge numbers of different patches that all need individual review.
Hi Mark
But my concern is that you hate big-patch-set, and it is almost 70 patches. Can I post these patches to ML ? or should I use git pull request ? or I shouldn't post ?
A very repetitive patch series which does the same thing to multiple drivers (so is essentially the same patch lots of times) is not such a problem, the problem is huge numbers of different patches that all need individual review.
OK, I see I will post it to ML
On 08/03/2016 03:12 AM, Kuninori Morimoto wrote:
Hi Mark
Now codec driver and component driver has duplicated callback function, and snd_soc_register_codec() just copied it to component side.
int snd_soc_register_codec(xxx) { ...
if (codec_drv->controls) { codec->component.controls = codec_drv->controls; codec->component.num_controls = codec_drv->num_controls; } if (codec_drv->dapm_widgets) { codec->component.dapm_widgets = codec_drv->dapm_widgets; codec->component.num_dapm_widgets = codec_drv->num_dapm_widgets; } if (codec_drv->dapm_routes) { codec->component.dapm_routes = codec_drv->dapm_routes; codec->component.num_dapm_routes = codec_drv->num_dapm_routes; } ...
}
I think we can cleanup this duplicated function, similar things happen on .probe, .remove, and platform side too.
I would like to post cleanup patches for these. As 1st step, remove codec duplicate callback.
But my concern is that you hate big-patch-set, and it is almost 70 patches. Can I post these patches to ML ? or should I use git pull request ? or I shouldn't post ?
I left this step out on purpose during the componentization of snd_soc_codec. Simply because it is a huge amount of code churn for very little gain. If you want to do it, go ahead, but I don't think it is worth the effort at this point.
I think of this as the final cleanup step once everything else is in place. E.g. there are lots of CODEC drivers that don't actually need anything CODEC specific, except that we need to know that it is a CODEC so we which direction the capture and playback streams of the DAI go. If we can come up with a generic to represent the DAI streams we could convert all these drivers directly from snd_soc_codec_driver to snd_soc_component_driver.
I'd much rather see this conversion to be part of such an effort.
participants (3)
-
Kuninori Morimoto
-
Lars-Peter Clausen
-
Mark Brown