From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Jaroslav Kysela <perex@perex.cz>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>,
Cezary Rojewski <cezary.rojewski@intel.com>,
linux-sound@vger.kernel.org
Subject: [RFC][PATCH v4 2/2] ASoC: core: use Complete rebind cards by default for all users
Date: Wed, 22 Apr 2026 03:04:31 +0000 [thread overview]
Message-ID: <87bjfbk85c.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87eck7k868.wl-kuninori.morimoto.gx@renesas.com>
commit a3375522bb5e2 ("ASoC: core: Complete support for card rebinding")
supports complete card rebinding, but it uses unbalanced pair functions
It added devm_snd_soc_bind_card() (= bind), but its inverse function is
snd_soc_unregister_card() (= unregister), and it adds new
devm_snd_soc_register_deferrable_card() (= register), but it doesn't have
inverse function (= merged with above inverse of bind function).
This feature is mainly used on Intel driver, but all driver can use it.
Let's use it on all drivers.
bin/unbind functions are soc-core.c local, so let's rename it.
It added new rebind function.
snd_soc_bind_card() -> soc_card_bind()
snd_soc_unbind_card() -> soc_card_unbind()
snd_soc_rebind_card() -> soc_card_rebind()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
include/sound/soc.h | 6 ++--
sound/soc/soc-card.c | 4 +--
sound/soc/soc-core.c | 67 ++++++++++--------------------------------
sound/soc/soc-devres.c | 7 -----
4 files changed, 22 insertions(+), 62 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 453548988d381..87bcb33cbde65 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -431,7 +431,10 @@ struct snd_soc_jack_pin;
int snd_soc_register_card(struct snd_soc_card *card);
void snd_soc_unregister_card(struct snd_soc_card *card);
int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
-int devm_snd_soc_register_deferrable_card(struct device *dev, struct snd_soc_card *card);
+
+/* REMOVE ME */
+#define devm_snd_soc_register_deferrable_card devm_snd_soc_register_card
+
#ifdef CONFIG_PM_SLEEP
int snd_soc_suspend(struct device *dev);
int snd_soc_resume(struct device *dev);
@@ -1087,7 +1090,6 @@ struct snd_soc_card {
unsigned int fully_routed:1;
unsigned int probed:1;
unsigned int component_chaining:1;
- struct device *devres_dev;
void *drvdata;
};
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
index 235427d690617..04d1c2ec11484 100644
--- a/sound/soc/soc-card.c
+++ b/sound/soc/soc-card.c
@@ -151,7 +151,7 @@ int snd_soc_card_probe(struct snd_soc_card *card)
* about "late_probe".
*
* see
- * snd_soc_bind_card()
+ * soc_card_bind()
* snd_soc_card_late_probe()
*/
card->probed = 1;
@@ -176,7 +176,7 @@ int snd_soc_card_late_probe(struct snd_soc_card *card)
* for all cases.
*
* see
- * snd_soc_bind_card()
+ * soc_card_bind()
* snd_soc_card_probe()
*/
card->probed = 1;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 13e933d2883e8..9b1ae88127d79 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2147,7 +2147,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
}
}
-static void snd_soc_unbind_card(struct snd_soc_card *card)
+static void soc_card_unbind(struct snd_soc_card *card)
{
if (snd_soc_card_is_instantiated(card)) {
card->instantiated = false;
@@ -2155,7 +2155,7 @@ static void snd_soc_unbind_card(struct snd_soc_card *card)
}
}
-static int snd_soc_bind_card(struct snd_soc_card *card)
+static int soc_card_bind(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_component *component;
@@ -2314,46 +2314,16 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
return ret;
}
-static void devm_card_bind_release(struct device *dev, void *res)
+static void soc_card_rebind(void)
{
- snd_soc_unregister_card(*(struct snd_soc_card **)res);
-}
+ struct snd_soc_card *card, *c;
-static int devm_snd_soc_bind_card(struct device *dev, struct snd_soc_card *card)
-{
- struct snd_soc_card **ptr;
- int ret;
+ list_for_each_entry_safe(card, c, &unbind_card_list, list) {
+ int ret = soc_card_bind(card);
- ptr = devres_alloc(devm_card_bind_release, sizeof(*ptr), GFP_KERNEL);
- if (!ptr)
- return -ENOMEM;
-
- ret = snd_soc_bind_card(card);
- if (ret == 0 || ret == -EPROBE_DEFER) {
- *ptr = card;
- devres_add(dev, ptr);
- } else {
- devres_free(ptr);
+ if (ret != -EPROBE_DEFER)
+ list_del_init(&card->list);
}
-
- return ret;
-}
-
-static int snd_soc_rebind_card(struct snd_soc_card *card)
-{
- int ret;
-
- if (card->devres_dev) {
- devres_destroy(card->devres_dev, devm_card_bind_release, NULL, NULL);
- ret = devm_snd_soc_bind_card(card->devres_dev, card);
- } else {
- ret = snd_soc_bind_card(card);
- }
-
- if (ret != -EPROBE_DEFER)
- list_del_init(&card->list);
-
- return ret;
}
/* probes a new socdev */
@@ -2578,14 +2548,10 @@ int snd_soc_register_card(struct snd_soc_card *card)
guard(mutex)(&client_mutex);
- if (card->devres_dev) {
- ret = devm_snd_soc_bind_card(card->devres_dev, card);
- if (ret == -EPROBE_DEFER) {
- list_add(&card->list, &unbind_card_list);
- ret = 0;
- }
- } else {
- ret = snd_soc_bind_card(card);
+ ret = soc_card_bind(card);
+ if (ret == -EPROBE_DEFER) {
+ list_add(&card->list, &unbind_card_list);
+ ret = 0;
}
return ret;
@@ -2602,7 +2568,7 @@ void snd_soc_unregister_card(struct snd_soc_card *card)
{
guard(mutex)(&client_mutex);
- snd_soc_unbind_card(card);
+ soc_card_unbind(card);
list_del(&card->list);
dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
@@ -2832,7 +2798,8 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
if (card) {
instantiated = card->instantiated;
- snd_soc_unbind_card(card);
+
+ soc_card_unbind(card);
if (instantiated)
list_add(&card->list, &unbind_card_list);
}
@@ -2879,7 +2846,6 @@ int snd_soc_add_component(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv,
int num_dai)
{
- struct snd_soc_card *card, *c;
int ret;
int i;
guard(mutex)(&client_mutex);
@@ -2907,8 +2873,7 @@ int snd_soc_add_component(struct snd_soc_component *component,
/* see for_each_component */
list_add(&component->list, &component_list);
- list_for_each_entry_safe(card, c, &unbind_card_list, list)
- snd_soc_rebind_card(card);
+ soc_card_rebind();
err_cleanup:
if (ret < 0)
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index d33f83ec24f27..c6364caabc0ec 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -83,13 +83,6 @@ int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
}
EXPORT_SYMBOL_GPL(devm_snd_soc_register_card);
-int devm_snd_soc_register_deferrable_card(struct device *dev, struct snd_soc_card *card)
-{
- card->devres_dev = dev;
- return snd_soc_register_card(card);
-}
-EXPORT_SYMBOL_GPL(devm_snd_soc_register_deferrable_card);
-
#ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM
static void devm_dmaengine_pcm_release(struct device *dev, void *res)
--
2.43.0
next prev parent reply other threads:[~2026-04-22 3:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 3:03 [RFC][PATCH v4 0/2] ASoC: core: use Complete rebind cards by default for all users Kuninori Morimoto
2026-04-22 3:04 ` [RFC][PATCH v4 1/2] ASoC: topology: make sure to call snd_soc_remove_pcm_runtime() Kuninori Morimoto
2026-04-22 3:04 ` Kuninori Morimoto [this message]
2026-04-26 14:53 ` [RFC][PATCH v4 0/2] ASoC: core: use Complete rebind cards by default for all users Cezary Rojewski
2026-04-26 23:18 ` Kuninori Morimoto
2026-04-28 16:22 ` Cezary Rojewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bjfbk85c.wl-kuninori.morimoto.gx@renesas.com \
--to=kuninori.morimoto.gx@renesas.com \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox