* [PATCH 0/2] ASoC: tidyup card rebind functions
@ 2026-05-13 1:48 Kuninori Morimoto
2026-05-13 1:48 ` [PATCH 1/2] ASoC: soc-core: add soc_rebind_card() Kuninori Morimoto
2026-05-13 1:48 ` [PATCH 2/2] ASoC: soc-core: handle card->list in snd_soc_unbind_card() Kuninori Morimoto
0 siblings, 2 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2026-05-13 1:48 UTC (permalink / raw)
To: Mark Brown, Rojewski, Cezary; +Cc: linux-sound
Hi Mar, Cezary
Now, all user can use deferrable card binding.
Now soc-core.c file has handling Card/Component/DAI randomly, so I would
like to capsuling these into soc-card/dai/component.c files.
So, I would like to handle Card related things in xx_card_xx() function.
It is easy to move functions when capsuling.
This patch tidyup deferrable card binding. No functional change.
Kuninori Morimoto (2):
ASoC: soc-core: add soc_rebind_card()
ASoC: soc-core: handle card->list in snd_soc_unbind_card()
sound/soc/soc-core.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] ASoC: soc-core: add soc_rebind_card()
2026-05-13 1:48 [PATCH 0/2] ASoC: tidyup card rebind functions Kuninori Morimoto
@ 2026-05-13 1:48 ` Kuninori Morimoto
2026-05-13 21:01 ` Rojewski, Cezary
2026-05-13 1:48 ` [PATCH 2/2] ASoC: soc-core: handle card->list in snd_soc_unbind_card() Kuninori Morimoto
1 sibling, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2026-05-13 1:48 UTC (permalink / raw)
To: Mark Brown, Rojewski, Cezary; +Cc: linux-sound
snd_soc_add_component() try to rebind Card. Which can be done
as Card function. Let's add soc_rebind_card() for it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-core.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 691fd7fc5030d..ae8467d88978e 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2197,6 +2197,14 @@ static int call_soc_bind_card(struct snd_soc_card *card)
return snd_soc_bind_card(card);
}
+static void soc_rebind_card(void)
+{
+ struct snd_soc_card *card, *c;
+
+ list_for_each_entry_safe(card, c, &unbind_card_list, list)
+ call_soc_bind_card(card);
+}
+
/* probes a new socdev */
static int soc_probe(struct platform_device *pdev)
{
@@ -2708,7 +2716,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);
@@ -2736,8 +2743,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)
- call_soc_bind_card(card);
+ soc_rebind_card();
err_cleanup:
if (ret < 0)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ASoC: soc-core: handle card->list in snd_soc_unbind_card()
2026-05-13 1:48 [PATCH 0/2] ASoC: tidyup card rebind functions Kuninori Morimoto
2026-05-13 1:48 ` [PATCH 1/2] ASoC: soc-core: add soc_rebind_card() Kuninori Morimoto
@ 2026-05-13 1:48 ` Kuninori Morimoto
2026-05-13 20:46 ` Rojewski, Cezary
1 sibling, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2026-05-13 1:48 UTC (permalink / raw)
To: Mark Brown, Rojewski, Cezary; +Cc: linux-sound
snd_soc_bind_card() is handling card->list inside, but
snd_soc_unbind_card() is handling it in outside.
Let's handle it inside.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-core.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ae8467d88978e..8b2269ba67c3a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1990,12 +1990,18 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
}
}
-static void snd_soc_unbind_card(struct snd_soc_card *card)
+static void snd_soc_unbind_card(struct snd_soc_card *card, bool add_to_list)
{
if (snd_soc_card_is_instantiated(card)) {
card->instantiated = false;
soc_cleanup_card_resources(card);
+
+ if (add_to_list)
+ list_add(&card->list, &unbind_card_list);
}
+
+ if (!add_to_list)
+ list_del(&card->list);
}
static int snd_soc_bind_card(struct snd_soc_card *card)
@@ -2439,8 +2445,7 @@ void snd_soc_unregister_card(struct snd_soc_card *card)
{
guard(mutex)(&client_mutex);
- snd_soc_unbind_card(card);
- list_del(&card->list);
+ snd_soc_unbind_card(card, false);
dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
}
@@ -2667,12 +2672,8 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
snd_soc_unregister_dais(component);
- if (card) {
- instantiated = card->instantiated;
- snd_soc_unbind_card(card);
- if (instantiated)
- list_add(&card->list, &unbind_card_list);
- }
+ if (card)
+ snd_soc_unbind_card(card, true);
list_del(&component->list);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ASoC: soc-core: handle card->list in snd_soc_unbind_card()
2026-05-13 1:48 ` [PATCH 2/2] ASoC: soc-core: handle card->list in snd_soc_unbind_card() Kuninori Morimoto
@ 2026-05-13 20:46 ` Rojewski, Cezary
0 siblings, 0 replies; 5+ messages in thread
From: Rojewski, Cezary @ 2026-05-13 20:46 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: linux-sound, Mark Brown
On 5/13/2026 3:48 AM, Kuninori Morimoto wrote:
> snd_soc_bind_card() is handling card->list inside, but
> snd_soc_unbind_card() is handling it in outside.
> Let's handle it inside.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> sound/soc/soc-core.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index ae8467d88978e..8b2269ba67c3a 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1990,12 +1990,18 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card)
> }
> }
>
> -static void snd_soc_unbind_card(struct snd_soc_card *card)
> +static void snd_soc_unbind_card(struct snd_soc_card *card, bool add_to_list)
> {
> if (snd_soc_card_is_instantiated(card)) {
> card->instantiated = false;
> soc_cleanup_card_resources(card);
> +
> + if (add_to_list)
> + list_add(&card->list, &unbind_card_list);
I see benefit in this.
> }
> +
> + if (!add_to_list)
> + list_del(&card->list);
But not this.
Moving card-behavior code from component-related function to
card-related one seems intuitive. However, snd_soc_unregister_card() is
already card-lated function. I'd keep the list_del() there and avoid
the second if-statement.
> }
>
> static int snd_soc_bind_card(struct snd_soc_card *card)
> @@ -2439,8 +2445,7 @@ void snd_soc_unregister_card(struct snd_soc_card *card)
> {
> guard(mutex)(&client_mutex);
>
> - snd_soc_unbind_card(card);
> - list_del(&card->list);
> + snd_soc_unbind_card(card, false);
>
> dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
> }
> @@ -2667,12 +2672,8 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
>
> snd_soc_unregister_dais(component);
>
> - if (card) {
> - instantiated = card->instantiated;
> - snd_soc_unbind_card(card);
> - if (instantiated)
> - list_add(&card->list, &unbind_card_list);
> - }
> + if (card)
> + snd_soc_unbind_card(card, true);
>
> list_del(&component->list);
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ASoC: soc-core: add soc_rebind_card()
2026-05-13 1:48 ` [PATCH 1/2] ASoC: soc-core: add soc_rebind_card() Kuninori Morimoto
@ 2026-05-13 21:01 ` Rojewski, Cezary
0 siblings, 0 replies; 5+ messages in thread
From: Rojewski, Cezary @ 2026-05-13 21:01 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: linux-sound, Mark Brown
On 5/13/2026 3:48 AM, Kuninori Morimoto wrote:
> snd_soc_add_component() try to rebind Card. Which can be done
> as Card function. Let's add soc_rebind_card() for it.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> sound/soc/soc-core.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 691fd7fc5030d..ae8467d88978e 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2197,6 +2197,14 @@ static int call_soc_bind_card(struct snd_soc_card *card)
> return snd_soc_bind_card(card);
> }
>
> +static void soc_rebind_card(void)
> +{
> + struct snd_soc_card *card, *c;
> +
> + list_for_each_entry_safe(card, c, &unbind_card_list, list)
> + call_soc_bind_card(card);
> +}
> +
> /* probes a new socdev */
> static int soc_probe(struct platform_device *pdev)
> {
> @@ -2708,7 +2716,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);
> @@ -2736,8 +2743,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)
> - call_soc_bind_card(card);
> + soc_rebind_card();
The naming is off. Clearly, we're not dealing with a card - many cards
could be bound here.
As previous patches related to the subject removed the rebind_card()
function, I'm not sure we want it back. Perhaps a readable macro instead?
#define for_each_unbound_card(card, c)
list_for_each_entry_safe(card, c, &unbind_card_list, list)
>
> err_cleanup:
> if (ret < 0)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-13 21:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 1:48 [PATCH 0/2] ASoC: tidyup card rebind functions Kuninori Morimoto
2026-05-13 1:48 ` [PATCH 1/2] ASoC: soc-core: add soc_rebind_card() Kuninori Morimoto
2026-05-13 21:01 ` Rojewski, Cezary
2026-05-13 1:48 ` [PATCH 2/2] ASoC: soc-core: handle card->list in snd_soc_unbind_card() Kuninori Morimoto
2026-05-13 20:46 ` Rojewski, Cezary
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox