* [PATCH 1/2] ASoC: atmel-classd: Simplify probe error handling
2026-11-13 10:37 [PATCH 0/2] ASoC: atmel-classd: Improve clock and probe handling phucduc.bui
@ 2026-11-13 10:37 ` phucduc.bui
2026-11-13 10:37 ` [PATCH 2/2] ASoC: atmel-classd: Enable pclk during probe phucduc.bui
1 sibling, 0 replies; 3+ messages in thread
From: phucduc.bui @ 2026-11-13 10:37 UTC (permalink / raw)
To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
Alexandre Belloni
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Use dev_err_probe() for clock acquisition to suppress probe deferral
logs and remove the unnecessary cleanup label, as all resources are
managed by devm.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/atmel-classd.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c
index 6693bdcbb8f5..117c8e400184 100644
--- a/sound/soc/atmel/atmel-classd.c
+++ b/sound/soc/atmel/atmel-classd.c
@@ -547,18 +547,14 @@ static int atmel_classd_probe(struct platform_device *pdev)
return dd->irq;
dd->pclk = devm_clk_get(dev, "pclk");
- if (IS_ERR(dd->pclk)) {
- ret = PTR_ERR(dd->pclk);
- dev_err(dev, "failed to get peripheral clock: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(dd->pclk))
+ return dev_err_probe(dev, PTR_ERR(dd->pclk),
+ "failed to get peripheral clock\n");
dd->gclk = devm_clk_get(dev, "gclk");
- if (IS_ERR(dd->gclk)) {
- ret = PTR_ERR(dd->gclk);
- dev_err(dev, "failed to get GCK clock: %d\n", ret);
- return ret;
- }
+ if (IS_ERR(dd->gclk))
+ return dev_err_probe(dev, PTR_ERR(dd->gclk),
+ "failed to get GCK clock\n");
io_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(io_base))
@@ -593,29 +589,24 @@ static int atmel_classd_probe(struct platform_device *pdev)
/* register sound card */
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
- if (!card) {
- ret = -ENOMEM;
- goto unregister_codec;
- }
+ if (!card)
+ return -ENOMEM;
snd_soc_card_set_drvdata(card, dd);
ret = atmel_classd_asoc_card_init(dev, card);
if (ret) {
dev_err(dev, "failed to init sound card\n");
- goto unregister_codec;
+ return ret;
}
ret = devm_snd_soc_register_card(dev, card);
if (ret) {
dev_err(dev, "failed to register sound card: %d\n", ret);
- goto unregister_codec;
+ return ret;
}
return 0;
-
-unregister_codec:
- return ret;
}
static struct platform_driver atmel_classd_driver = {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] ASoC: atmel-classd: Enable pclk during probe
2026-11-13 10:37 [PATCH 0/2] ASoC: atmel-classd: Improve clock and probe handling phucduc.bui
2026-11-13 10:37 ` [PATCH 1/2] ASoC: atmel-classd: Simplify probe error handling phucduc.bui
@ 2026-11-13 10:37 ` phucduc.bui
1 sibling, 0 replies; 3+ messages in thread
From: phucduc.bui @ 2026-11-13 10:37 UTC (permalink / raw)
To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
Alexandre Belloni
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
The peripheral clock is enabled in the startup callback but never
disabled, causing its enable reference count to increase on each
startup and preventing the clock from being gated.
Use devm_clk_get_enabled() to enable pclk once during probe and
automatically disable it on device removal.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/atmel-classd.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c
index 117c8e400184..b6d815804e33 100644
--- a/sound/soc/atmel/atmel-classd.c
+++ b/sound/soc/atmel/atmel-classd.c
@@ -122,19 +122,10 @@ static int atmel_classd_cpu_dai_startup(struct snd_pcm_substream *substream,
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card);
- int err;
regmap_write(dd->regmap, CLASSD_THR, 0x0);
- err = clk_prepare_enable(dd->pclk);
- if (err)
- return err;
- err = clk_prepare_enable(dd->gclk);
- if (err) {
- clk_disable_unprepare(dd->pclk);
- return err;
- }
- return 0;
+ return clk_prepare_enable(dd->gclk);
}
/* platform */
@@ -546,10 +537,10 @@ static int atmel_classd_probe(struct platform_device *pdev)
if (dd->irq < 0)
return dd->irq;
- dd->pclk = devm_clk_get(dev, "pclk");
+ dd->pclk = devm_clk_get_enabled(dev, "pclk");
if (IS_ERR(dd->pclk))
return dev_err_probe(dev, PTR_ERR(dd->pclk),
- "failed to get peripheral clock\n");
+ "failed to get/enable peripheral clock\n");
dd->gclk = devm_clk_get(dev, "gclk");
if (IS_ERR(dd->gclk))
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread