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>,
Codrin Ciubotariu <codrin.ciubotariu@microchip.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] ASoC: atmel-i2s: Use devm_clk_get_enabled() for pclk
Date: Wed, 11 Nov 2026 11:27:46 +0700 [thread overview]
Message-ID: <20261111042746.14714-1-phucduc.bui@gmail.com> (raw)
From: bui duc phuc <phucduc.bui@gmail.com>
The peripheral clock is only acquired and enabled once during
probe. Use devm_clk_get_enabled() to combine clock acquisition
and enabling into a single call.
This also removes the need for manual clock disable handling
on probe failures and in the remove callback, as the devm API
automatically handles clock cleanup.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/atmel-i2s.c | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/sound/soc/atmel/atmel-i2s.c b/sound/soc/atmel/atmel-i2s.c
index e1d8af056234..a3aeb8e607f6 100644
--- a/sound/soc/atmel/atmel-i2s.c
+++ b/sound/soc/atmel/atmel-i2s.c
@@ -660,8 +660,8 @@ static int atmel_i2s_probe(struct platform_device *pdev)
if (err)
return err;
- /* Get the peripheral clock. */
- dev->pclk = devm_clk_get(&pdev->dev, "pclk");
+ /* Get and enable the peripheral clock. */
+ dev->pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
if (IS_ERR(dev->pclk))
return dev_err_probe(&pdev->dev, PTR_ERR(dev->pclk),
"failed to get the peripheral clock\n");
@@ -682,11 +682,6 @@ static int atmel_i2s_probe(struct platform_device *pdev)
return err;
}
- /* Enable the peripheral clock. */
- err = clk_prepare_enable(dev->pclk);
- if (err)
- return err;
-
/* Get IP version. */
regmap_read(dev->regmap, ATMEL_I2SC_VERSION, &version);
dev_info(&pdev->dev, "hw version: %#x\n", version);
@@ -698,10 +693,8 @@ static int atmel_i2s_probe(struct platform_device *pdev)
err = devm_snd_soc_register_component(&pdev->dev,
&atmel_i2s_component,
&atmel_i2s_dai, 1);
- if (err) {
- clk_disable_unprepare(dev->pclk);
+ if (err)
return err;
- }
/* Prepare DMA config. */
dev->playback.addr = (dma_addr_t)mem->start + ATMEL_I2SC_THR;
@@ -712,28 +705,18 @@ static int atmel_i2s_probe(struct platform_device *pdev)
if (of_property_match_string(np, "dma-names", "rx-tx") == 0)
pcm_flags |= SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX;
err = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, pcm_flags);
- if (err) {
- clk_disable_unprepare(dev->pclk);
+ if (err)
return err;
- }
return 0;
}
-static void atmel_i2s_remove(struct platform_device *pdev)
-{
- struct atmel_i2s_dev *dev = platform_get_drvdata(pdev);
-
- clk_disable_unprepare(dev->pclk);
-}
-
static struct platform_driver atmel_i2s_driver = {
.driver = {
.name = "atmel_i2s",
.of_match_table = atmel_i2s_dt_ids,
},
.probe = atmel_i2s_probe,
- .remove = atmel_i2s_remove,
};
module_platform_driver(atmel_i2s_driver);
--
2.43.0
reply other threads:[~2026-11-11 4:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261111042746.14714-1-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=codrin.ciubotariu@microchip.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®