--- Begin Message ---
- To: lgirdwood@xxxxxxxxx
- Subject: [PATCH 3/5] ASoC: mediatek: mt8195-afe-pcm: Simplify runtime PM during probe
- From: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
- Date: Wed, 3 May 2023 13:34:11 +0200
- Cc: broonie@xxxxxxxxxx, tiwai@xxxxxxxx, matthias.bgg@xxxxxxxxx, angelogioacchino.delregno@xxxxxxxxxxxxx, pierre-louis.bossart@xxxxxxxxxxxxxxx, peter.ujfalusi@xxxxxxxxxxxxxxx, yung-chuan.liao@xxxxxxxxxxxxxxx, ranjani.sridharan@xxxxxxxxxxxxxxx, kai.vehmanen@xxxxxxxxxxxxxxx, daniel.baluta@xxxxxxx, nicolas.ferre@xxxxxxxxxxxxx, u.kleine-koenig@xxxxxxxxxxxxxx, chunxu.li@xxxxxxxxxxxx, tinghan.shen@xxxxxxxxxxxx, error27@xxxxxxxxx, ribalda@xxxxxxxxxxxx, yc.hung@xxxxxxxxxxxx, Allen-KH.Cheng@xxxxxxxxxxxx, alsa-devel@xxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-mediatek@xxxxxxxxxxxxxxxxxxx, sound-open-firmware@xxxxxxxxxxxxxxxx, kernel@xxxxxxxxxxxxx
- In-reply-to: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com>
- References: <20230503113413.149235-1-angelogioacchino.delregno@collabora.com>
Use devm_pm_runtime_enable() and pm_runtime_resume_and_get() to
to simplify the probe function.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
---
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
index 9e45efeada55..a54c16e0aa05 100644
--- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
+++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
@@ -3179,16 +3179,16 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
mt8195_afe_parse_of(afe, pdev->dev.of_node);
- pm_runtime_enable(dev);
- if (!pm_runtime_enabled(dev)) {
- ret = mt8195_afe_runtime_resume(dev);
- if (ret)
- return ret;
- }
-
/* enable clock for regcache get default value from hw */
afe_priv->pm_runtime_bypass_reg_ctl = true;
- pm_runtime_get_sync(dev);
+
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to resume device\n");
afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr,
&mt8195_afe_regmap_config);
@@ -3238,7 +3238,10 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
mt8195_afe_init_registers(afe);
- pm_runtime_put_sync(dev);
+ ret = pm_runtime_put_sync(dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to suspend device\n");
+
afe_priv->pm_runtime_bypass_reg_ctl = false;
regcache_cache_only(afe->regmap, true);
@@ -3248,7 +3251,6 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
err_pm_put:
pm_runtime_put_sync(dev);
- pm_runtime_disable(dev);
return ret;
}
--
2.40.1
--- End Message ---