* [PATCH v2] ASoC: soc-core: add snd_soc_dapm_add_routes_with_card()
@ 2025-01-08 3:06 Kuninori Morimoto
2025-01-08 8:44 ` Amadeusz Sławiński
0 siblings, 1 reply; 3+ messages in thread
From: Kuninori Morimoto @ 2025-01-08 3:06 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound
Some device want to ignore snd_soc_dapm_add_routes() error, thus
card->disable_route_checks flags had been added for such purpose. Because
of this, ASoC has duplicate code for it. Let's adds new
snd_soc_dapm_add_routes_with_card(), and share the error message handling.
We don't need to indicate error message on this function, because it will
be indicated from snd_soc_dapm_add_route().
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2
- rebase to latest asoc/for-6.14
include/sound/soc-dapm.h | 3 +++
sound/soc/soc-core.c | 33 ++++++---------------------------
sound/soc/soc-dapm.c | 15 +++++++++++++++
sound/soc/soc-topology.c | 14 +++-----------
4 files changed, 27 insertions(+), 38 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 12cd7b5a2202e..16f4a536cdf52 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -478,6 +478,9 @@ void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm,
struct snd_soc_card *card, struct snd_soc_component *component);
int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_route *route, int num);
+int snd_soc_dapm_add_routes_with_card(struct snd_soc_card *card,
+ struct snd_soc_dapm_context *dapm,
+ const struct snd_soc_dapm_route *routes, int num);
int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_route *route, int num);
int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 710c278e4f36b..01ce1c9366223 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1641,22 +1641,11 @@ static int soc_probe_component(struct snd_soc_card *card,
if (ret < 0)
goto err_probe;
- ret = snd_soc_dapm_add_routes(dapm,
+ ret = snd_soc_dapm_add_routes_with_card(card, dapm,
component->driver->dapm_routes,
component->driver->num_dapm_routes);
- if (ret < 0) {
- if (card->disable_route_checks) {
- ret = 0;
- dev_info(card->dev,
- "%s: disable_route_checks set, ignoring errors on add_routes\n",
- __func__);
- } else {
- dev_err(card->dev,
- "%s: snd_soc_dapm_add_routes failed: %d\n",
- __func__, ret);
- goto err_probe;
- }
- }
+ if (ret < 0)
+ goto err_probe;
/* see for_each_card_components */
list_add(&component->card_list, &card->component_dev_list);
@@ -2233,20 +2222,10 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
if (ret < 0)
goto probe_end;
- ret = snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
+ ret = snd_soc_dapm_add_routes_with_card(card, &card->dapm, card->dapm_routes,
card->num_dapm_routes);
- if (ret < 0) {
- if (card->disable_route_checks) {
- dev_info(card->dev,
- "%s: disable_route_checks set, ignoring errors on add_routes\n",
- __func__);
- } else {
- dev_err(card->dev,
- "%s: snd_soc_dapm_add_routes failed: %d\n",
- __func__, ret);
- goto probe_end;
- }
- }
+ if (ret < 0)
+ goto probe_end;
ret = snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
card->num_of_dapm_routes);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 99521c784a9b1..ea0c74f0df102 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3189,6 +3189,21 @@ int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
+int snd_soc_dapm_add_routes_with_card(struct snd_soc_card *card,
+ struct snd_soc_dapm_context *dapm,
+ const struct snd_soc_dapm_route *routes, int num)
+{
+ int ret = snd_soc_dapm_add_routes(dapm, routes, num);
+
+ if (ret < 0 && card->disable_route_checks) {
+ dev_info(card->dev, "disable_route_checks set, ignoring errors on add_routes\n");
+ ret = 0;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes_with_card);
+
/**
* snd_soc_dapm_del_routes - Remove routes between DAPM widgets
* @dapm: DAPM context
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index ae2d6802cce05..37e7e1147c241 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1100,17 +1100,9 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg,
break;
}
- ret = snd_soc_dapm_add_routes(dapm, route, 1);
- if (ret) {
- if (dapm->card->disable_route_checks) {
- ret = 0;
- dev_info(tplg->dev,
- "ASoC: disable_route_checks set, ignoring dapm_add_routes errors\n");
- } else {
- dev_err(tplg->dev, "ASoC: dapm_add_routes failed: %d\n", ret);
- break;
- }
- }
+ ret = snd_soc_dapm_add_routes_with_card(dapm->card, dapm, route, 1);
+ if (ret)
+ break;
}
return ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ASoC: soc-core: add snd_soc_dapm_add_routes_with_card()
2025-01-08 3:06 [PATCH v2] ASoC: soc-core: add snd_soc_dapm_add_routes_with_card() Kuninori Morimoto
@ 2025-01-08 8:44 ` Amadeusz Sławiński
2025-01-08 23:38 ` Kuninori Morimoto
0 siblings, 1 reply; 3+ messages in thread
From: Amadeusz Sławiński @ 2025-01-08 8:44 UTC (permalink / raw)
To: Kuninori Morimoto, Mark Brown; +Cc: linux-sound, Cezary Rojewski
On 1/8/2025 4:06 AM, Kuninori Morimoto wrote:
> Some device want to ignore snd_soc_dapm_add_routes() error, thus
> card->disable_route_checks flags had been added for such purpose. Because
> of this, ASoC has duplicate code for it. Let's adds new
> snd_soc_dapm_add_routes_with_card(), and share the error message handling.
>
> We don't need to indicate error message on this function, because it will
> be indicated from snd_soc_dapm_add_route().
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
card->disable_route_checks is a leftover from skylake driver which had
partial routes in some topologies, as skylake driver was removed,
perhaps we can remove the field altogether?
Quick grep shows that there is only one board left which sets it:
sound/soc/intel/boards/skl_hda_dsp_generic.c:
card->disable_route_checks = true;
and it only does it after checking that parent driver isn't SOF, and as
skylake driver was removed it is dead code (it was shared between SOF
and skylake drivers).
As such I would recommend removing whole thing altogether ;)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ASoC: soc-core: add snd_soc_dapm_add_routes_with_card()
2025-01-08 8:44 ` Amadeusz Sławiński
@ 2025-01-08 23:38 ` Kuninori Morimoto
0 siblings, 0 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2025-01-08 23:38 UTC (permalink / raw)
To: Amadeusz Sławiński; +Cc: Mark Brown, linux-sound, Cezary Rojewski
Hi Amadeusz
> > Some device want to ignore snd_soc_dapm_add_routes() error, thus
> > card->disable_route_checks flags had been added for such purpose. Because
> > of this, ASoC has duplicate code for it. Let's adds new
> > snd_soc_dapm_add_routes_with_card(), and share the error message handling.
> >
> > We don't need to indicate error message on this function, because it will
> > be indicated from snd_soc_dapm_add_route().
> >
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
>
> card->disable_route_checks is a leftover from skylake driver which had
> partial routes in some topologies, as skylake driver was removed,
> perhaps we can remove the field altogether?
>
> Quick grep shows that there is only one board left which sets it:
> sound/soc/intel/boards/skl_hda_dsp_generic.c:
> card->disable_route_checks = true;
> and it only does it after checking that parent driver isn't SOF, and as
> skylake driver was removed it is dead code (it was shared between SOF
> and skylake drivers).
>
> As such I would recommend removing whole thing altogether ;)
Nice to know.
OK, let's remove it and clean code.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-08 23:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 3:06 [PATCH v2] ASoC: soc-core: add snd_soc_dapm_add_routes_with_card() Kuninori Morimoto
2025-01-08 8:44 ` Amadeusz Sławiński
2025-01-08 23:38 ` Kuninori Morimoto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox