OSDN Git Service

ASoC: soc-core: merge soc_free_pcm_runtime() and soc_rtd_free()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 12 Sep 2019 04:41:01 +0000 (13:41 +0900)
committerMark Brown <broonie@kernel.org>
Tue, 1 Oct 2019 11:12:53 +0000 (12:12 +0100)
commitb7c5bc45ee94a03a0dc45a862180e17db8ea8e9d
tree00a268a8e4c669161f9111549fbc4123c8ce89e7
parent6e864344873f19120f742c19d15a8c53e7247c6a
ASoC: soc-core: merge soc_free_pcm_runtime() and soc_rtd_free()

"rtd"      is handled by soc_xxx_pcm_runtime(), and
"rtd->dev" is handled by soc_rtd_xxx().

There is no reason to separate these, and it makes code complex.
We can free these in the same time.

Here soc_rtd_free() (A) which frees rtd->dev is called from
soc_remove_link_dais() many times (1).
Then, it is using dev_registered flags to avoid multi kfree() (2).
This is no longer needed if we can merge these functions.

static void soc_remove_link_dais(...)
{
...
(1) for_each_comp_order(order) {
(1) for_each_card_rtds(card, rtd) {

(A) soc_rtd_free(rtd);
...
}
}
}

(A) static void soc_rtd_free(...)
{
(2) if (rtd->dev_registered) {
/* we don't need to call kfree() for rtd->dev */
device_unregister(rtd->dev);
(2) rtd->dev_registered = 0;
}
}

This patch merges soc_rtd_free() into soc_free_pcm_runtime().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878squf7oi.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/soc-core.c