Skip to content

Commit daa480b

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-core: tidyup for snd_soc_dapm_add_routes()
snd_soc_dapm_add_routes() registers routes by using for(... i < num; ...). If routes was NULL, num should be zero. Thus, we don't need to check about route pointer. This patch also cares missing return value. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87d0hhahon.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e6d7020 commit daa480b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

sound/soc/soc-core.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,10 +1310,11 @@ static int soc_probe_component(struct snd_soc_card *card,
13101310
if (ret < 0)
13111311
goto err_probe;
13121312

1313-
if (component->driver->dapm_routes)
1314-
snd_soc_dapm_add_routes(dapm,
1315-
component->driver->dapm_routes,
1316-
component->driver->num_dapm_routes);
1313+
ret = snd_soc_dapm_add_routes(dapm,
1314+
component->driver->dapm_routes,
1315+
component->driver->num_dapm_routes);
1316+
if (ret < 0)
1317+
goto err_probe;
13171318

13181319
list_add(&dapm->list, &card->dapm_list);
13191320
/* see for_each_card_components */
@@ -2061,13 +2062,15 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
20612062
snd_soc_add_card_controls(card, card->controls,
20622063
card->num_controls);
20632064

2064-
if (card->dapm_routes)
2065-
snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
2066-
card->num_dapm_routes);
2065+
ret = snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
2066+
card->num_dapm_routes);
2067+
if (ret < 0)
2068+
goto probe_end;
20672069

2068-
if (card->of_dapm_routes)
2069-
snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
2070-
card->num_of_dapm_routes);
2070+
ret = snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
2071+
card->num_of_dapm_routes);
2072+
if (ret < 0)
2073+
goto probe_end;
20712074

20722075
/* try to set some sane longname if DMI is available */
20732076
snd_soc_set_dmi_name(card, NULL);

0 commit comments

Comments
 (0)