[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240111105247.117766-3-angelogioacchino.delregno@collabora.com>
Date: Thu, 11 Jan 2024 11:52:42 +0100
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
To: lgirdwood@...il.com
Cc: broonie@...nel.org,
perex@...ex.cz,
tiwai@...e.com,
matthias.bgg@...il.com,
angelogioacchino.delregno@...labora.com,
ribalda@...omium.org,
nicolas.ferre@...rochip.com,
u.kleine-koenig@...gutronix.de,
kuninori.morimoto.gx@...esas.com,
nfraprado@...labora.com,
alsa-devel@...a-project.org,
trevor.wu@...iatek.com,
linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: [PATCH 2/7] ASoC: mediatek: mt8173-afe-pcm: Use devm_snd_soc_register_component()
Function devm_snd_soc_register_component() allocates a new struct
snd_soc_component, adds components and initializes them; since this
is also devm, it automatically unregisters components and frees
memory upon destruction.
That's exactly what we're doing in the probe function of this driver:
switch to that function instead, allowing to remove the last goto and
to discard the .remove_new() callback for this driver.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
---
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 58 +++-------------------
1 file changed, 8 insertions(+), 50 deletions(-)
diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
index ea611730de9c..b887e10635fe 100644
--- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
+++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
@@ -1129,72 +1129,31 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev)
afe->runtime_resume = mt8173_afe_runtime_resume;
afe->runtime_suspend = mt8173_afe_runtime_suspend;
- ret = devm_snd_soc_register_component(&pdev->dev,
- &mtk_afe_pcm_platform,
- NULL, 0);
+ ret = devm_snd_soc_register_component(&pdev->dev, &mtk_afe_pcm_platform, NULL, 0);
if (ret)
return ret;
- comp_pcm = devm_kzalloc(&pdev->dev, sizeof(*comp_pcm), GFP_KERNEL);
- if (!comp_pcm)
- return -ENOMEM;
-
- ret = snd_soc_component_initialize(comp_pcm,
- &mt8173_afe_pcm_dai_component,
- &pdev->dev);
+ ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_pcm_dai_component,
+ mt8173_afe_pcm_dais,
+ ARRAY_SIZE(mt8173_afe_pcm_dais));
if (ret)
return ret;
-#ifdef CONFIG_DEBUG_FS
- comp_pcm->debugfs_prefix = "pcm";
-#endif
-
- ret = snd_soc_add_component(comp_pcm,
- mt8173_afe_pcm_dais,
- ARRAY_SIZE(mt8173_afe_pcm_dais));
+ ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_hdmi_dai_component,
+ mt8173_afe_hdmi_dais,
+ ARRAY_SIZE(mt8173_afe_hdmi_dais));
if (ret)
return ret;
- comp_hdmi = devm_kzalloc(&pdev->dev, sizeof(*comp_hdmi), GFP_KERNEL);
- if (!comp_hdmi) {
- ret = -ENOMEM;
- goto err_cleanup_components;
- }
-
- ret = snd_soc_component_initialize(comp_hdmi,
- &mt8173_afe_hdmi_dai_component,
- &pdev->dev);
- if (ret)
- goto err_cleanup_components;
-
-#ifdef CONFIG_DEBUG_FS
- comp_hdmi->debugfs_prefix = "hdmi";
-#endif
-
- ret = snd_soc_add_component(comp_hdmi,
- mt8173_afe_hdmi_dais,
- ARRAY_SIZE(mt8173_afe_hdmi_dais));
- if (ret)
- goto err_cleanup_components;
-
ret = devm_request_irq(afe->dev, irq_id, mt8173_afe_irq_handler,
0, "Afe_ISR_Handle", (void *)afe);
if (ret) {
dev_err(afe->dev, "could not request_irq\n");
- goto err_cleanup_components;
+ return ret;
}
dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n");
return 0;
-
-err_cleanup_components:
- snd_soc_unregister_component(&pdev->dev);
- return ret;
-}
-
-static void mt8173_afe_pcm_dev_remove(struct platform_device *pdev)
-{
- snd_soc_unregister_component(&pdev->dev);
}
static const struct of_device_id mt8173_afe_pcm_dt_match[] = {
@@ -1215,7 +1174,6 @@ static struct platform_driver mt8173_afe_pcm_driver = {
.pm = &mt8173_afe_pm_ops,
},
.probe = mt8173_afe_pcm_dev_probe,
- .remove_new = mt8173_afe_pcm_dev_remove,
};
module_platform_driver(mt8173_afe_pcm_driver);
--
2.43.0
Powered by blists - more mailing lists