Skip to content

Commit

Permalink
ASoC: soc-core.c: use devm_snd_soc_register_dai()
Browse files Browse the repository at this point in the history
It is still using snd_soc_{un}register_dai() manually.
Let's use devm_snd_soc_register_dai().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  • Loading branch information
morimoto committed Apr 25, 2023
1 parent 48018be commit 7ca5c2e
Showing 1 changed file with 9 additions and 31 deletions.
40 changes: 9 additions & 31 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2542,49 +2542,29 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
}
EXPORT_SYMBOL_GPL(snd_soc_register_dai);

/**
* snd_soc_unregister_dais - Unregister DAIs from the ASoC core
*
* @component: The component for which the DAIs should be unregistered
*/
static void snd_soc_unregister_dais(struct snd_soc_component *component)
{
struct snd_soc_dai *dai, *_dai;

for_each_component_dais_safe(component, dai, _dai)
snd_soc_unregister_dai(dai);
}

/**
* snd_soc_register_dais - Register a DAI with the ASoC core
*
* @component: The component the DAIs are registered for
* @dai_drv: DAI driver to use for the DAIs
* @count: Number of DAIs
*/
static int snd_soc_register_dais(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv,
size_t count)
static int devm_snd_soc_register_dais(struct snd_soc_component *component,
struct snd_soc_dai_driver *dai_drv,
size_t count)
{
struct snd_soc_dai *dai;
unsigned int i;
int ret;

for (i = 0; i < count; i++) {
dai = snd_soc_register_dai(component, dai_drv + i, count == 1 &&
component->driver->legacy_dai_naming);
if (dai == NULL) {
ret = -ENOMEM;
goto err;
}
dai = devm_snd_soc_register_dai(component->dev,
component, dai_drv + i, count == 1 &&
component->driver->legacy_dai_naming);
if (!dai)
return -ENOMEM;
}

return 0;

err:
snd_soc_unregister_dais(component);

return ret;
}

#define ENDIANNESS_MAP(name) \
Expand Down Expand Up @@ -2635,8 +2615,6 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)
{
struct snd_soc_card *card = component->card;

snd_soc_unregister_dais(component);

if (card)
snd_soc_unbind_card(card, false);

Expand Down Expand Up @@ -2687,7 +2665,7 @@ int snd_soc_add_component(struct snd_soc_component *component,
}
}

ret = snd_soc_register_dais(component, dai_drv, num_dai);
ret = devm_snd_soc_register_dais(component, dai_drv, num_dai);
if (ret < 0) {
dev_err(component->dev, "ASoC: Failed to register DAIs: %d\n",
ret);
Expand Down

0 comments on commit 7ca5c2e

Please sign in to comment.