From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Andrei Simion <andrei.simion@microchip.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 2/4] ASoC: atmel: mchp-spdifrx: Use devm helpers for runtime PM
Date: Thu, 19 Nov 2026 17:34:11 +0700 [thread overview]
Message-ID: <20261119103413.31729-3-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20261119103413.31729-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Use devm_pm_runtime_enable() and a devm action to handle runtime PM
cleanup automatically.
This removes the manual runtime PM cleanup from the probe error
paths and the remove callback.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/mchp-spdifrx.c | 47 ++++++++++++++++++----------------
1 file changed, 25 insertions(+), 22 deletions(-)
diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
index 7d80f35576cd..25122f6ef3c9 100644
--- a/sound/soc/atmel/mchp-spdifrx.c
+++ b/sound/soc/atmel/mchp-spdifrx.c
@@ -1079,6 +1079,15 @@ static const struct dev_pm_ops mchp_spdifrx_pm_ops = {
NULL)
};
+/* Runtime suspend the device on cleanup if necessary */
+static void mchp_spdifrx_runtime_suspend_action(void *data)
+{
+ struct device *dev = data;
+
+ if (!pm_runtime_status_suspended(dev))
+ mchp_spdifrx_runtime_suspend(dev);
+}
+
static int mchp_spdifrx_probe(struct platform_device *pdev)
{
struct mchp_spdifrx_dev *dev;
@@ -1141,11 +1150,22 @@ static int mchp_spdifrx_probe(struct platform_device *pdev)
dev->regmap = regmap;
platform_set_drvdata(pdev, dev);
- pm_runtime_enable(dev->dev);
+ err = devm_add_action(dev->dev, mchp_spdifrx_runtime_suspend_action,
+ dev->dev);
+ if (err)
+ return err;
+
+ err = devm_pm_runtime_enable(dev->dev);
+ if (err)
+ return err;
if (!pm_runtime_enabled(dev->dev)) {
err = mchp_spdifrx_runtime_resume(dev->dev);
- if (err)
- goto pm_runtime_disable;
+ if (err) {
+ devm_remove_action(dev->dev,
+ mchp_spdifrx_runtime_suspend_action,
+ dev->dev);
+ return err;
+ }
}
dev->capture.addr = (dma_addr_t)mem->start + SPDIFRX_RHR;
@@ -1154,7 +1174,7 @@ static int mchp_spdifrx_probe(struct platform_device *pdev)
err = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
if (err) {
dev_err(&pdev->dev, "failed to register PCM: %d\n", err);
- goto pm_runtime_suspend;
+ return err;
}
err = devm_snd_soc_register_component(&pdev->dev,
@@ -1162,34 +1182,17 @@ static int mchp_spdifrx_probe(struct platform_device *pdev)
&mchp_spdifrx_dai, 1);
if (err) {
dev_err(&pdev->dev, "fail to register dai\n");
- goto pm_runtime_suspend;
+ return err;
}
regmap_read(regmap, SPDIFRX_VERSION, &vers);
dev_info(&pdev->dev, "hw version: %#lx\n", vers & SPDIFRX_VERSION_MASK);
return 0;
-
-pm_runtime_suspend:
- if (!pm_runtime_status_suspended(dev->dev))
- mchp_spdifrx_runtime_suspend(dev->dev);
-pm_runtime_disable:
- pm_runtime_disable(dev->dev);
- return err;
-}
-
-static void mchp_spdifrx_remove(struct platform_device *pdev)
-{
- struct mchp_spdifrx_dev *dev = platform_get_drvdata(pdev);
-
- pm_runtime_disable(dev->dev);
- if (!pm_runtime_status_suspended(dev->dev))
- mchp_spdifrx_runtime_suspend(dev->dev);
}
static struct platform_driver mchp_spdifrx_driver = {
.probe = mchp_spdifrx_probe,
- .remove = mchp_spdifrx_remove,
.driver = {
.name = "mchp_spdifrx",
.of_match_table = mchp_spdifrx_dt_ids,
--
2.43.0
next prev parent reply other threads:[~2026-11-19 10:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 10:34 [PATCH 0/4] ASoC: atmel: mchp-spdifrx: Improve driver cleanup and error handling phucduc.bui
2026-11-19 10:34 ` [PATCH 1/4] ASoC: atmel: mchp-spdifrx: Improve probe " phucduc.bui
2026-11-19 10:34 ` phucduc.bui [this message]
2026-11-19 10:34 ` [PATCH 3/4] ASoC: atmel: mchp-spdifrx: Move IRQ request after runtime PM setup phucduc.bui
2026-11-19 10:34 ` [PATCH 4/4] ASoC: atmel: mchp-spdifrx: Propagate runtime PM errors in ulock get phucduc.bui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119103413.31729-3-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrei.simion@microchip.com \
--cc=broonie@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.