[alsa-devel] [PATCH resend 00/11] ASoC: soc-core cleanup
Hi Mark
These are resend of soc-core cleanup patches which are not yet accepted/reviewed. These are based on latest mark/for-v5.4 branch.
Kuninori Morimoto (11): ASoC: soc-core: add comment to jack at soc_remove_component() ASoC: soc-core: self contained soc_probe_link_components() ASoC: soc-core: self contained soc_remove_link_components() ASoC: soc-core: self contained soc_remove_link_dais() ASoC: soc-core: move soc_probe_dai() next to soc_remove_dai() ASoC: soc-core: add new soc_link_init() ASoC: soc-core: self contained soc_probe_link_dais() ASoC: soc-core: move soc_probe_link_dais() next to soc_remove_link_dais() ASoC: soc-core: self contained soc_bind_aux_dev() ASoC: soc-core: add soc_unbind_aux_dev() ASoC: soc-core: self contained soc_unbind_aux_dev()
sound/soc/soc-core.c | 264 +++++++++++++++++++++++++++------------------------ 1 file changed, 139 insertions(+), 125 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Basically, driver which setups snd_soc_component_set_jack() need to release it by themselves. But, as framework level robustness, soc_remove_component() also releases it.
To avoid code reader confuse, this patch makes it clarify.
This patch makes it clarify.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2a166ab..05a2aff 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -975,7 +975,9 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
static void soc_cleanup_component(struct snd_soc_component *component) { + /* For framework level robustness */ snd_soc_component_set_jack(component, NULL, NULL); + list_del(&component->card_list); snd_soc_dapm_free(snd_soc_component_get_dapm(component)); soc_cleanup_component_debugfs(component);
The patch
ASoC: soc-core: add comment to jack at soc_remove_component()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 04f770d968344ca95b55cf7b50452888ec5440e7 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:14:35 +0900 Subject: [PATCH] ASoC: soc-core: add comment to jack at soc_remove_component()
Basically, driver which setups snd_soc_component_set_jack() need to release it by themselves. But, as framework level robustness, soc_remove_component() also releases it.
To avoid code reader confuse, this patch makes it clarify.
This patch makes it clarify.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/875zm8q5n8.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2a166abaade1..05a2aff843aa 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -975,7 +975,9 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
static void soc_cleanup_component(struct snd_soc_component *component) { + /* For framework level robustness */ snd_soc_component_set_jack(component, NULL, NULL); + list_del(&component->card_list); snd_soc_dapm_free(snd_soc_component_get_dapm(component)); soc_cleanup_component_debugfs(component);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_probe_link_components() implementation is very half, thus it is very difficult to read.
for_each_comp_order(xxx) { for_each_card_rtds(xxx) { => ret = soc_probe_link_components(xxx); ... } }
This patch does all for_each_xxx() under soc_probe_link_components(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 05a2aff..04b98e6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1137,20 +1137,25 @@ static void soc_remove_link_components(struct snd_soc_card *card, } }
-static int soc_probe_link_components(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd, int order) +static int soc_probe_link_components(struct snd_soc_card *card) { struct snd_soc_component *component; + struct snd_soc_pcm_runtime *rtd; struct snd_soc_rtdcom_list *rtdcom; - int ret; + int ret, order;
- for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) { + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component;
- if (component->driver->probe_order == order) { - ret = soc_probe_component(card, component); - if (ret < 0) - return ret; + if (component->driver->probe_order != order) + continue; + + ret = soc_probe_component(card, component); + if (ret < 0) + return ret; + } } }
@@ -1990,16 +1995,11 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }
/* probe all components used by DAI links on this card */ - for_each_comp_order(order) { - for_each_card_rtds(card, rtd) { - ret = soc_probe_link_components(card, rtd, order); - if (ret < 0) { - dev_err(card->dev, - "ASoC: failed to instantiate card %d\n", - ret); - goto probe_end; - } - } + ret = soc_probe_link_components(card); + if (ret < 0) { + dev_err(card->dev, + "ASoC: failed to instantiate card %d\n", ret); + goto probe_end; }
/* probe auxiliary components */
The patch
ASoC: soc-core: self contained soc_probe_link_components()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 62f07a6b6dbaf0e7196b6911111d4666b5d03518 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:14:46 +0900 Subject: [PATCH] ASoC: soc-core: self contained soc_probe_link_components()
Current soc_probe_link_components() implementation is very half, thus it is very difficult to read.
for_each_comp_order(xxx) { for_each_card_rtds(xxx) { => ret = soc_probe_link_components(xxx); ... } }
This patch does all for_each_xxx() under soc_probe_link_components(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/874l1sq5mx.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 05a2aff843aa..04b98e6c7b2a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1137,20 +1137,25 @@ static void soc_remove_link_components(struct snd_soc_card *card, } }
-static int soc_probe_link_components(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd, int order) +static int soc_probe_link_components(struct snd_soc_card *card) { struct snd_soc_component *component; + struct snd_soc_pcm_runtime *rtd; struct snd_soc_rtdcom_list *rtdcom; - int ret; + int ret, order;
- for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) { + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component;
- if (component->driver->probe_order == order) { - ret = soc_probe_component(card, component); - if (ret < 0) - return ret; + if (component->driver->probe_order != order) + continue; + + ret = soc_probe_component(card, component); + if (ret < 0) + return ret; + } } }
@@ -1990,16 +1995,11 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }
/* probe all components used by DAI links on this card */ - for_each_comp_order(order) { - for_each_card_rtds(card, rtd) { - ret = soc_probe_link_components(card, rtd, order); - if (ret < 0) { - dev_err(card->dev, - "ASoC: failed to instantiate card %d\n", - ret); - goto probe_end; - } - } + ret = soc_probe_link_components(card); + if (ret < 0) { + dev_err(card->dev, + "ASoC: failed to instantiate card %d\n", ret); + goto probe_end; }
/* probe auxiliary components */
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_remove_link_components() implementation is very half, thus it is very difficult to read.
for_each_comp_order(xxx) { for_each_card_rtds(xxx) => soc_remove_link_components(xxx); }
This patch does all for_each_xxx() under soc_remove_link_components(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 04b98e6..fbaf4dd 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1123,17 +1123,24 @@ static void soc_remove_link_dais(struct snd_soc_card *card, soc_remove_dai(rtd->cpu_dai, order); }
-static void soc_remove_link_components(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd, int order) +static void soc_remove_link_components(struct snd_soc_card *card) { struct snd_soc_component *component; + struct snd_soc_pcm_runtime *rtd; struct snd_soc_rtdcom_list *rtdcom; + int order;
- for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) { + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->remove_order != order) + continue;
- if (component->driver->remove_order == order) - soc_remove_component(component); + soc_remove_component(component); + } + } } }
@@ -1173,10 +1180,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card) soc_remove_link_dais(card, rtd, order); }
- for_each_comp_order(order) { - for_each_card_rtds(card, rtd) - soc_remove_link_components(card, rtd, order); - } + soc_remove_link_components(card);
for_each_card_links_safe(card, link, _link) { if (link->dobj.type == SND_SOC_DOBJ_DAI_LINK) @@ -2394,20 +2398,13 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card);
static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) { - struct snd_soc_pcm_runtime *rtd; - int order; - if (card->instantiated) { card->instantiated = false; snd_soc_dapm_shutdown(card); snd_soc_flush_all_delayed_work(card);
/* remove all components used by DAI links on this card */ - for_each_comp_order(order) { - for_each_card_rtds(card, rtd) { - soc_remove_link_components(card, rtd, order); - } - } + soc_remove_link_components(card);
soc_cleanup_card_resources(card); if (!unregister)
The patch
ASoC: soc-core: self contained soc_remove_link_components()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 b006c0c6ed0dc779e64a8d7a25f5cf316fa3562c Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:14:51 +0900 Subject: [PATCH] ASoC: soc-core: self contained soc_remove_link_components()
Current soc_remove_link_components() implementation is very half, thus it is very difficult to read.
for_each_comp_order(xxx) { for_each_card_rtds(xxx) => soc_remove_link_components(xxx); }
This patch does all for_each_xxx() under soc_remove_link_components(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/8736hcq5ms.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 04b98e6c7b2a..fbaf4dd597b5 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1123,17 +1123,24 @@ static void soc_remove_link_dais(struct snd_soc_card *card, soc_remove_dai(rtd->cpu_dai, order); }
-static void soc_remove_link_components(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd, int order) +static void soc_remove_link_components(struct snd_soc_card *card) { struct snd_soc_component *component; + struct snd_soc_pcm_runtime *rtd; struct snd_soc_rtdcom_list *rtdcom; + int order;
- for_each_rtdcom(rtd, rtdcom) { - component = rtdcom->component; + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) { + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->remove_order != order) + continue;
- if (component->driver->remove_order == order) - soc_remove_component(component); + soc_remove_component(component); + } + } } }
@@ -1173,10 +1180,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card) soc_remove_link_dais(card, rtd, order); }
- for_each_comp_order(order) { - for_each_card_rtds(card, rtd) - soc_remove_link_components(card, rtd, order); - } + soc_remove_link_components(card);
for_each_card_links_safe(card, link, _link) { if (link->dobj.type == SND_SOC_DOBJ_DAI_LINK) @@ -2394,20 +2398,13 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card);
static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) { - struct snd_soc_pcm_runtime *rtd; - int order; - if (card->instantiated) { card->instantiated = false; snd_soc_dapm_shutdown(card); snd_soc_flush_all_delayed_work(card);
/* remove all components used by DAI links on this card */ - for_each_comp_order(order) { - for_each_card_rtds(card, rtd) { - soc_remove_link_components(card, rtd, order); - } - } + soc_remove_link_components(card);
soc_cleanup_card_resources(card); if (!unregister)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_remove_link_dais() implementation is very half, thus it is very difficult to read.
for_each_comp_order(xxx) { for_each_card_rtds(xxx) => soc_remove_link_dais(xxx); }
This patch does all for_each_xxx() under soc_remove_link_dais(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index fbaf4dd..0a13f94 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1107,20 +1107,26 @@ static void soc_remove_dai(struct snd_soc_dai *dai, int order) }
static void soc_rtd_free(struct snd_soc_pcm_runtime *rtd); /* remove me */ -static void soc_remove_link_dais(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd, int order) +static void soc_remove_link_dais(struct snd_soc_card *card) { int i; struct snd_soc_dai *codec_dai; + struct snd_soc_pcm_runtime *rtd; + int order; + + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) {
- /* finalize rtd device */ - soc_rtd_free(rtd); + /* finalize rtd device */ + soc_rtd_free(rtd);
- /* remove the CODEC DAI */ - for_each_rtd_codec_dai(rtd, i, codec_dai) - soc_remove_dai(codec_dai, order); + /* remove the CODEC DAI */ + for_each_rtd_codec_dai(rtd, i, codec_dai) + soc_remove_dai(codec_dai, order);
- soc_remove_dai(rtd->cpu_dai, order); + soc_remove_dai(rtd->cpu_dai, order); + } + } }
static void soc_remove_link_components(struct snd_soc_card *card) @@ -1171,14 +1177,9 @@ static int soc_probe_link_components(struct snd_soc_card *card)
static void soc_remove_dai_links(struct snd_soc_card *card) { - int order; - struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *link, *_link;
- for_each_comp_order(order) { - for_each_card_rtds(card, rtd) - soc_remove_link_dais(card, rtd, order); - } + soc_remove_link_dais(card);
soc_remove_link_components(card);
The patch
ASoC: soc-core: self contained soc_remove_link_dais()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 4ca47d21bf7aa044c703688fa715862183dd6a3c Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:14:57 +0900 Subject: [PATCH] ASoC: soc-core: self contained soc_remove_link_dais()
Current soc_remove_link_dais() implementation is very half, thus it is very difficult to read.
for_each_comp_order(xxx) { for_each_card_rtds(xxx) => soc_remove_link_dais(xxx); }
This patch does all for_each_xxx() under soc_remove_link_dais(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/871rwwq5mm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index fbaf4dd597b5..0a13f9461303 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1107,20 +1107,26 @@ static void soc_remove_dai(struct snd_soc_dai *dai, int order) }
static void soc_rtd_free(struct snd_soc_pcm_runtime *rtd); /* remove me */ -static void soc_remove_link_dais(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd, int order) +static void soc_remove_link_dais(struct snd_soc_card *card) { int i; struct snd_soc_dai *codec_dai; + struct snd_soc_pcm_runtime *rtd; + int order; + + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) {
- /* finalize rtd device */ - soc_rtd_free(rtd); + /* finalize rtd device */ + soc_rtd_free(rtd);
- /* remove the CODEC DAI */ - for_each_rtd_codec_dai(rtd, i, codec_dai) - soc_remove_dai(codec_dai, order); + /* remove the CODEC DAI */ + for_each_rtd_codec_dai(rtd, i, codec_dai) + soc_remove_dai(codec_dai, order);
- soc_remove_dai(rtd->cpu_dai, order); + soc_remove_dai(rtd->cpu_dai, order); + } + } }
static void soc_remove_link_components(struct snd_soc_card *card) @@ -1171,14 +1177,9 @@ static int soc_probe_link_components(struct snd_soc_card *card)
static void soc_remove_dai_links(struct snd_soc_card *card) { - int order; - struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *link, *_link;
- for_each_comp_order(order) { - for_each_card_rtds(card, rtd) - soc_remove_link_dais(card, rtd, order); - } + soc_remove_link_dais(card);
soc_remove_link_components(card);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
It is easy to read code if it is cleanly using paired function/naming, like start <-> stop, register <-> unregister, etc, etc. But, current ALSA SoC code is very random, unbalance, not paired, etc. It is easy to create bug at the such code, and it will be difficult to debug.
This patch moves soc_probe_dai() next to soc_remove_dai() which is paired function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0a13f94..3ca5a21b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1106,6 +1106,26 @@ static void soc_remove_dai(struct snd_soc_dai *dai, int order) dai->probed = 0; }
+static int soc_probe_dai(struct snd_soc_dai *dai, int order) +{ + int ret; + + if (dai->probed || + dai->driver->probe_order != order) + return 0; + + ret = snd_soc_dai_probe(dai); + if (ret < 0) { + dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n", + dai->name, ret); + return ret; + } + + dai->probed = 1; + + return 0; +} + static void soc_rtd_free(struct snd_soc_pcm_runtime *rtd); /* remove me */ static void soc_remove_link_dais(struct snd_soc_card *card) { @@ -1411,26 +1431,6 @@ static int soc_rtd_init(struct snd_soc_pcm_runtime *rtd, const char *name) return 0; }
-static int soc_probe_dai(struct snd_soc_dai *dai, int order) -{ - int ret; - - if (dai->probed || - dai->driver->probe_order != order) - return 0; - - ret = snd_soc_dai_probe(dai); - if (ret < 0) { - dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n", - dai->name, ret); - return ret; - } - - dai->probed = 1; - - return 0; -} - static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, struct snd_soc_pcm_runtime *rtd) {
The patch
ASoC: soc-core: move soc_probe_dai() next to soc_remove_dai()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 a7d44f78063d642406132c2ed1dc6033d0d03cfe Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:15:06 +0900 Subject: [PATCH] ASoC: soc-core: move soc_probe_dai() next to soc_remove_dai()
It is easy to read code if it is cleanly using paired function/naming, like start <-> stop, register <-> unregister, etc, etc. But, current ALSA SoC code is very random, unbalance, not paired, etc. It is easy to create bug at the such code, and it will be difficult to debug.
This patch moves soc_probe_dai() next to soc_remove_dai() which is paired function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87zhjkor1x.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0a13f9461303..3ca5a21bfa6a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1106,6 +1106,26 @@ static void soc_remove_dai(struct snd_soc_dai *dai, int order) dai->probed = 0; }
+static int soc_probe_dai(struct snd_soc_dai *dai, int order) +{ + int ret; + + if (dai->probed || + dai->driver->probe_order != order) + return 0; + + ret = snd_soc_dai_probe(dai); + if (ret < 0) { + dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n", + dai->name, ret); + return ret; + } + + dai->probed = 1; + + return 0; +} + static void soc_rtd_free(struct snd_soc_pcm_runtime *rtd); /* remove me */ static void soc_remove_link_dais(struct snd_soc_card *card) { @@ -1411,26 +1431,6 @@ static int soc_rtd_init(struct snd_soc_pcm_runtime *rtd, const char *name) return 0; }
-static int soc_probe_dai(struct snd_soc_dai *dai, int order) -{ - int ret; - - if (dai->probed || - dai->driver->probe_order != order) - return 0; - - ret = snd_soc_dai_probe(dai); - if (ret < 0) { - dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n", - dai->name, ret); - return ret; - } - - dai->probed = 1; - - return 0; -} - static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, struct snd_soc_pcm_runtime *rtd) {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_probe_link_dais() (1) is called under probe_order (2), and it will initialize dai_link related settings at *Last* turn (3)(B). It is very complex code.
static int soc_probe_link_dais(..., order) { (A) /* probe DAIs here */ ...
(3) if (order != SND_SOC_COMP_ORDER_LAST) return 0;
(B) /* initialize dai_link related settings */ ... }
static int snd_soc_instantiate_card(...) { ... (2) for_each_comp_order(order) { for_each_card_rtds(...) { (1) ret = soc_probe_link_dais(..., order); } } }
This patch separes soc_probe_link_dais() into "DAI probe" portion (A), and dai_link settings portion (B). The later is named as soc_link_init() by this patch.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3ca5a21b..1e74ab8 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1455,19 +1455,13 @@ static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, static int soc_probe_link_dais(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, int order) { - struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_rtdcom_list *rtdcom; - struct snd_soc_component *component; struct snd_soc_dai *codec_dai; - int i, ret, num; + int i, ret;
dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", card->name, rtd->num, order);
- /* set default power off timeout */ - rtd->pmdown_time = pmdown_time; - ret = soc_probe_dai(cpu_dai, order); if (ret) return ret; @@ -1479,9 +1473,20 @@ static int soc_probe_link_dais(struct snd_soc_card *card, return ret; }
- /* complete DAI probe during last probe */ - if (order != SND_SOC_COMP_ORDER_LAST) - return 0; + return 0; +} + +static int soc_link_init(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai_link *dai_link = rtd->dai_link; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + int ret, num; + + /* set default power off timeout */ + rtd->pmdown_time = pmdown_time;
/* do machine specific initialization */ if (dai_link->init) { @@ -2041,6 +2046,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) } }
+ for_each_card_rtds(card, rtd) + soc_link_init(card, rtd); + snd_soc_dapm_link_dai_widgets(card); snd_soc_dapm_connect_dai_link_widgets(card);
The patch
ASoC: soc-core: add new soc_link_init()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 c4b4698291a1d1c55665ae906779d1b685d5aa66 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:15:12 +0900 Subject: [PATCH] ASoC: soc-core: add new soc_link_init()
Current soc_probe_link_dais() (1) is called under probe_order (2), and it will initialize dai_link related settings at *Last* turn (3)(B). It is very complex code.
static int soc_probe_link_dais(..., order) { (A) /* probe DAIs here */ ...
(3) if (order != SND_SOC_COMP_ORDER_LAST) return 0;
(B) /* initialize dai_link related settings */ ... }
static int snd_soc_instantiate_card(...) { ... (2) for_each_comp_order(order) { for_each_card_rtds(...) { (1) ret = soc_probe_link_dais(..., order); } } }
This patch separes soc_probe_link_dais() into "DAI probe" portion (A), and dai_link settings portion (B). The later is named as soc_link_init() by this patch.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87y2z4or1r.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3ca5a21bfa6a..1e74ab8e6a25 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1455,19 +1455,13 @@ static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, static int soc_probe_link_dais(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, int order) { - struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_rtdcom_list *rtdcom; - struct snd_soc_component *component; struct snd_soc_dai *codec_dai; - int i, ret, num; + int i, ret;
dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", card->name, rtd->num, order);
- /* set default power off timeout */ - rtd->pmdown_time = pmdown_time; - ret = soc_probe_dai(cpu_dai, order); if (ret) return ret; @@ -1479,9 +1473,20 @@ static int soc_probe_link_dais(struct snd_soc_card *card, return ret; }
- /* complete DAI probe during last probe */ - if (order != SND_SOC_COMP_ORDER_LAST) - return 0; + return 0; +} + +static int soc_link_init(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai_link *dai_link = rtd->dai_link; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + int ret, num; + + /* set default power off timeout */ + rtd->pmdown_time = pmdown_time;
/* do machine specific initialization */ if (dai_link->init) { @@ -2041,6 +2046,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) } }
+ for_each_card_rtds(card, rtd) + soc_link_init(card, rtd); + snd_soc_dapm_link_dai_widgets(card); snd_soc_dapm_connect_dai_link_widgets(card);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_probe_link_dais() implementation is very half, thus it is very difficult to read.
for_each_comp_order(xxx) { for_each_card_rtds(xxx) => soc_probe_link_dais(xxx); }
This patch does all for_each_xxx() under soc_probe_link_dais(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1e74ab8..36b86e3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1452,25 +1452,30 @@ static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, return 0; }
-static int soc_probe_link_dais(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd, int order) +static int soc_probe_link_dais(struct snd_soc_card *card) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; - int i, ret; + struct snd_soc_pcm_runtime *rtd; + int i, order, ret;
- dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", - card->name, rtd->num, order); + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) {
- ret = soc_probe_dai(cpu_dai, order); - if (ret) - return ret; + dev_dbg(card->dev, + "ASoC: probe %s dai link %d late %d\n", + card->name, rtd->num, order);
- /* probe the CODEC DAI */ - for_each_rtd_codec_dai(rtd, i, codec_dai) { - ret = soc_probe_dai(codec_dai, order); - if (ret) - return ret; + ret = soc_probe_dai(rtd->cpu_dai, order); + if (ret) + return ret; + + /* probe the CODEC DAI */ + for_each_rtd_codec_dai(rtd, i, codec_dai) { + ret = soc_probe_dai(codec_dai, order); + if (ret) + return ret; + } + } }
return 0; @@ -1933,7 +1938,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; struct snd_soc_aux_dev *aux; - int ret, i, order; + int ret, i;
mutex_lock(&client_mutex); for_each_card_prelinks(card, i, dai_link) { @@ -2034,16 +2039,11 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }
/* probe all DAI links on this card */ - for_each_comp_order(order) { - for_each_card_rtds(card, rtd) { - ret = soc_probe_link_dais(card, rtd, order); - if (ret < 0) { - dev_err(card->dev, - "ASoC: failed to instantiate card %d\n", - ret); - goto probe_end; - } - } + ret = soc_probe_link_dais(card); + if (ret < 0) { + dev_err(card->dev, + "ASoC: failed to instantiate card %d\n", ret); + goto probe_end; }
for_each_card_rtds(card, rtd)
The patch
ASoC: soc-core: self contained soc_probe_link_dais()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 c7e73774f2f4213e75670f393a7b253620e04441 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:15:17 +0900 Subject: [PATCH] ASoC: soc-core: self contained soc_probe_link_dais()
Current soc_probe_link_dais() implementation is very half, thus it is very difficult to read.
for_each_comp_order(xxx) { for_each_card_rtds(xxx) => soc_probe_link_dais(xxx); }
This patch does all for_each_xxx() under soc_probe_link_dais(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87woeoor1m.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1e74ab8e6a25..36b86e3c193c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1452,25 +1452,30 @@ static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, return 0; }
-static int soc_probe_link_dais(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd, int order) +static int soc_probe_link_dais(struct snd_soc_card *card) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; - int i, ret; + struct snd_soc_pcm_runtime *rtd; + int i, order, ret;
- dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", - card->name, rtd->num, order); + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) {
- ret = soc_probe_dai(cpu_dai, order); - if (ret) - return ret; + dev_dbg(card->dev, + "ASoC: probe %s dai link %d late %d\n", + card->name, rtd->num, order);
- /* probe the CODEC DAI */ - for_each_rtd_codec_dai(rtd, i, codec_dai) { - ret = soc_probe_dai(codec_dai, order); - if (ret) - return ret; + ret = soc_probe_dai(rtd->cpu_dai, order); + if (ret) + return ret; + + /* probe the CODEC DAI */ + for_each_rtd_codec_dai(rtd, i, codec_dai) { + ret = soc_probe_dai(codec_dai, order); + if (ret) + return ret; + } + } }
return 0; @@ -1933,7 +1938,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; struct snd_soc_aux_dev *aux; - int ret, i, order; + int ret, i;
mutex_lock(&client_mutex); for_each_card_prelinks(card, i, dai_link) { @@ -2034,16 +2039,11 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }
/* probe all DAI links on this card */ - for_each_comp_order(order) { - for_each_card_rtds(card, rtd) { - ret = soc_probe_link_dais(card, rtd, order); - if (ret < 0) { - dev_err(card->dev, - "ASoC: failed to instantiate card %d\n", - ret); - goto probe_end; - } - } + ret = soc_probe_link_dais(card); + if (ret < 0) { + dev_err(card->dev, + "ASoC: failed to instantiate card %d\n", ret); + goto probe_end; }
for_each_card_rtds(card, rtd)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
It is easy to read code if it is cleanly using paired function/naming, like start <-> stop, register <-> unregister, etc, etc. But, current ALSA SoC code is very random, unbalance, not paired, etc. It is easy to create bug at the such code, and it will be difficult to debug.
This patch moves soc_probe_link_dais() next to soc_remove_link_dais() which is paired function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 58 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 36b86e3..20381f6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1149,6 +1149,35 @@ static void soc_remove_link_dais(struct snd_soc_card *card) } }
+static int soc_probe_link_dais(struct snd_soc_card *card) +{ + struct snd_soc_dai *codec_dai; + struct snd_soc_pcm_runtime *rtd; + int i, order, ret; + + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) { + + dev_dbg(card->dev, + "ASoC: probe %s dai link %d late %d\n", + card->name, rtd->num, order); + + ret = soc_probe_dai(rtd->cpu_dai, order); + if (ret) + return ret; + + /* probe the CODEC DAI */ + for_each_rtd_codec_dai(rtd, i, codec_dai) { + ret = soc_probe_dai(codec_dai, order); + if (ret) + return ret; + } + } + } + + return 0; +} + static void soc_remove_link_components(struct snd_soc_card *card) { struct snd_soc_component *component; @@ -1452,35 +1481,6 @@ static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, return 0; }
-static int soc_probe_link_dais(struct snd_soc_card *card) -{ - struct snd_soc_dai *codec_dai; - struct snd_soc_pcm_runtime *rtd; - int i, order, ret; - - for_each_comp_order(order) { - for_each_card_rtds(card, rtd) { - - dev_dbg(card->dev, - "ASoC: probe %s dai link %d late %d\n", - card->name, rtd->num, order); - - ret = soc_probe_dai(rtd->cpu_dai, order); - if (ret) - return ret; - - /* probe the CODEC DAI */ - for_each_rtd_codec_dai(rtd, i, codec_dai) { - ret = soc_probe_dai(codec_dai, order); - if (ret) - return ret; - } - } - } - - return 0; -} - static int soc_link_init(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd) {
The patch
ASoC: soc-core: move soc_probe_link_dais() next to soc_remove_link_dais()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 bc7c16c226a919a509e4161c905bfe9981a17f02 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:15:23 +0900 Subject: [PATCH] ASoC: soc-core: move soc_probe_link_dais() next to soc_remove_link_dais()
It is easy to read code if it is cleanly using paired function/naming, like start <-> stop, register <-> unregister, etc, etc. But, current ALSA SoC code is very random, unbalance, not paired, etc. It is easy to create bug at the such code, and it will be difficult to debug.
This patch moves soc_probe_link_dais() next to soc_remove_link_dais() which is paired function.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87v9u8or1g.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 58 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 36b86e3c193c..20381f69a34b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1149,6 +1149,35 @@ static void soc_remove_link_dais(struct snd_soc_card *card) } }
+static int soc_probe_link_dais(struct snd_soc_card *card) +{ + struct snd_soc_dai *codec_dai; + struct snd_soc_pcm_runtime *rtd; + int i, order, ret; + + for_each_comp_order(order) { + for_each_card_rtds(card, rtd) { + + dev_dbg(card->dev, + "ASoC: probe %s dai link %d late %d\n", + card->name, rtd->num, order); + + ret = soc_probe_dai(rtd->cpu_dai, order); + if (ret) + return ret; + + /* probe the CODEC DAI */ + for_each_rtd_codec_dai(rtd, i, codec_dai) { + ret = soc_probe_dai(codec_dai, order); + if (ret) + return ret; + } + } + } + + return 0; +} + static void soc_remove_link_components(struct snd_soc_card *card) { struct snd_soc_component *component; @@ -1452,35 +1481,6 @@ static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, return 0; }
-static int soc_probe_link_dais(struct snd_soc_card *card) -{ - struct snd_soc_dai *codec_dai; - struct snd_soc_pcm_runtime *rtd; - int i, order, ret; - - for_each_comp_order(order) { - for_each_card_rtds(card, rtd) { - - dev_dbg(card->dev, - "ASoC: probe %s dai link %d late %d\n", - card->name, rtd->num, order); - - ret = soc_probe_dai(rtd->cpu_dai, order); - if (ret) - return ret; - - /* probe the CODEC DAI */ - for_each_rtd_codec_dai(rtd, i, codec_dai) { - ret = soc_probe_dai(codec_dai, order); - if (ret) - return ret; - } - } - } - - return 0; -} - static int soc_link_init(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd) {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_bind_aux_dev() implementation is very half, thus it is very unreadable.
for_each_card_pre_auxs(xxx) { => ret = soc_bind_aux_dev(xxx); ... }
This patch does all for_each_xxx() under soc_bind_aux_dev(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 20381f6..d7761df 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1559,20 +1559,22 @@ static int soc_link_init(struct snd_soc_card *card, return ret; }
-static int soc_bind_aux_dev(struct snd_soc_card *card, - struct snd_soc_aux_dev *aux_dev) +static int soc_bind_aux_dev(struct snd_soc_card *card) { struct snd_soc_component *component; + struct snd_soc_aux_dev *aux; + int i;
- /* codecs, usually analog devices */ - component = soc_find_component(&aux_dev->dlc); - if (!component) - return -EPROBE_DEFER; - - component->init = aux_dev->init; - /* see for_each_card_auxs */ - list_add(&component->card_aux_list, &card->aux_comp_list); + for_each_card_pre_auxs(card, i, aux) { + /* codecs, usually analog devices */ + component = soc_find_component(&aux->dlc); + if (!component) + return -EPROBE_DEFER;
+ component->init = aux->init; + /* see for_each_card_auxs */ + list_add(&component->card_aux_list, &card->aux_comp_list); + } return 0; }
@@ -1937,7 +1939,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; - struct snd_soc_aux_dev *aux; int ret, i;
mutex_lock(&client_mutex); @@ -1965,11 +1966,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }
/* bind aux_devs too */ - for_each_card_pre_auxs(card, i, aux) { - ret = soc_bind_aux_dev(card, aux); - if (ret != 0) - goto probe_end; - } + ret = soc_bind_aux_dev(card); + if (ret < 0) + goto probe_end;
/* add predefined DAI links to the list */ for_each_card_prelinks(card, i, dai_link) {
The patch
ASoC: soc-core: self contained soc_bind_aux_dev()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 bee886f1ea9d9e58bef8204c543a409c399f8744 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:15:28 +0900 Subject: [PATCH] ASoC: soc-core: self contained soc_bind_aux_dev()
Current soc_bind_aux_dev() implementation is very half, thus it is very unreadable.
for_each_card_pre_auxs(xxx) { => ret = soc_bind_aux_dev(xxx); ... }
This patch does all for_each_xxx() under soc_bind_aux_dev(), and makes it to self contained.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87tv9sor1b.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 20381f69a34b..d7761df03e19 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1559,20 +1559,22 @@ static int soc_link_init(struct snd_soc_card *card, return ret; }
-static int soc_bind_aux_dev(struct snd_soc_card *card, - struct snd_soc_aux_dev *aux_dev) +static int soc_bind_aux_dev(struct snd_soc_card *card) { struct snd_soc_component *component; + struct snd_soc_aux_dev *aux; + int i;
- /* codecs, usually analog devices */ - component = soc_find_component(&aux_dev->dlc); - if (!component) - return -EPROBE_DEFER; - - component->init = aux_dev->init; - /* see for_each_card_auxs */ - list_add(&component->card_aux_list, &card->aux_comp_list); + for_each_card_pre_auxs(card, i, aux) { + /* codecs, usually analog devices */ + component = soc_find_component(&aux->dlc); + if (!component) + return -EPROBE_DEFER;
+ component->init = aux->init; + /* see for_each_card_auxs */ + list_add(&component->card_aux_list, &card->aux_comp_list); + } return 0; }
@@ -1937,7 +1939,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; - struct snd_soc_aux_dev *aux; int ret, i;
mutex_lock(&client_mutex); @@ -1965,11 +1966,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }
/* bind aux_devs too */ - for_each_card_pre_auxs(card, i, aux) { - ret = soc_bind_aux_dev(card, aux); - if (ret != 0) - goto probe_end; - } + ret = soc_bind_aux_dev(card); + if (ret < 0) + goto probe_end;
/* add predefined DAI links to the list */ for_each_card_prelinks(card, i, dai_link) {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
It is easy to read code if it is cleanly using paired function/naming, like start <-> stop, register <-> unregister, etc, etc. But, current ALSA SoC code is very random, unbalance, not paired, etc. It is easy to create bug at the such code, and it will be difficult to debug.
soc-core.c has soc_bind_aux_dev(), but, there is no its paired soc_unbind_aux_dev(). This patch adds soc_unbind_aux_dev().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d7761df..2960070 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1559,6 +1559,12 @@ static int soc_link_init(struct snd_soc_card *card, return ret; }
+static void soc_unbind_aux_dev(struct snd_soc_component *component) +{ + component->init = NULL; + list_del(&component->card_aux_list); +} + static int soc_bind_aux_dev(struct snd_soc_card *card) { struct snd_soc_component *component; @@ -1612,7 +1618,7 @@ static void soc_remove_aux_devices(struct snd_soc_card *card) if (comp->driver->remove_order == order) { soc_remove_component(comp); /* remove it from the card's aux_comp_list */ - list_del(&comp->card_aux_list); + soc_unbind_aux_dev(comp); } } }
The patch
ASoC: soc-core: add soc_unbind_aux_dev()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 4893a2eb34a9722501915a0b75844aa11956c10d Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:15:35 +0900 Subject: [PATCH] ASoC: soc-core: add soc_unbind_aux_dev()
It is easy to read code if it is cleanly using paired function/naming, like start <-> stop, register <-> unregister, etc, etc. But, current ALSA SoC code is very random, unbalance, not paired, etc. It is easy to create bug at the such code, and it will be difficult to debug.
soc-core.c has soc_bind_aux_dev(), but, there is no its paired soc_unbind_aux_dev(). This patch adds soc_unbind_aux_dev().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87sgpcor14.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d7761df03e19..2960070e68bc 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1559,6 +1559,12 @@ static int soc_link_init(struct snd_soc_card *card, return ret; }
+static void soc_unbind_aux_dev(struct snd_soc_component *component) +{ + component->init = NULL; + list_del(&component->card_aux_list); +} + static int soc_bind_aux_dev(struct snd_soc_card *card) { struct snd_soc_component *component; @@ -1612,7 +1618,7 @@ static void soc_remove_aux_devices(struct snd_soc_card *card) if (comp->driver->remove_order == order) { soc_remove_component(comp); /* remove it from the card's aux_comp_list */ - list_del(&comp->card_aux_list); + soc_unbind_aux_dev(comp); } } }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_unbind_aux_dev() implementation is very half, thus it is very unreadable.
for_each_comp_order(order) { for_each_card_auxs_safe(card, comp, _comp) {
(1) if (comp->driver->remove_order == order) { ... => soc_unbind_aux_dev(comp); } }
soc_unbind_aux_dev() itself is not related to remove_order (1). And, it is called from soc_remove_aux_devices(), even though its paired function soc_bind_aux_dev() is called from snd_soc_instantiate_card(). It is very unbalance, and very difficult to understand.
This patch do 1) update soc_bind_aux_dev() to self contained 2) call it from soc_cleanup_card_resources() to make up balance
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2960070..35f48e9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1559,10 +1559,14 @@ static int soc_link_init(struct snd_soc_card *card, return ret; }
-static void soc_unbind_aux_dev(struct snd_soc_component *component) +static void soc_unbind_aux_dev(struct snd_soc_card *card) { - component->init = NULL; - list_del(&component->card_aux_list); + struct snd_soc_component *component, *_component; + + for_each_card_auxs_safe(card, component, _component) { + component->init = NULL; + list_del(&component->card_aux_list); + } }
static int soc_bind_aux_dev(struct snd_soc_card *card) @@ -1614,12 +1618,8 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)
for_each_comp_order(order) { for_each_card_auxs_safe(card, comp, _comp) { - - if (comp->driver->remove_order == order) { + if (comp->driver->remove_order == order) soc_remove_component(comp); - /* remove it from the card's aux_comp_list */ - soc_unbind_aux_dev(comp); - } } } } @@ -1932,6 +1932,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
/* remove auxiliary devices */ soc_remove_aux_devices(card); + soc_unbind_aux_dev(card);
snd_soc_dapm_free(&card->dapm); soc_cleanup_card_debugfs(card);
On Wed, Sep 04, 2019 at 09:15:40AM +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc_unbind_aux_dev() implementation is very half, thus it is very unreadable.
You only just added this in the previous patch! :P
The patch
ASoC: soc-core: self contained soc_unbind_aux_dev()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4
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 e8fbd2505242467044ec51bf57c642a50ed28a14 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 4 Sep 2019 09:15:40 +0900 Subject: [PATCH] ASoC: soc-core: self contained soc_unbind_aux_dev()
Current soc_unbind_aux_dev() implementation is very half, thus it is very unreadable.
for_each_comp_order(order) { for_each_card_auxs_safe(card, comp, _comp) {
(1) if (comp->driver->remove_order == order) { ... => soc_unbind_aux_dev(comp); } }
soc_unbind_aux_dev() itself is not related to remove_order (1). And, it is called from soc_remove_aux_devices(), even though its paired function soc_bind_aux_dev() is called from snd_soc_instantiate_card(). It is very unbalance, and very difficult to understand.
This patch do 1) update soc_bind_aux_dev() to self contained 2) call it from soc_cleanup_card_resources() to make up balance
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87r24wor0z.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2960070e68bc..35f48e9c5ead 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1559,10 +1559,14 @@ static int soc_link_init(struct snd_soc_card *card, return ret; }
-static void soc_unbind_aux_dev(struct snd_soc_component *component) +static void soc_unbind_aux_dev(struct snd_soc_card *card) { - component->init = NULL; - list_del(&component->card_aux_list); + struct snd_soc_component *component, *_component; + + for_each_card_auxs_safe(card, component, _component) { + component->init = NULL; + list_del(&component->card_aux_list); + } }
static int soc_bind_aux_dev(struct snd_soc_card *card) @@ -1614,12 +1618,8 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)
for_each_comp_order(order) { for_each_card_auxs_safe(card, comp, _comp) { - - if (comp->driver->remove_order == order) { + if (comp->driver->remove_order == order) soc_remove_component(comp); - /* remove it from the card's aux_comp_list */ - soc_unbind_aux_dev(comp); - } } } } @@ -1932,6 +1932,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
/* remove auxiliary devices */ soc_remove_aux_devices(card); + soc_unbind_aux_dev(card);
snd_soc_dapm_free(&card->dapm); soc_cleanup_card_debugfs(card);
participants (2)
-
Kuninori Morimoto
-
Mark Brown