Commit 353e16bf authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-core: remove snd_soc_rtdcom_del_all()

If we can use devm_kzalloc(rtd->dev, xxx) for rtdcom,
we don't need to call snd_soc_rtdcom_del_all() for kfree().
This patch uses devm_kzalloc(rtd->dev, xxx) for rtdcom,
and remove snd_soc_rtdcom_del_all().
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875zlyf7ln.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d918a376
......@@ -288,28 +288,29 @@ static int snd_soc_rtdcom_add(struct snd_soc_pcm_runtime *rtd,
return 0;
}
rtdcom = kmalloc(sizeof(*rtdcom), GFP_KERNEL);
/*
* created rtdcom here will be freed when rtd->dev was freed.
* see
* soc_free_pcm_runtime() :: device_unregister(rtd->dev)
*/
rtdcom = devm_kzalloc(rtd->dev, sizeof(*rtdcom), GFP_KERNEL);
if (!rtdcom)
return -ENOMEM;
rtdcom->component = component;
INIT_LIST_HEAD(&rtdcom->list);
/*
* When rtd was freed, created rtdcom here will be
* also freed.
* And we don't need to call list_del(&rtdcom->list)
* when freed, because rtd is also freed.
*/
list_add_tail(&rtdcom->list, &rtd->component_list);
return 0;
}
static void snd_soc_rtdcom_del_all(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_rtdcom_list *rtdcom1, *rtdcom2;
for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2)
kfree(rtdcom1);
INIT_LIST_HEAD(&rtd->component_list);
}
struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
const char *driver_name)
{
......@@ -370,7 +371,6 @@ static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd)
return;
kfree(rtd->codec_dais);
snd_soc_rtdcom_del_all(rtd);
list_del(&rtd->list);
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment