[alsa-devel] [PATCH 0/9] ASoC: soc-core: cleanup step5
Hi Mark
These are soc-core cleanup step5. My apology that it is randomly cleanupping.
Kuninori Morimoto (9): ASoC: soc-core: remove soc_is_dai_link_bound() ASoC: soc-core: merge snd_soc_register_dai() and soc_add_dai() ASoC: soc-core: merge snd_soc_unregister_dai() and soc_del_dai() ASoC: soc-core: merge snd_soc_add_dai_link() and soc_bind_dai_link() ASoC: soc-core: merge snd_soc_remove_dai_link() and soc_unbind_dai_link() ASoC: soc-core: merge soc_remove_component() and soc_cleanup_component() ASoC: soc-core: merge snd_soc_bind_card() and snd_soc_instantiate_card() ASoC: soc-core: tidyup soc_probe_aux_devices() ASoC: soc-core: call snd_soc_dapm_shutdown() at soc_cleanup_card_resources()
sound/soc/soc-core.c | 281 ++++++++++++++++++++------------------------------- 1 file changed, 107 insertions(+), 174 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Because complex separeted "card pre-listed component" and "topology added component" duplicated operation is now becoming simple, we don't need to check already bound dai_link which is not exist anymore. This patch removes soc_is_dai_link_bound().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 19 ------------------- 1 file changed, 19 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index cc59687..dff91db 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -943,19 +943,6 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(snd_soc_find_dai_link);
-static bool soc_is_dai_link_bound(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - struct snd_soc_pcm_runtime *rtd; - - for_each_card_rtds(card, rtd) { - if (rtd->dai_link == dai_link) - return true; - } - - return false; -} - static int soc_dai_link_sanity_check(struct snd_soc_card *card, struct snd_soc_dai_link *link) { @@ -1075,12 +1062,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name);
- if (soc_is_dai_link_bound(card, dai_link)) { - dev_dbg(card->dev, "ASoC: dai link %s already bound\n", - dai_link->name); - return 0; - } - ret = soc_dai_link_sanity_check(card, dai_link); if (ret < 0) return ret;
The patch
ASoC: soc-core: remove soc_is_dai_link_bound()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5
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 0d18a7caa654ea1a0c02b3a253adfd5c10723871 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 6 Nov 2019 10:07:07 +0900 Subject: [PATCH] ASoC: soc-core: remove soc_is_dai_link_bound()
Because complex separeted "card pre-listed component" and "topology added component" duplicated operation is now becoming simple, we don't need to check already bound dai_link which is not exist anymore. This patch removes soc_is_dai_link_bound().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87v9rxhkxw.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 19 ------------------- 1 file changed, 19 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 55014e7ae0d8..c6885adbdc8b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -953,19 +953,6 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(snd_soc_find_dai_link);
-static bool soc_is_dai_link_bound(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - struct snd_soc_pcm_runtime *rtd; - - for_each_card_rtds(card, rtd) { - if (rtd->dai_link == dai_link) - return true; - } - - return false; -} - static int soc_dai_link_sanity_check(struct snd_soc_card *card, struct snd_soc_dai_link *link) { @@ -1085,12 +1072,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name);
- if (soc_is_dai_link_bound(card, dai_link)) { - dev_dbg(card->dev, "ASoC: dai link %s already bound\n", - dai_link->name); - return 0; - } - ret = soc_dai_link_sanity_check(card, dai_link); if (ret < 0) return ret;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
We don't need to separete snd_soc_register_dai() and soc_add_dai() anymore. Let's merge these
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index dff91db..ffdb8ce 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2505,16 +2505,27 @@ static void soc_del_dai(struct snd_soc_dai *dai) list_del(&dai->list); }
-/* Create a DAI and add it to the component's DAI list */ -static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component, - struct snd_soc_dai_driver *dai_drv, - bool legacy_dai_naming) +/** + * snd_soc_register_dai - Register a DAI dynamically & create its widgets + * + * @component: The component the DAIs are registered for + * @dai_drv: DAI driver to use for the DAI + * + * Topology can use this API to register DAIs when probing a component. + * These DAIs's widgets will be freed in the card cleanup and the DAIs + * will be freed in the component cleanup. + */ +struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, + struct snd_soc_dai_driver *dai_drv, + bool legacy_dai_naming) { struct device *dev = component->dev; struct snd_soc_dai *dai;
dev_dbg(dev, "ASoC: dynamically register DAI %s\n", dev_name(dev));
+ lockdep_assert_held(&client_mutex); + dai = devm_kzalloc(dev, sizeof(*dai), GFP_KERNEL); if (dai == NULL) return NULL; @@ -2553,6 +2564,7 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component, dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); return dai; } +EXPORT_SYMBOL_GPL(snd_soc_register_dai);
void snd_soc_unregister_dai(struct snd_soc_dai *dai) { @@ -2561,29 +2573,6 @@ void snd_soc_unregister_dai(struct snd_soc_dai *dai) EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
/** - * snd_soc_register_dai - Register a DAI dynamically & create its widgets - * - * @component: The component the DAIs are registered for - * @dai_drv: DAI driver to use for the DAI - * - * Topology can use this API to register DAIs when probing a component. - * These DAIs's widgets will be freed in the card cleanup and the DAIs - * will be freed in the component cleanup. - */ -struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, - struct snd_soc_dai_driver *dai_drv, - bool legacy_dai_naming) -{ - struct device *dev = component->dev; - - dev_dbg(dev, "ASoC: dai register %s\n", dai_drv->name); - - lockdep_assert_held(&client_mutex); - return soc_add_dai(component, dai_drv, legacy_dai_naming); -} -EXPORT_SYMBOL_GPL(snd_soc_register_dai); - -/** * snd_soc_unregister_dai - Unregister DAIs from the ASoC core * * @component: The component for which the DAIs should be unregistered
The patch
ASoC: soc-core: merge snd_soc_register_dai() and soc_add_dai()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5
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 7ca24386a7c2fb3828303b7c694cb0b4af1eac5c Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 6 Nov 2019 10:07:17 +0900 Subject: [PATCH] ASoC: soc-core: merge snd_soc_register_dai() and soc_add_dai()
We don't need to separete snd_soc_register_dai() and soc_add_dai() anymore. Let's merge these
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87tv7hhkxm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c6885adbdc8b..b2544c7ff0f4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2517,16 +2517,27 @@ static void soc_del_dai(struct snd_soc_dai *dai) list_del(&dai->list); }
-/* Create a DAI and add it to the component's DAI list */ -static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component, - struct snd_soc_dai_driver *dai_drv, - bool legacy_dai_naming) +/** + * snd_soc_register_dai - Register a DAI dynamically & create its widgets + * + * @component: The component the DAIs are registered for + * @dai_drv: DAI driver to use for the DAI + * + * Topology can use this API to register DAIs when probing a component. + * These DAIs's widgets will be freed in the card cleanup and the DAIs + * will be freed in the component cleanup. + */ +struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, + struct snd_soc_dai_driver *dai_drv, + bool legacy_dai_naming) { struct device *dev = component->dev; struct snd_soc_dai *dai;
dev_dbg(dev, "ASoC: dynamically register DAI %s\n", dev_name(dev));
+ lockdep_assert_held(&client_mutex); + dai = devm_kzalloc(dev, sizeof(*dai), GFP_KERNEL); if (dai == NULL) return NULL; @@ -2565,6 +2576,7 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component, dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); return dai; } +EXPORT_SYMBOL_GPL(snd_soc_register_dai);
void snd_soc_unregister_dai(struct snd_soc_dai *dai) { @@ -2572,29 +2584,6 @@ void snd_soc_unregister_dai(struct snd_soc_dai *dai) } EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
-/** - * snd_soc_register_dai - Register a DAI dynamically & create its widgets - * - * @component: The component the DAIs are registered for - * @dai_drv: DAI driver to use for the DAI - * - * Topology can use this API to register DAIs when probing a component. - * These DAIs's widgets will be freed in the card cleanup and the DAIs - * will be freed in the component cleanup. - */ -struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, - struct snd_soc_dai_driver *dai_drv, - bool legacy_dai_naming) -{ - struct device *dev = component->dev; - - dev_dbg(dev, "ASoC: dai register %s\n", dai_drv->name); - - lockdep_assert_held(&client_mutex); - return soc_add_dai(component, dai_drv, legacy_dai_naming); -} -EXPORT_SYMBOL_GPL(snd_soc_register_dai); - /** * snd_soc_unregister_dai - Unregister DAIs from the ASoC core *
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
We don't need to separete snd_soc_unregister_dai() and soc_del_dai() anymore. Let's merge these
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index ffdb8ce..02d9236 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2499,11 +2499,12 @@ static inline char *fmt_multiple_name(struct device *dev, return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL); }
-static void soc_del_dai(struct snd_soc_dai *dai) +void snd_soc_unregister_dai(struct snd_soc_dai *dai) { dev_dbg(dai->dev, "ASoC: Unregistered DAI '%s'\n", dai->name); list_del(&dai->list); } +EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
/** * snd_soc_register_dai - Register a DAI dynamically & create its widgets @@ -2564,13 +2565,6 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); return dai; } -EXPORT_SYMBOL_GPL(snd_soc_register_dai); - -void snd_soc_unregister_dai(struct snd_soc_dai *dai) -{ - soc_del_dai(dai); -} -EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
/** * snd_soc_unregister_dai - Unregister DAIs from the ASoC core
The patch
ASoC: soc-core: merge snd_soc_unregister_dai() and soc_del_dai()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5
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 ffdbca0be6c78ea32b9243eea976270441210f2f Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 6 Nov 2019 10:07:23 +0900 Subject: [PATCH] ASoC: soc-core: merge snd_soc_unregister_dai() and soc_del_dai()
We don't need to separete snd_soc_unregister_dai() and soc_del_dai() anymore. Let's merge these
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87sgn1hkxg.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b2544c7ff0f4..01a8fb28b48f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2511,11 +2511,12 @@ static inline char *fmt_multiple_name(struct device *dev, return devm_kstrdup(dev, dai_drv->name, GFP_KERNEL); }
-static void soc_del_dai(struct snd_soc_dai *dai) +void snd_soc_unregister_dai(struct snd_soc_dai *dai) { dev_dbg(dai->dev, "ASoC: Unregistered DAI '%s'\n", dai->name); list_del(&dai->list); } +EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
/** * snd_soc_register_dai - Register a DAI dynamically & create its widgets @@ -2576,13 +2577,6 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); return dai; } -EXPORT_SYMBOL_GPL(snd_soc_register_dai); - -void snd_soc_unregister_dai(struct snd_soc_dai *dai) -{ - soc_del_dai(dai); -} -EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
/** * snd_soc_unregister_dai - Unregister DAIs from the ASoC core
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
We don't need to separete snd_soc_add_dai_link() and soc_bind_dai_link() anymore. Let's merge these.
One note is that before this patch, it adds list (A) eventhough if it had dai_link->ignore (1), or already bounded dai_link (2). But I guess it is wrong. This patch also solve this issue.
/* BEFORE */ int soc_bind_dai_link(...) { ... (1) if (dai_link->ignore) return 0;
(2) if (soc_is_dai_link_bound(...)) return 0; ... }
int snd_soc_add_dai_link(...) { ... => ret = soc_bind_dai_link(...); => if (ret < 0) => return ret;
(A) list_add_tail(&dai_link->list, &card->dai_link_list); ... }
/* AFTER */
int snd_soc_add_dai_link(...) { ... (1) if (dai_link->ignore) return 0;
(2) if (soc_is_dai_link_bound(...)) return 0; ... (A) list_add_tail(&dai_link->list, &card->dai_link_list); return 0; }
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 62 +++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 37 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 02d9236..12198a9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1049,14 +1049,33 @@ static void soc_unbind_dai_link(struct snd_soc_card *card, soc_free_pcm_runtime(rtd); }
-static int soc_bind_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) +/** + * snd_soc_add_dai_link - Add a DAI link dynamically + * @card: The ASoC card to which the DAI link is added + * @dai_link: The new DAI link to add + * + * This function adds a DAI link to the ASoC card's link list. + * + * Note: Topology can use this API to add DAI links when probing the + * topology component. And machine drivers can still define static + * DAI links in dai_link array. + */ +int snd_soc_add_dai_link(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link_component *codec, *platform; struct snd_soc_component *component; int i, ret;
+ lockdep_assert_held(&client_mutex); + + /* + * Notify the machine driver for extra initialization + */ + if (card->add_dai_link) + card->add_dai_link(card, dai_link); + if (dai_link->ignore) return 0;
@@ -1105,12 +1124,16 @@ static int soc_bind_dai_link(struct snd_soc_card *card, } }
+ /* see for_each_card_links */ + list_add_tail(&dai_link->list, &card->dai_link_list); + return 0;
_err_defer: soc_free_pcm_runtime(rtd); return -EPROBE_DEFER; } +EXPORT_SYMBOL_GPL(snd_soc_add_dai_link);
static void soc_set_of_name_prefix(struct snd_soc_component *component) { @@ -1402,41 +1425,6 @@ void snd_soc_disconnect_sync(struct device *dev) EXPORT_SYMBOL_GPL(snd_soc_disconnect_sync);
/** - * snd_soc_add_dai_link - Add a DAI link dynamically - * @card: The ASoC card to which the DAI link is added - * @dai_link: The new DAI link to add - * - * This function adds a DAI link to the ASoC card's link list. - * - * Note: Topology can use this API to add DAI links when probing the - * topology component. And machine drivers can still define static - * DAI links in dai_link array. - */ -int snd_soc_add_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - int ret; - - lockdep_assert_held(&client_mutex); - - /* - * Notify the machine driver for extra initialization - */ - if (card->add_dai_link) - card->add_dai_link(card, dai_link); - - ret = soc_bind_dai_link(card, dai_link); - if (ret < 0) - return ret; - - /* see for_each_card_links */ - list_add_tail(&dai_link->list, &card->dai_link_list); - - return 0; -} -EXPORT_SYMBOL_GPL(snd_soc_add_dai_link); - -/** * snd_soc_remove_dai_link - Remove a DAI link from the list * @card: The ASoC card that owns the link * @dai_link: The DAI link to remove
The patch
ASoC: soc-core: merge snd_soc_add_dai_link() and soc_bind_dai_link()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5
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 63dc47da1f396fecd2373e41928e275f9ca3d924 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 6 Nov 2019 10:07:31 +0900 Subject: [PATCH] ASoC: soc-core: merge snd_soc_add_dai_link() and soc_bind_dai_link()
We don't need to separete snd_soc_add_dai_link() and soc_bind_dai_link() anymore. Let's merge these.
One note is that before this patch, it adds list (A) eventhough if it had dai_link->ignore (1), or already bounded dai_link (2). But I guess it is wrong. This patch also solve this issue.
/* BEFORE */ int soc_bind_dai_link(...) { ... (1) if (dai_link->ignore) return 0;
(2) if (soc_is_dai_link_bound(...)) return 0; ... }
int snd_soc_add_dai_link(...) { ... => ret = soc_bind_dai_link(...); => if (ret < 0) => return ret;
(A) list_add_tail(&dai_link->list, &card->dai_link_list); ... }
/* AFTER */
int snd_soc_add_dai_link(...) { ... (1) if (dai_link->ignore) return 0;
(2) if (soc_is_dai_link_bound(...)) return 0; ... (A) list_add_tail(&dai_link->list, &card->dai_link_list); return 0; }
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87r22lhkx8.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 62 ++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 37 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 01a8fb28b48f..8add98431881 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1059,14 +1059,33 @@ static void soc_unbind_dai_link(struct snd_soc_card *card, soc_free_pcm_runtime(rtd); }
-static int soc_bind_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) +/** + * snd_soc_add_dai_link - Add a DAI link dynamically + * @card: The ASoC card to which the DAI link is added + * @dai_link: The new DAI link to add + * + * This function adds a DAI link to the ASoC card's link list. + * + * Note: Topology can use this API to add DAI links when probing the + * topology component. And machine drivers can still define static + * DAI links in dai_link array. + */ +int snd_soc_add_dai_link(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link_component *codec, *platform; struct snd_soc_component *component; int i, ret;
+ lockdep_assert_held(&client_mutex); + + /* + * Notify the machine driver for extra initialization + */ + if (card->add_dai_link) + card->add_dai_link(card, dai_link); + if (dai_link->ignore) return 0;
@@ -1115,12 +1134,16 @@ static int soc_bind_dai_link(struct snd_soc_card *card, } }
+ /* see for_each_card_links */ + list_add_tail(&dai_link->list, &card->dai_link_list); + return 0;
_err_defer: soc_free_pcm_runtime(rtd); return -EPROBE_DEFER; } +EXPORT_SYMBOL_GPL(snd_soc_add_dai_link);
static void soc_set_of_name_prefix(struct snd_soc_component *component) { @@ -1411,41 +1434,6 @@ void snd_soc_disconnect_sync(struct device *dev) } EXPORT_SYMBOL_GPL(snd_soc_disconnect_sync);
-/** - * snd_soc_add_dai_link - Add a DAI link dynamically - * @card: The ASoC card to which the DAI link is added - * @dai_link: The new DAI link to add - * - * This function adds a DAI link to the ASoC card's link list. - * - * Note: Topology can use this API to add DAI links when probing the - * topology component. And machine drivers can still define static - * DAI links in dai_link array. - */ -int snd_soc_add_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - int ret; - - lockdep_assert_held(&client_mutex); - - /* - * Notify the machine driver for extra initialization - */ - if (card->add_dai_link) - card->add_dai_link(card, dai_link); - - ret = soc_bind_dai_link(card, dai_link); - if (ret < 0) - return ret; - - /* see for_each_card_links */ - list_add_tail(&dai_link->list, &card->dai_link_list); - - return 0; -} -EXPORT_SYMBOL_GPL(snd_soc_add_dai_link); - /** * snd_soc_remove_dai_link - Remove a DAI link from the list * @card: The ASoC card that owns the link
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
We don't need to separete snd_soc_remove_dai_link() and soc_unbind_dai_link() anymore. Let's merge these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 52 +++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 12198a9..28f94a2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1039,15 +1039,36 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card, return 0; }
-static void soc_unbind_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) +/** + * snd_soc_remove_dai_link - Remove a DAI link from the list + * @card: The ASoC card that owns the link + * @dai_link: The DAI link to remove + * + * This function removes a DAI link from the ASoC card's link list. + * + * For DAI links previously added by topology, topology should + * remove them by using the dobj embedded in the link. + */ +void snd_soc_remove_dai_link(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd;
+ lockdep_assert_held(&client_mutex); + + /* + * Notify the machine driver for extra destruction + */ + if (card->remove_dai_link) + card->remove_dai_link(card, dai_link); + + list_del(&dai_link->list); + rtd = snd_soc_get_pcm_runtime(card, dai_link->name); if (rtd) soc_free_pcm_runtime(rtd); } +EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link);
/** * snd_soc_add_dai_link - Add a DAI link dynamically @@ -1424,33 +1445,6 @@ void snd_soc_disconnect_sync(struct device *dev) } EXPORT_SYMBOL_GPL(snd_soc_disconnect_sync);
-/** - * snd_soc_remove_dai_link - Remove a DAI link from the list - * @card: The ASoC card that owns the link - * @dai_link: The DAI link to remove - * - * This function removes a DAI link from the ASoC card's link list. - * - * For DAI links previously added by topology, topology should - * remove them by using the dobj embedded in the link. - */ -void snd_soc_remove_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - lockdep_assert_held(&client_mutex); - - /* - * Notify the machine driver for extra destruction - */ - if (card->remove_dai_link) - card->remove_dai_link(card, dai_link); - - list_del(&dai_link->list); - - soc_unbind_dai_link(card, dai_link); -} -EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link); - 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: merge snd_soc_remove_dai_link() and soc_unbind_dai_link()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5
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 da704f26ba376bd93ac5234fa4605c4a8e4a5648 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 6 Nov 2019 10:07:38 +0900 Subject: [PATCH] ASoC: soc-core: merge snd_soc_remove_dai_link() and soc_unbind_dai_link()
We don't need to separete snd_soc_remove_dai_link() and soc_unbind_dai_link() anymore. Let's merge these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87pni5hkx1.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 52 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 8add98431881..d80d485f46d1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1049,15 +1049,36 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card, return 0; }
-static void soc_unbind_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) +/** + * snd_soc_remove_dai_link - Remove a DAI link from the list + * @card: The ASoC card that owns the link + * @dai_link: The DAI link to remove + * + * This function removes a DAI link from the ASoC card's link list. + * + * For DAI links previously added by topology, topology should + * remove them by using the dobj embedded in the link. + */ +void snd_soc_remove_dai_link(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd;
+ lockdep_assert_held(&client_mutex); + + /* + * Notify the machine driver for extra destruction + */ + if (card->remove_dai_link) + card->remove_dai_link(card, dai_link); + + list_del(&dai_link->list); + rtd = snd_soc_get_pcm_runtime(card, dai_link->name); if (rtd) soc_free_pcm_runtime(rtd); } +EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link);
/** * snd_soc_add_dai_link - Add a DAI link dynamically @@ -1434,33 +1455,6 @@ void snd_soc_disconnect_sync(struct device *dev) } EXPORT_SYMBOL_GPL(snd_soc_disconnect_sync);
-/** - * snd_soc_remove_dai_link - Remove a DAI link from the list - * @card: The ASoC card that owns the link - * @dai_link: The DAI link to remove - * - * This function removes a DAI link from the ASoC card's link list. - * - * For DAI links previously added by topology, topology should - * remove them by using the dobj embedded in the link. - */ -void snd_soc_remove_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) -{ - lockdep_assert_held(&client_mutex); - - /* - * Notify the machine driver for extra destruction - */ - if (card->remove_dai_link) - card->remove_dai_link(card, dai_link); - - list_del(&dai_link->list); - - soc_unbind_dai_link(card, dai_link); -} -EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link); - 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
having both soc_remove_component() and soc_cleanup_component() is very confusable. Let's merge these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 28f94a2..763a63d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1191,8 +1191,16 @@ static void soc_set_name_prefix(struct snd_soc_card *card, soc_set_of_name_prefix(component); }
-static void soc_cleanup_component(struct snd_soc_component *component) +static void soc_remove_component(struct snd_soc_component *component, + int probed) { + + if (!component->card) + return; + + if (probed) + snd_soc_component_remove(component); + /* For framework level robustness */ snd_soc_component_set_jack(component, NULL, NULL);
@@ -1203,22 +1211,13 @@ static void soc_cleanup_component(struct snd_soc_component *component) snd_soc_component_module_put_when_remove(component); }
-static void soc_remove_component(struct snd_soc_component *component) -{ - if (!component->card) - return; - - snd_soc_component_remove(component); - - soc_cleanup_component(component); -} - static int soc_probe_component(struct snd_soc_card *card, struct snd_soc_component *component) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct snd_soc_dai *dai; + int probed = 0; int ret;
if (!strcmp(component->name, "snd-soc-dummy")) @@ -1274,6 +1273,7 @@ static int soc_probe_component(struct snd_soc_card *card, dapm->bias_level != SND_SOC_BIAS_OFF, "codec %s can not start from non-off bias with idle_bias_off==1\n", component->name); + probed = 1;
/* machine specific init */ if (component->init) { @@ -1302,7 +1302,7 @@ static int soc_probe_component(struct snd_soc_card *card,
err_probe: if (ret < 0) - soc_cleanup_component(component); + soc_remove_component(component, probed);
return ret; } @@ -1404,7 +1404,7 @@ static void soc_remove_link_components(struct snd_soc_card *card) if (component->driver->remove_order != order) continue;
- soc_remove_component(component); + soc_remove_component(component, 1); } } } @@ -1598,7 +1598,7 @@ 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) - soc_remove_component(comp); + soc_remove_component(comp, 1); } } }
On Wed, Nov 06, 2019 at 10:07:46AM +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
having both soc_remove_component() and soc_cleanup_component() is very confusable. Let's merge these.
This doesn't apply against current code, please check and resend.
Hi Mark
Thank you for applying my patches
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
having both soc_remove_component() and soc_cleanup_component() is very confusable. Let's merge these.
This doesn't apply against current code, please check and resend.
I could find this patch as c6619b729814c855fc7bfa5a6936f5ea94d60dfd ("ASoC: soc-core: merge soc_remove_component() and soc_cleanup_component()")
Thank you for your help !! Best regards --- Kuninori Morimoto
The patch
ASoC: soc-core: merge soc_remove_component() and soc_cleanup_component()
has been applied to the asoc tree at
https://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 c6619b729814c855fc7bfa5a6936f5ea94d60dfd Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 6 Nov 2019 10:07:46 +0900 Subject: [PATCH] ASoC: soc-core: merge soc_remove_component() and soc_cleanup_component()
having both soc_remove_component() and soc_cleanup_component() is very confusable. Let's merge these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87o8xphkwt.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d80d485f46d1..11cbd7915154 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1201,8 +1201,16 @@ static void soc_set_name_prefix(struct snd_soc_card *card, soc_set_of_name_prefix(component); }
-static void soc_cleanup_component(struct snd_soc_component *component) +static void soc_remove_component(struct snd_soc_component *component, + int probed) { + + if (!component->card) + return; + + if (probed) + snd_soc_component_remove(component); + /* For framework level robustness */ snd_soc_component_set_jack(component, NULL, NULL);
@@ -1213,22 +1221,13 @@ static void soc_cleanup_component(struct snd_soc_component *component) snd_soc_component_module_put_when_remove(component); }
-static void soc_remove_component(struct snd_soc_component *component) -{ - if (!component->card) - return; - - snd_soc_component_remove(component); - - soc_cleanup_component(component); -} - static int soc_probe_component(struct snd_soc_card *card, struct snd_soc_component *component) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct snd_soc_dai *dai; + int probed = 0; int ret;
if (!strcmp(component->name, "snd-soc-dummy")) @@ -1284,6 +1283,7 @@ static int soc_probe_component(struct snd_soc_card *card, dapm->bias_level != SND_SOC_BIAS_OFF, "codec %s can not start from non-off bias with idle_bias_off==1\n", component->name); + probed = 1;
/* machine specific init */ if (component->init) { @@ -1312,7 +1312,7 @@ static int soc_probe_component(struct snd_soc_card *card,
err_probe: if (ret < 0) - soc_cleanup_component(component); + soc_remove_component(component, probed);
return ret; } @@ -1414,7 +1414,7 @@ static void soc_remove_link_components(struct snd_soc_card *card) if (component->driver->remove_order != order) continue;
- soc_remove_component(component); + soc_remove_component(component, 1); } } } @@ -1608,7 +1608,7 @@ 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) - soc_remove_component(comp); + soc_remove_component(comp, 1); } } }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
having both soc_bind_card() and snd_soc_instantiate_card() is very confusable. Let's merge these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 763a63d..4ec71fc 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1962,7 +1962,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card) card->remove(card); }
-static int snd_soc_instantiate_card(struct snd_soc_card *card) +static int snd_soc_bind_card(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; @@ -2094,6 +2094,19 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) dapm_mark_endpoints_dirty(card); snd_soc_dapm_sync(&card->dapm);
+ /* deactivate pins to sleep state */ + for_each_card_rtds(card, rtd) { + struct snd_soc_dai *dai; + + for_each_rtd_codec_dai(rtd, i, dai) { + if (!dai->active) + pinctrl_pm_select_sleep_state(dai->dev); + } + + if (!rtd->cpu_dai->active) + pinctrl_pm_select_sleep_state(rtd->cpu_dai->dev); + } + probe_end: if (ret < 0) soc_cleanup_card_resources(card); @@ -2326,33 +2339,6 @@ int snd_soc_add_dai_controls(struct snd_soc_dai *dai, } EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
-static int snd_soc_bind_card(struct snd_soc_card *card) -{ - struct snd_soc_pcm_runtime *rtd; - int ret; - - ret = snd_soc_instantiate_card(card); - if (ret != 0) - return ret; - - /* deactivate pins to sleep state */ - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai; - int j; - - for_each_rtd_codec_dai(rtd, j, codec_dai) { - if (!codec_dai->active) - pinctrl_pm_select_sleep_state(codec_dai->dev); - } - - if (!cpu_dai->active) - pinctrl_pm_select_sleep_state(cpu_dai->dev); - } - - return ret; -} - /** * snd_soc_register_card - Register a card with the ASoC core *
The patch
ASoC: soc-core: merge snd_soc_bind_card() and snd_soc_instantiate_card()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5
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 ed90c013a773b5f9e06089d0eed6714761152d14 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 6 Nov 2019 10:07:56 +0900 Subject: [PATCH] ASoC: soc-core: merge snd_soc_bind_card() and snd_soc_instantiate_card()
having both soc_bind_card() and snd_soc_instantiate_card() is very confusable. Let's merge these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87mud9hkwj.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 11cbd7915154..f3d33a908fbc 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1974,7 +1974,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card) card->remove(card); }
-static int snd_soc_instantiate_card(struct snd_soc_card *card) +static int snd_soc_bind_card(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; @@ -2106,6 +2106,19 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) dapm_mark_endpoints_dirty(card); snd_soc_dapm_sync(&card->dapm);
+ /* deactivate pins to sleep state */ + for_each_card_rtds(card, rtd) { + struct snd_soc_dai *dai; + + for_each_rtd_codec_dai(rtd, i, dai) { + if (!dai->active) + pinctrl_pm_select_sleep_state(dai->dev); + } + + if (!rtd->cpu_dai->active) + pinctrl_pm_select_sleep_state(rtd->cpu_dai->dev); + } + probe_end: if (ret < 0) soc_cleanup_card_resources(card); @@ -2338,33 +2351,6 @@ int snd_soc_add_dai_controls(struct snd_soc_dai *dai, } EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
-static int snd_soc_bind_card(struct snd_soc_card *card) -{ - struct snd_soc_pcm_runtime *rtd; - int ret; - - ret = snd_soc_instantiate_card(card); - if (ret != 0) - return ret; - - /* deactivate pins to sleep state */ - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai; - int j; - - for_each_rtd_codec_dai(rtd, j, codec_dai) { - if (!codec_dai->active) - pinctrl_pm_select_sleep_state(codec_dai->dev); - } - - if (!cpu_dai->active) - pinctrl_pm_select_sleep_state(cpu_dai->dev); - } - - return ret; -} - /** * snd_soc_register_card - Register a card with the ASoC core *
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
snd_soc_bind_card() is calling many initialize functions for each card / link / dai / aux etc, etc, etc... When error happen, the message is indicated at snd_soc_bind_card(), not at each functions. But, only soc_probe_aux_devices() case is indicating error at functions, not at snd_soc_bind_card(). It is not an issue, but unbalanced.
This patch moves error message to snd_soc_bind_card(). Also avoids deep-nested code.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4ec71fc..927b9c9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1569,21 +1569,18 @@ static int soc_bind_aux_dev(struct snd_soc_card *card)
static int soc_probe_aux_devices(struct snd_soc_card *card) { - struct snd_soc_component *comp; + struct snd_soc_component *component; int order; int ret;
for_each_comp_order(order) { - for_each_card_auxs(card, comp) { - if (comp->driver->probe_order == order) { - ret = soc_probe_component(card, comp); - if (ret < 0) { - dev_err(card->dev, - "ASoC: failed to probe aux component %s %d\n", - comp->name, ret); - return ret; - } - } + for_each_card_auxs(card, component) { + if (component->driver->probe_order != order) + continue; + + ret = soc_probe_component(card, component); + if (ret < 0) + return ret; } }
@@ -2030,8 +2027,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
/* probe auxiliary components */ ret = soc_probe_aux_devices(card); - if (ret < 0) + if (ret < 0) { + dev_err(card->dev, + "ASoC: failed to probe aux component %d\n", ret); goto probe_end; + }
/* probe all DAI links on this card */ ret = soc_probe_link_dais(card);
The patch
ASoC: soc-core: tidyup soc_probe_aux_devices()
has been applied to the asoc tree at
https://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 74bd3f92d0d173fe4c0a12cf736c505ceb15576a Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Wed, 6 Nov 2019 10:08:06 +0900 Subject: [PATCH] ASoC: soc-core: tidyup soc_probe_aux_devices()
snd_soc_bind_card() is calling many initialize functions for each card / link / dai / aux etc, etc, etc... When error happen, the message is indicated at snd_soc_bind_card(), not at each functions. But, only soc_probe_aux_devices() case is indicating error at functions, not at snd_soc_bind_card(). It is not an issue, but unbalanced.
This patch moves error message to snd_soc_bind_card(). Also avoids deep-nested code.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87lfsthkw9.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index f3d33a908fbc..92260a9569a2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1579,21 +1579,18 @@ static int soc_bind_aux_dev(struct snd_soc_card *card)
static int soc_probe_aux_devices(struct snd_soc_card *card) { - struct snd_soc_component *comp; + struct snd_soc_component *component; int order; int ret;
for_each_comp_order(order) { - for_each_card_auxs(card, comp) { - if (comp->driver->probe_order == order) { - ret = soc_probe_component(card, comp); - if (ret < 0) { - dev_err(card->dev, - "ASoC: failed to probe aux component %s %d\n", - comp->name, ret); - return ret; - } - } + for_each_card_auxs(card, component) { + if (component->driver->probe_order != order) + continue; + + ret = soc_probe_component(card, component); + if (ret < 0) + return ret; } }
@@ -2042,8 +2039,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
/* probe auxiliary components */ ret = soc_probe_aux_devices(card); - if (ret < 0) + if (ret < 0) { + dev_err(card->dev, + "ASoC: failed to probe aux component %d\n", ret); goto probe_end; + }
/* probe all DAI links on this card */ ret = soc_probe_link_dais(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.
snd_soc_bind_card() is calling snd_soc_dapm_init() for both card and component. Let's call paired snd_soc_dapm_shutdown() at paired soc_cleanup_card_resources().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 927b9c9..0bed63e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1940,6 +1940,8 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card) card->snd_card = NULL; }
+ snd_soc_dapm_shutdown(card); + /* remove and free each DAI */ soc_remove_link_dais(card); soc_remove_link_components(card); @@ -2377,7 +2379,6 @@ static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) { if (card->instantiated) { card->instantiated = false; - snd_soc_dapm_shutdown(card); snd_soc_flush_all_delayed_work(card);
soc_cleanup_card_resources(card);
On Tue, Nov 5, 2019 at 5:14 PM Kuninori Morimoto < kuninori.morimoto.gx@renesas.com> wrote:
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.
snd_soc_bind_card() is calling snd_soc_dapm_init() for both card and component. Let's call paired snd_soc_dapm_shutdown() at paired soc_cleanup_card_resources().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
sound/soc/soc-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 927b9c9..0bed63e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1940,6 +1940,8 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card) card->snd_card = NULL; }
snd_soc_dapm_shutdown(card);
/* remove and free each DAI */ soc_remove_link_dais(card); soc_remove_link_components(card);
@@ -2377,7 +2379,6 @@ static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister)
Morimoto-san,
You removed snd_soc_bind_card in one of the patches but then leaving snd_soc_unbind_card() will be unbalanced isnt it?
Why not just have instantiate_card() and cleanup_card_resources()?
Thanks, Ranjani
{ if (card->instantiated) { card->instantiated = false;
snd_soc_dapm_shutdown(card); snd_soc_flush_all_delayed_work(card); soc_cleanup_card_resources(card);
-- 2.7.4
Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Hi Ranjani
Thank you for your review
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. snd_soc_bind_card() is calling snd_soc_dapm_init() for both card and component. Let's call paired snd_soc_dapm_shutdown() at paired soc_cleanup_card_resources(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> ---
(snip)
You removed snd_soc_bind_card in one of the patches but then leaving snd_soc_unbind_card() will be unbalanced isnt it?
Why not just have instantiate_card() and cleanup_card_resources()?
Do you mean [7/9] patch ? It merges snd_soc_instantiate_card() and snd_soc_bind_card(). Thus, snd_soc_bind_card() is still exist. Or am I misunderstanding ?
Thank you for your help !! Best regards --- Kuninori Morimoto
On Tue, Nov 5, 2019 at 6:40 PM Kuninori Morimoto < kuninori.morimoto.gx@renesas.com> wrote:
Hi Ranjani
Thank you for your review
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. snd_soc_bind_card() is calling snd_soc_dapm_init() for both card and component. Let's call paired snd_soc_dapm_shutdown() at paired soc_cleanup_card_resources(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> ---
(snip)
You removed snd_soc_bind_card in one of the patches but then leaving
snd_soc_unbind_card() will be unbalanced isnt it?
Why not just have instantiate_card() and cleanup_card_resources()?
Do you mean [7/9] patch ? It merges snd_soc_instantiate_card() and snd_soc_bind_card(). Thus, snd_soc_bind_card() is still exist. Or am I misunderstanding ?
Oh yes, sorry I misread that. So why not remove cleanup_card_resources and move everything to snd_soc_unbind_card()?
Thanks, Ranjani
Thank you for your help !! Best regards
Kuninori Morimoto
Hi Ranjani
Thank you for your feedback
Do you mean [7/9] patch ? It merges snd_soc_instantiate_card() and snd_soc_bind_card(). Thus, snd_soc_bind_card() is still exist. Or am I misunderstanding ?
Oh yes, sorry I misread that. So why not remove cleanup_card_resources and move everything to snd_soc_unbind_card()?
Good question :)
Indeed snd_soc_bind_card() and snd_soc_unbind_card() are paired function. We want to merge cleanup_card_resources() and snd_soc_unbind_card(). But, can you check snd_soc_unbind_card() ? unbind() is caring - card->instantiated - snd_soc_flush_all_delayed_work(card); - unbind_card_list
Actually I tried to merge cleanup() and unbind() into one, but then, the code became not simple. So I gave up this time. But, we might can do it in the future if soc-core is more cleanuped/simpled.
Thank you for your help !! Best regards --- Kuninori Morimoto
On Tue, Nov 5, 2019 at 6:56 PM Kuninori Morimoto < kuninori.morimoto.gx@renesas.com> wrote:
Hi Ranjani
Thank you for your feedback
Do you mean [7/9] patch ? It merges snd_soc_instantiate_card() and snd_soc_bind_card(). Thus, snd_soc_bind_card() is still exist. Or am I misunderstanding ?
Oh yes, sorry I misread that. So why not remove cleanup_card_resources
and move everything to snd_soc_unbind_card()?
Good question :)
Indeed snd_soc_bind_card() and snd_soc_unbind_card() are paired function. We want to merge cleanup_card_resources() and snd_soc_unbind_card(). But, can you check snd_soc_unbind_card() ? unbind() is caring - card->instantiated - snd_soc_flush_all_delayed_work(card); - unbind_card_list
Actually I tried to merge cleanup() and unbind() into one, but then, the code became not simple. So I gave up this time. But, we might can do it in the future if soc-core is more cleanuped/simpled.
OK, makes sense. In that case, this series looks good to go.
Reviewed-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com
Thank you for your help !! Best regards
Kuninori Morimoto
participants (3)
-
Kuninori Morimoto
-
Mark Brown
-
Sridharan, Ranjani