From dd79f1926436ebfebf57b540d21eae5d1773297a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:44:39 +0000 Subject: [PATCH 01/11] ASoC: simple-card: move simple_parse_of() Move simple_parse_of() position. No functional change. This is preparation for code cleanup. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/87h5mixj09.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/generic/simple-card.c | 76 ++++++++++++++++----------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index b4957e025211..456b7ebeb068 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -517,44 +517,6 @@ static int simple_populate_aux(struct simple_util_priv *priv) return simple_ret(priv, ret); } -static int simple_parse_of(struct simple_util_priv *priv, struct link_info *li) -{ - struct snd_soc_card *card = simple_priv_to_card(priv); - int ret; - - ret = simple_util_parse_widgets(card, PREFIX); - if (ret < 0) - goto end; - - ret = simple_util_parse_routing(card, PREFIX); - if (ret < 0) - goto end; - - ret = simple_util_parse_pin_switches(card, PREFIX); - if (ret < 0) - goto end; - - /* Single/Muti DAI link(s) & New style of DT node */ - memset(li, 0, sizeof(*li)); - ret = simple_for_each_link(priv, li, - simple_dai_link_of, - simple_dai_link_of_dpcm); - if (ret < 0) - goto end; - - ret = simple_util_parse_card_name(priv, PREFIX); - if (ret < 0) - goto end; - - ret = simple_populate_aux(priv); - if (ret < 0) - goto end; - - ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs"); -end: - return simple_ret(priv, ret); -} - static int simple_count_noml(struct simple_util_priv *priv, struct device_node *np, struct device_node *codec, @@ -704,6 +666,44 @@ static int simple_soc_probe(struct snd_soc_card *card) return simple_ret(priv, ret); } +static int simple_parse_of(struct simple_util_priv *priv, struct link_info *li) +{ + struct snd_soc_card *card = simple_priv_to_card(priv); + int ret; + + ret = simple_util_parse_widgets(card, PREFIX); + if (ret < 0) + goto end; + + ret = simple_util_parse_routing(card, PREFIX); + if (ret < 0) + goto end; + + ret = simple_util_parse_pin_switches(card, PREFIX); + if (ret < 0) + goto end; + + /* Single/Muti DAI link(s) & New style of DT node */ + memset(li, 0, sizeof(*li)); + ret = simple_for_each_link(priv, li, + simple_dai_link_of, + simple_dai_link_of_dpcm); + if (ret < 0) + goto end; + + ret = simple_util_parse_card_name(priv, PREFIX); + if (ret < 0) + goto end; + + ret = simple_populate_aux(priv); + if (ret < 0) + goto end; + + ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs"); +end: + return simple_ret(priv, ret); +} + static int simple_probe(struct platform_device *pdev) { struct simple_util_priv *priv; From 7f20b9b05b3abb619b6c951dfb7303525efc13c0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:44:48 +0000 Subject: [PATCH 02/11] ASoC: simple-card: merge extra method into simple_parse_of() Current simple_probe() calls many code before/after simple_parse_of(). This is because it had supported platform style probe, but is no longer exist. We can merge all into simple_parse_of(), same as Audio Graph Card/Cars2. No functional change. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/87fr22xizz.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/generic/simple-card.c | 82 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 456b7ebeb068..20e6edd1d7d3 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -666,10 +666,31 @@ static int simple_soc_probe(struct snd_soc_card *card) return simple_ret(priv, ret); } -static int simple_parse_of(struct simple_util_priv *priv, struct link_info *li) +static int simple_parse_of(struct simple_util_priv *priv) { struct snd_soc_card *card = simple_priv_to_card(priv); - int ret; + struct device *dev = card->dev; + int ret = -EINVAL; + + if (!dev) + goto end; + + ret = -ENOMEM; + struct link_info *li __free(kfree) = kzalloc_obj(*li); + if (!li) + goto end; + + ret = simple_get_dais_count(priv, li); + if (ret < 0) + goto end; + + ret = -EINVAL; + if (!li->link) + goto end; + + ret = simple_util_init_priv(priv, li); + if (ret < 0) + goto end; ret = simple_util_parse_widgets(card, PREFIX); if (ret < 0) @@ -689,17 +710,30 @@ static int simple_parse_of(struct simple_util_priv *priv, struct link_info *li) simple_dai_link_of, simple_dai_link_of_dpcm); if (ret < 0) - goto end; + goto err; ret = simple_util_parse_card_name(priv, PREFIX); if (ret < 0) - goto end; + goto err; ret = simple_populate_aux(priv); if (ret < 0) - goto end; + goto err; ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs"); + if (ret < 0) + goto err; + + snd_soc_card_set_drvdata(card, priv); + + simple_util_debug_info(priv); + + ret = devm_snd_soc_register_card(dev, card); +err: + if (ret < 0) { + simple_util_clean_reference(card); + return dev_err_probe(dev, ret, "parse error\n"); + } end: return simple_ret(priv, ret); } @@ -709,7 +743,6 @@ static int simple_probe(struct platform_device *pdev) struct simple_util_priv *priv; struct device *dev = &pdev->dev; struct snd_soc_card *card; - int ret; /* Allocate the private data and the DAI link array */ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -722,42 +755,7 @@ static int simple_probe(struct platform_device *pdev) card->probe = simple_soc_probe; card->driver_name = "simple-card"; - ret = -ENOMEM; - struct link_info *li __free(kfree) = kzalloc_obj(*li); - if (!li) - goto end; - - ret = simple_get_dais_count(priv, li); - if (ret < 0) - goto end; - - ret = -EINVAL; - if (!li->link) - goto end; - - ret = simple_util_init_priv(priv, li); - if (ret < 0) - goto end; - - ret = simple_parse_of(priv, li); - if (ret < 0) { - dev_err_probe(dev, ret, "parse error\n"); - goto err; - } - - snd_soc_card_set_drvdata(card, priv); - - simple_util_debug_info(priv); - - ret = devm_snd_soc_register_card(dev, card); - if (ret < 0) - goto err; - - return 0; -err: - simple_util_clean_reference(card); -end: - return dev_err_probe(dev, ret, "parse error\n"); + return simple_parse_of(priv); } static const struct of_device_id simple_of_match[] = { From aa7fe27fda3241d33cd3af5cdeef4094c162cabb Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:44:57 +0000 Subject: [PATCH 03/11] ASoC: audio-graph-card2: Tidyup audio_graph2_parse_of() around error audio_graph2_parse_of() have not been calling simple_util_clean_reference(). Call it. And it is already calling dev_err_probe() in error case, no need to call graph_ret() in success case. Tidyup it. Let's keep same style with simple-card/audio-graph-card. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/87echmxizq.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/generic/audio-graph-card2.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 0202ed0ee78e..c5ada1f83881 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -1303,11 +1303,11 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, struct graph2_custom_hooks *hooks) { struct snd_soc_card *card = simple_priv_to_card(priv); - int ret; + int ret = -ENOMEM; struct link_info *li __free(kfree) = kzalloc_obj(*li); if (!li) - return -ENOMEM; + goto end; card->probe = graph_util_card_probe; card->owner = THIS_MODULE; @@ -1316,33 +1316,33 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, if ((hooks) && (hooks)->hook_pre) { ret = (hooks)->hook_pre(priv); if (ret < 0) - goto err; + goto end; } ret = graph_for_each_link(priv, hooks, li, graph_count); if (!li->link) ret = -EINVAL; if (ret < 0) - goto err; + goto end; ret = simple_util_init_priv(priv, li); if (ret < 0) - goto err; + goto end; priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); if (IS_ERR(priv->pa_gpio)) { ret = PTR_ERR(priv->pa_gpio); dev_err(dev, "failed to get amplifier gpio: %d\n", ret); - goto err; + goto end; } ret = simple_util_parse_widgets(card, NULL); if (ret < 0) - goto err; + goto end; ret = simple_util_parse_routing(card, NULL); if (ret < 0) - goto err; + goto end; memset(li, 0, sizeof(*li)); ret = graph_for_each_link(priv, hooks, li, graph_link); @@ -1369,9 +1369,11 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, ret = devm_snd_soc_register_card(dev, card); err: - if (ret < 0) - dev_err_probe(dev, ret, "parse error\n"); - + if (ret < 0) { + simple_util_clean_reference(card); + return dev_err_probe(dev, ret, "parse error\n"); + } +end: return graph_ret(priv, ret); } EXPORT_SYMBOL_GPL(audio_graph2_parse_of); From 30bb98d530d0c04893d516cf65204d0086e08970 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:45:06 +0000 Subject: [PATCH 04/11] ASoC: audio-graph-card: Tidyup audio_graph_parse_of() around error It is already calling dev_err_probe() in error case, no need to call graph_ret() in success case. Tidyup it. Let's keep same style with simple-card/audio-graph-card2. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/87cxx6xizh.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/generic/audio-graph-card.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 18ce4ee06350..42e1b77fa65e 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -603,14 +603,13 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) simple_util_debug_info(priv); ret = devm_snd_soc_register_card(dev, card); - if (ret < 0) - goto err; - - return 0; err: - simple_util_clean_reference(card); + if (ret < 0) { + simple_util_clean_reference(card); + return dev_err_probe(dev, ret, "parse error\n"); + } end: - return dev_err_probe(dev, ret, "parse error\n"); + return graph_ret(priv, ret); } EXPORT_SYMBOL_GPL(audio_graph_parse_of); From 7ad9d917e251be70cfa9733f990cfa5f7c49f9b5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:45:14 +0000 Subject: [PATCH 05/11] ASoC: simple_card_utils: add simple_util_parse_property() We have simple_util_parse_{routing/widgets/pin_switches}(). These are doing almost same things, but has each own implementation. Les't adds new simple_util_parse_property() and share the code. To be more easy cleanup later, change the required parameter from "card" to "priv". Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/87bjcqxiza.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/simple_card_utils.h | 27 +++++++--- sound/soc/generic/audio-graph-card.c | 4 +- sound/soc/generic/audio-graph-card2.c | 4 +- sound/soc/generic/simple-card-utils.c | 72 ++++++++------------------- sound/soc/generic/simple-card.c | 6 +-- 5 files changed, 49 insertions(+), 64 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 915e6ae5f68d..dfa1b5fb7aa8 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -189,12 +189,27 @@ bool simple_util_is_convert_required(const struct simple_util_data *data); int simple_util_get_sample_fmt(struct simple_util_data *data); -int simple_util_parse_routing(struct snd_soc_card *card, - char *prefix); -int simple_util_parse_widgets(struct snd_soc_card *card, - char *prefix); -int simple_util_parse_pin_switches(struct snd_soc_card *card, - char *prefix); +int simple_util_parse_property(struct simple_util_priv *priv, + int (*func)(struct snd_soc_card *card, const char *propname), + char *prefix, char *property); +static inline int simple_util_parse_routing(struct simple_util_priv *priv, char *prefix) +{ + return simple_util_parse_property(priv, snd_soc_of_parse_audio_routing, + prefix, "routing"); +} + +static inline int simple_util_parse_widgets(struct simple_util_priv *priv, char *prefix) +{ + return simple_util_parse_property(priv, snd_soc_of_parse_audio_simple_widgets, + prefix, "widgets"); +} + +static inline int simple_util_parse_pin_switches(struct simple_util_priv *priv, char *prefix) +{ + return simple_util_parse_property(priv, snd_soc_of_parse_pin_switches, + prefix, "pin-switches"); +} + int simple_util_init_jack(struct snd_soc_card *card, struct simple_util_jack *sjack, diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 42e1b77fa65e..273b0c82ebea 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -579,11 +579,11 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) goto end; } - ret = simple_util_parse_widgets(card, NULL); + ret = simple_util_parse_widgets(priv, NULL); if (ret < 0) goto end; - ret = simple_util_parse_routing(card, NULL); + ret = simple_util_parse_routing(priv, NULL); if (ret < 0) goto end; diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index c5ada1f83881..b4ae9bb860a1 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -1336,11 +1336,11 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, goto end; } - ret = simple_util_parse_widgets(card, NULL); + ret = simple_util_parse_widgets(priv, NULL); if (ret < 0) goto end; - ret = simple_util_parse_routing(card, NULL); + ret = simple_util_parse_routing(priv, NULL); if (ret < 0) goto end; diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index e5cb602fd248..522dd1e3c96a 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -216,6 +216,27 @@ int simple_util_set_dailink_name(struct simple_util_priv *priv, } EXPORT_SYMBOL_GPL(simple_util_set_dailink_name); +int simple_util_parse_property(struct simple_util_priv *priv, + int (*func)(struct snd_soc_card *card, const char *propname), + char *prefix, char *property) +{ + struct snd_soc_card *card = simple_priv_to_card(priv); + struct device_node *node = card->dev->of_node; + char prop[128]; + + if (!prefix) + prefix = ""; + + snprintf(prop, sizeof(prop), "%s%s", prefix, property); + + /* no property is not error */ + if (!of_property_present(node, prop)) + return 0; + + return func(card, prop); +} +EXPORT_SYMBOL_GPL(simple_util_parse_property); + int simple_util_parse_card_name(struct simple_util_priv *priv, char *prefix) { @@ -747,57 +768,6 @@ void simple_util_clean_reference(struct snd_soc_card *card) } EXPORT_SYMBOL_GPL(simple_util_clean_reference); -int simple_util_parse_routing(struct snd_soc_card *card, - char *prefix) -{ - struct device_node *node = card->dev->of_node; - char prop[128]; - - if (!prefix) - prefix = ""; - - snprintf(prop, sizeof(prop), "%s%s", prefix, "routing"); - - if (!of_property_present(node, prop)) - return 0; - - return snd_soc_of_parse_audio_routing(card, prop); -} -EXPORT_SYMBOL_GPL(simple_util_parse_routing); - -int simple_util_parse_widgets(struct snd_soc_card *card, - char *prefix) -{ - struct device_node *node = card->dev->of_node; - char prop[128]; - - if (!prefix) - prefix = ""; - - snprintf(prop, sizeof(prop), "%s%s", prefix, "widgets"); - - if (of_property_present(node, prop)) - return snd_soc_of_parse_audio_simple_widgets(card, prop); - - /* no widgets is not error */ - return 0; -} -EXPORT_SYMBOL_GPL(simple_util_parse_widgets); - -int simple_util_parse_pin_switches(struct snd_soc_card *card, - char *prefix) -{ - char prop[128]; - - if (!prefix) - prefix = ""; - - snprintf(prop, sizeof(prop), "%s%s", prefix, "pin-switches"); - - return snd_soc_of_parse_pin_switches(card, prop); -} -EXPORT_SYMBOL_GPL(simple_util_parse_pin_switches); - int simple_util_init_jack(struct snd_soc_card *card, struct simple_util_jack *sjack, int is_hp, char *prefix, diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 20e6edd1d7d3..6e432733649f 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -692,15 +692,15 @@ static int simple_parse_of(struct simple_util_priv *priv) if (ret < 0) goto end; - ret = simple_util_parse_widgets(card, PREFIX); + ret = simple_util_parse_widgets(priv, PREFIX); if (ret < 0) goto end; - ret = simple_util_parse_routing(card, PREFIX); + ret = simple_util_parse_routing(priv, PREFIX); if (ret < 0) goto end; - ret = simple_util_parse_pin_switches(card, PREFIX); + ret = simple_util_parse_pin_switches(priv, PREFIX); if (ret < 0) goto end; From d0ab37b02826fc4b2b78cb3f47416cc2dbbd9e7e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:45:32 +0000 Subject: [PATCH 06/11] ASoC: simple_card_utils: add simple_util_parse_aux_devs() We are using snd_soc_of_parse_aux_devs() directly, but can use simple_util_parse_property(). use it. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/878q7uxiyr.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/simple_card_utils.h | 5 +++++ sound/soc/generic/audio-graph-card2.c | 2 +- sound/soc/generic/simple-card.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index dfa1b5fb7aa8..ff9747c6aa49 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -210,6 +210,11 @@ static inline int simple_util_parse_pin_switches(struct simple_util_priv *priv, prefix, "pin-switches"); } +static inline int simple_util_parse_aux_devs(struct simple_util_priv *priv, char *prefix) +{ + return simple_util_parse_property(priv, snd_soc_of_parse_aux_devs, + prefix, "aux-devs"); +} int simple_util_init_jack(struct snd_soc_card *card, struct simple_util_jack *sjack, diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index b4ae9bb860a1..4dee28276671 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -1363,7 +1363,7 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, simple_util_debug_info(priv); - ret = snd_soc_of_parse_aux_devs(card, "aux-devs"); + ret = simple_util_parse_aux_devs(priv, NULL); if (ret < 0) goto err; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 6e432733649f..4dd05e726213 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -720,7 +720,7 @@ static int simple_parse_of(struct simple_util_priv *priv) if (ret < 0) goto err; - ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs"); + ret = simple_util_parse_aux_devs(priv, PREFIX); if (ret < 0) goto err; From 27ecf4da5ad3845b773508917e71f5a07b149077 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:45:40 +0000 Subject: [PATCH 07/11] ASoC: simple-card: tidyup simple_util_parse_xxx() in simple_parse_of() simple_parse_of() calls simple_util_parse_xxx(), but are random. Let's gather them all in one place. Let's keep same style with audio-graph-card/audio-graph-card2. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/877bnexiyj.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/generic/simple-card.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 4dd05e726213..a67f4aad0188 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -704,6 +704,14 @@ static int simple_parse_of(struct simple_util_priv *priv) if (ret < 0) goto end; + ret = simple_util_parse_card_name(priv, PREFIX); + if (ret < 0) + goto err; + + ret = simple_util_parse_aux_devs(priv, PREFIX); + if (ret < 0) + goto err; + /* Single/Muti DAI link(s) & New style of DT node */ memset(li, 0, sizeof(*li)); ret = simple_for_each_link(priv, li, @@ -712,18 +720,10 @@ static int simple_parse_of(struct simple_util_priv *priv) if (ret < 0) goto err; - ret = simple_util_parse_card_name(priv, PREFIX); - if (ret < 0) - goto err; - ret = simple_populate_aux(priv); if (ret < 0) goto err; - ret = simple_util_parse_aux_devs(priv, PREFIX); - if (ret < 0) - goto err; - snd_soc_card_set_drvdata(card, priv); simple_util_debug_info(priv); From b8081307f5c9d662ed5afbf42e809273dd9af8be Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:45:48 +0000 Subject: [PATCH 08/11] ASoC: audio-graph-card: tidyup simple_util_parse_xxx() in audio_graph_parse_of() audio_graph_parse_of() calls simple_util_parse_xxx(), but are random. Let's gather them all in one place. Let's keep same style with simple-card/audio-graph-card2. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/875x2yxiyc.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/generic/audio-graph-card.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 273b0c82ebea..f5e36c777ac6 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -587,6 +587,10 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) if (ret < 0) goto end; + ret = simple_util_parse_card_name(priv, NULL); + if (ret < 0) + goto err; + memset(li, 0, sizeof(*li)); ret = graph_for_each_link(priv, li, graph_dai_link_of, @@ -594,10 +598,6 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) if (ret < 0) goto err; - ret = simple_util_parse_card_name(priv, NULL); - if (ret < 0) - goto err; - snd_soc_card_set_drvdata(card, priv); simple_util_debug_info(priv); From fa6222d5e1219468301370c8b316f9b729ee600b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:45:55 +0000 Subject: [PATCH 09/11] ASoC: audio-graph-card2: tidyup simple_util_parse_xxx() in audio_graph2_parse_of() audio_graph2_parse_of() calls simple_util_parse_xxx(), but are random. Let's gather them all in one place. Let's keep same style with simple-card/audio-graph-card. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/874iiixiy5.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/generic/audio-graph-card2.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 4dee28276671..9ef7373a6ca6 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -1344,12 +1344,16 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, if (ret < 0) goto end; - memset(li, 0, sizeof(*li)); - ret = graph_for_each_link(priv, hooks, li, graph_link); + ret = simple_util_parse_card_name(priv, NULL); if (ret < 0) goto err; - ret = simple_util_parse_card_name(priv, NULL); + ret = simple_util_parse_aux_devs(priv, NULL); + if (ret < 0) + goto err; + + memset(li, 0, sizeof(*li)); + ret = graph_for_each_link(priv, hooks, li, graph_link); if (ret < 0) goto err; @@ -1363,10 +1367,6 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, simple_util_debug_info(priv); - ret = simple_util_parse_aux_devs(priv, NULL); - if (ret < 0) - goto err; - ret = devm_snd_soc_register_card(dev, card); err: if (ret < 0) { From 279bfbb150aef95a3ee281cdd9ebefdddfb43a1e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:46:02 +0000 Subject: [PATCH 10/11] ASoC: simple-card-utils: tidyup simple_util_init_aux_jacks() Current code makes old style / new style conversion difficult. To make future conversions easier to understand, this patch clean up the code a little. but no functional change. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/8733y2xixy.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/simple_card_utils.h | 3 +-- sound/soc/generic/simple-card-utils.c | 4 ++-- sound/soc/generic/simple-card.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index ff9747c6aa49..5e2e91578bf5 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -219,8 +219,7 @@ static inline int simple_util_parse_aux_devs(struct simple_util_priv *priv, char int simple_util_init_jack(struct snd_soc_card *card, struct simple_util_jack *sjack, int is_hp, char *prefix, char *pin); -int simple_util_init_aux_jacks(struct simple_util_priv *priv, - char *prefix); +int simple_util_init_aux_jacks(struct snd_soc_card *card, char *prefix); int simple_util_init_priv(struct simple_util_priv *priv, struct link_info *li); void simple_util_remove(struct platform_device *pdev); diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 522dd1e3c96a..44632759b185 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -824,9 +824,9 @@ int simple_util_init_jack(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(simple_util_init_jack); -int simple_util_init_aux_jacks(struct simple_util_priv *priv, char *prefix) +int simple_util_init_aux_jacks(struct snd_soc_card *card, char *prefix) { - struct snd_soc_card *card = simple_priv_to_card(priv); + struct simple_util_priv *priv = snd_soc_card_get_drvdata(card); struct snd_soc_component *component; int found_jack_index = 0; int type = 0; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index a67f4aad0188..49289cd655ea 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -661,7 +661,7 @@ static int simple_soc_probe(struct snd_soc_card *card) if (ret < 0) goto end; - ret = simple_util_init_aux_jacks(priv, PREFIX); + ret = simple_util_init_aux_jacks(card, PREFIX); end: return simple_ret(priv, ret); } From 6f5c4f6ffa8bd87803145d03b1ad36d4fa50d562 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 2 Jul 2026 01:46:09 +0000 Subject: [PATCH 11/11] ASoC: simple-card-utils: tidyup simple_util_clean_reference() Current code makes old style / new style conversion difficult. To make future conversions easier to understand, this patch clean up the code a little. but no functional change. Signed-off-by: Kuninori Morimoto Link: https://patch.msgid.link/871pdmxixq.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/simple_card_utils.h | 2 +- sound/soc/generic/audio-graph-card.c | 2 +- sound/soc/generic/audio-graph-card2.c | 2 +- sound/soc/generic/simple-card-utils.c | 6 ++++-- sound/soc/generic/simple-card.c | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 5e2e91578bf5..bd8c3a033577 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -181,7 +181,7 @@ void simple_util_canonicalize_platform(struct snd_soc_dai_link_component *platfo void simple_util_canonicalize_cpu(struct snd_soc_dai_link_component *cpus, int is_single_links); -void simple_util_clean_reference(struct snd_soc_card *card); +void simple_util_clean_reference(struct simple_util_priv *priv); void simple_util_parse_convert(struct device_node *np, char *prefix, struct simple_util_data *data); diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index f5e36c777ac6..73ea562ce52b 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -605,7 +605,7 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) ret = devm_snd_soc_register_card(dev, card); err: if (ret < 0) { - simple_util_clean_reference(card); + simple_util_clean_reference(priv); return dev_err_probe(dev, ret, "parse error\n"); } end: diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 9ef7373a6ca6..e3e92025b317 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -1370,7 +1370,7 @@ int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, ret = devm_snd_soc_register_card(dev, card); err: if (ret < 0) { - simple_util_clean_reference(card); + simple_util_clean_reference(priv); return dev_err_probe(dev, ret, "parse error\n"); } end: diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 44632759b185..42019daa5e04 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -752,11 +752,12 @@ void simple_util_canonicalize_cpu(struct snd_soc_dai_link_component *cpus, } EXPORT_SYMBOL_GPL(simple_util_canonicalize_cpu); -void simple_util_clean_reference(struct snd_soc_card *card) +void simple_util_clean_reference(struct simple_util_priv *priv) { struct snd_soc_dai_link *dai_link; struct snd_soc_dai_link_component *cpu; struct snd_soc_dai_link_component *codec; + struct snd_soc_card *card = simple_priv_to_card(priv); int i, j; for_each_card_prelinks(card, i, dai_link) { @@ -996,8 +997,9 @@ EXPORT_SYMBOL_GPL(simple_util_init_priv); void simple_util_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); + struct simple_util_priv *priv = snd_soc_card_get_drvdata(card); - simple_util_clean_reference(card); + simple_util_clean_reference(priv); } EXPORT_SYMBOL_GPL(simple_util_remove); diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 49289cd655ea..abfbc9fd7c6d 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -731,7 +731,7 @@ static int simple_parse_of(struct simple_util_priv *priv) ret = devm_snd_soc_register_card(dev, card); err: if (ret < 0) { - simple_util_clean_reference(card); + simple_util_clean_reference(priv); return dev_err_probe(dev, ret, "parse error\n"); } end: