Skip to content

Commit bb8d8ba

Browse files
wensbroonie
authored andcommitted
ASoC: mediatek: mt8183-afe-pcm: use local dev pointer in driver callbacks
The probe and remove functions in the mt8183-afe-pcm driver repeatedly uses `&pdev->dev` for |struct device *|, but then assigns this value to `afe->dev` and uses that in other places in the same function. Store `&pdev->dev` in a local pointer and use that exclusively to avoid the numerous dereferences and to make the code more consistent. Lines are reflowed where it makes sense. Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Link: https://patch.msgid.link/20250612074901.4023253-10-wenst@chromium.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b2c090c commit bb8d8ba

1 file changed

Lines changed: 17 additions & 20 deletions

File tree

sound/soc/mediatek/mt8183/mt8183-afe-pcm.c

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -770,27 +770,25 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
770770
{
771771
struct mtk_base_afe *afe;
772772
struct mt8183_afe_private *afe_priv;
773-
struct device *dev;
773+
struct device *dev = &pdev->dev;
774774
struct reset_control *rstc;
775775
int i, irq_id, ret;
776776

777-
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
777+
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(34));
778778
if (ret)
779779
return ret;
780780

781-
afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
781+
afe = devm_kzalloc(dev, sizeof(*afe), GFP_KERNEL);
782782
if (!afe)
783783
return -ENOMEM;
784784
platform_set_drvdata(pdev, afe);
785785

786-
afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv),
787-
GFP_KERNEL);
786+
afe->platform_priv = devm_kzalloc(dev, sizeof(*afe_priv), GFP_KERNEL);
788787
if (!afe->platform_priv)
789788
return -ENOMEM;
790789

791790
afe_priv = afe->platform_priv;
792-
afe->dev = &pdev->dev;
793-
dev = afe->dev;
791+
afe->dev = dev;
794792

795793
ret = of_reserved_mem_device_init(dev);
796794
if (ret) {
@@ -835,15 +833,15 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
835833

836834
/* enable clock for regcache get default value from hw */
837835
afe_priv->pm_runtime_bypass_reg_ctl = true;
838-
pm_runtime_get_sync(&pdev->dev);
836+
pm_runtime_get_sync(dev);
839837

840838
ret = regmap_reinit_cache(afe->regmap, &mt8183_afe_regmap_config);
841839
if (ret) {
842840
dev_err(dev, "regmap_reinit_cache fail, ret %d\n", ret);
843841
goto err_pm_disable;
844842
}
845843

846-
pm_runtime_put_sync(&pdev->dev);
844+
pm_runtime_put_sync(dev);
847845
afe_priv->pm_runtime_bypass_reg_ctl = false;
848846

849847
regcache_cache_only(afe->regmap, true);
@@ -901,7 +899,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
901899
for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) {
902900
ret = dai_register_cbs[i](afe);
903901
if (ret) {
904-
dev_warn(afe->dev, "dai register i %d fail, ret %d\n",
902+
dev_warn(dev, "dai register i %d fail, ret %d\n",
905903
i, ret);
906904
goto err_pm_disable;
907905
}
@@ -910,8 +908,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
910908
/* init dai_driver and component_driver */
911909
ret = mtk_afe_combine_sub_dai(afe);
912910
if (ret) {
913-
dev_warn(afe->dev, "mtk_afe_combine_sub_dai fail, ret %d\n",
914-
ret);
911+
dev_warn(dev, "mtk_afe_combine_sub_dai fail, ret %d\n", ret);
915912
goto err_pm_disable;
916913
}
917914

@@ -923,16 +920,14 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
923920
afe->runtime_suspend = mt8183_afe_runtime_suspend;
924921

925922
/* register component */
926-
ret = devm_snd_soc_register_component(&pdev->dev,
927-
&mtk_afe_pcm_platform,
923+
ret = devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform,
928924
NULL, 0);
929925
if (ret) {
930926
dev_warn(dev, "err_platform\n");
931927
goto err_pm_disable;
932928
}
933929

934-
ret = devm_snd_soc_register_component(afe->dev,
935-
&mt8183_afe_pcm_dai_component,
930+
ret = devm_snd_soc_register_component(dev, &mt8183_afe_pcm_dai_component,
936931
afe->dai_drivers,
937932
afe->num_dai_drivers);
938933
if (ret) {
@@ -943,15 +938,17 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
943938
return ret;
944939

945940
err_pm_disable:
946-
pm_runtime_disable(&pdev->dev);
941+
pm_runtime_disable(dev);
947942
return ret;
948943
}
949944

950945
static void mt8183_afe_pcm_dev_remove(struct platform_device *pdev)
951946
{
952-
pm_runtime_disable(&pdev->dev);
953-
if (!pm_runtime_status_suspended(&pdev->dev))
954-
mt8183_afe_runtime_suspend(&pdev->dev);
947+
struct device *dev = &pdev->dev;
948+
949+
pm_runtime_disable(dev);
950+
if (!pm_runtime_status_suspended(dev))
951+
mt8183_afe_runtime_suspend(dev);
955952
}
956953

957954
static const struct of_device_id mt8183_afe_pcm_dt_match[] = {

0 commit comments

Comments
 (0)