[RFC][PATCH] ASoC: mediatek: mt8365-mt6357: tidyup mach_priv
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Thu Jun 25 22:37:45 PDT 2026
It sets soc_card_data (1) in Card private data at (A), but the function (z)
after that gets it as priv (2) at (B). These are different data (*).
(z) static int mt8365_mt6357_gpio_probe(...)
{
(B) struct mt8365_mt6357_priv *priv = snd_soc_card_get_drvdata(card);
... ^^^^(2) ^^^^^^^^^^^
}
static int mt8365_mt6357_dev_probe(*soc_card_data, ...)
{ ^^^^^^^^^^^^^(1)
...
struct mt8365_mt6357_priv *mach_priv;
... ^^^^^^^^^(2)
(*) soc_card_data->mach_priv = mach_priv;
^^^^^^^^^^^^^(1) ^^^^^^^^^(2)
(A) snd_soc_card_set_drvdata(card, soc_card_data);
^^^^^^^^^^^ ^^^^^^^^^^^^^(1)
(z) mt8365_mt6357_gpio_probe(card);
...
}
Depending on the defined order in the struct (s), they may be the same
pointer, but mach_priv (2) is not top of soc_card_data (1), thus the
function (z) is getting wrong pointer. Fix it.
(1)
(s) struct mtk_soc_card_data {
const struct mtk_sof_priv *sof_priv;
...
void *mach_priv;
}; (2)
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
Hi
I think this is bug, but not 100% sure. So it is using [RFC]
sound/soc/mediatek/mt8365/mt8365-mt6357.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/sound/soc/mediatek/mt8365/mt8365-mt6357.c b/sound/soc/mediatek/mt8365/mt8365-mt6357.c
index 10f9ef73c130c..38bd86b67ecc4 100644
--- a/sound/soc/mediatek/mt8365/mt8365-mt6357.c
+++ b/sound/soc/mediatek/mt8365/mt8365-mt6357.c
@@ -71,7 +71,8 @@ static const struct snd_soc_dapm_route mt8365_mt6357_routes[] = {
static int mt8365_mt6357_int_adda_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct mt8365_mt6357_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+ struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card);
+ struct mt8365_mt6357_priv *priv = soc_card_data->mach_priv;
int ret = 0;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -102,7 +103,8 @@ static int mt8365_mt6357_int_adda_startup(struct snd_pcm_substream *substream)
static void mt8365_mt6357_int_adda_shutdown(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct mt8365_mt6357_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+ struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card);
+ struct mt8365_mt6357_priv *priv = soc_card_data->mach_priv;
int ret = 0;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -246,7 +248,8 @@ static struct snd_soc_dai_link mt8365_mt6357_dais[] = {
static int mt8365_mt6357_gpio_probe(struct snd_soc_card *card)
{
- struct mt8365_mt6357_priv *priv = snd_soc_card_get_drvdata(card);
+ struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);
+ struct mt8365_mt6357_priv *priv = soc_card_data->mach_priv;
struct device *dev = card->dev;
int ret, i;
--
2.53.0
More information about the linux-arm-kernel
mailing list