* [PATCH 0/5] ASoC: atmel-i2s: fix clock error handling
@ 2026-10-02 4:38 phucduc.bui
2026-10-02 4:38 ` [PATCH 1/5] ASoC: atmel-i2s: fix MCK generator " phucduc.bui
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-02 4:38 UTC (permalink / raw)
To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
Alexandre Belloni
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Codrin Ciubotariu,
Cyrille Pitchen, linux-sound, linux-arm-kernel, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Hi all,
This series fixes clock error handling in the Atmel I2S driver by
propagating errors, using optional clock APIs, and simplifying probe
error reporting.
Found by manual code inspection.
Compile-tested only.
Best regards,
Phuc
bui duc phuc (5):
ASoC: atmel-i2s: fix MCK generator error handling
ASoC: atmel-i2s: use optional API for muxclk
ASoC: atmel-i2s: use optional API for gclk
ASoC: atmel-i2s: use dev_err_probe() for pclk errors
ASoC: atmel-i2s: remove redundant error message
sound/soc/atmel/atmel-i2s.c | 54 +++++++++++++++++--------------------
1 file changed, 25 insertions(+), 29 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] ASoC: atmel-i2s: fix MCK generator error handling
2026-10-02 4:38 [PATCH 0/5] ASoC: atmel-i2s: fix clock error handling phucduc.bui
@ 2026-10-02 4:38 ` phucduc.bui
2026-10-02 4:38 ` [PATCH 2/5] ASoC: atmel-i2s: use optional API for muxclk phucduc.bui
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-02 4:38 UTC (permalink / raw)
To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
Alexandre Belloni
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Codrin Ciubotariu,
Cyrille Pitchen, linux-sound, linux-arm-kernel, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Disable the gclk and reset the MCK configuration when an error occurs
while enabling the MCK generator.
This prevents the gclk from remaining enabled after a failed clock
configuration.
Fixes: 73ad0df57290 ("ASoC: atmel-i2s: Remove unnecessary audio PLL clock (aclk)")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/atmel-i2s.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/sound/soc/atmel/atmel-i2s.c b/sound/soc/atmel/atmel-i2s.c
index d9ad262ec44d..f28808d980ce 100644
--- a/sound/soc/atmel/atmel-i2s.c
+++ b/sound/soc/atmel/atmel-i2s.c
@@ -466,11 +466,21 @@ static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev,
mr |= ATMEL_I2SC_MR_IMCKMODE_I2SMCK;
ret = regmap_update_bits(dev->regmap, ATMEL_I2SC_MR, mr_mask, mr);
if (ret)
- return ret;
+ goto err_disable_gclk;
/* Finally enable the I2S Master Clock generator. */
- return regmap_write(dev->regmap, ATMEL_I2SC_CR,
- ATMEL_I2SC_CR_CKEN);
+ ret = regmap_write(dev->regmap, ATMEL_I2SC_CR, ATMEL_I2SC_CR_CKEN);
+ if (ret)
+ goto err_reset_mr;
+
+ return 0;
+
+err_reset_mr:
+ regmap_update_bits(dev->regmap, ATMEL_I2SC_MR, mr_mask, 0);
+err_disable_gclk:
+ clk_disable_unprepare(dev->gclk);
+
+ return ret;
}
static int atmel_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/5] ASoC: atmel-i2s: use optional API for muxclk
2026-10-02 4:38 [PATCH 0/5] ASoC: atmel-i2s: fix clock error handling phucduc.bui
2026-10-02 4:38 ` [PATCH 1/5] ASoC: atmel-i2s: fix MCK generator " phucduc.bui
@ 2026-10-02 4:38 ` phucduc.bui
2026-10-02 4:38 ` [PATCH 3/5] ASoC: atmel-i2s: use optional API for gclk phucduc.bui
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-02 4:38 UTC (permalink / raw)
To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
Alexandre Belloni
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Codrin Ciubotariu,
Cyrille Pitchen, linux-sound, linux-arm-kernel, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
The muxclk is an optional clock according to the device tree
binding.
Use devm_clk_get_optional() to handle the optional muxclk instead of
handling the missing clock explicitly.
When muxclk is not available, devm_clk_get_optional() returns NULL.
clk_set_parent() returns 0 when passed NULL, preserving the existing
behavior.
Unlike the existing code, errors other than -EPROBE_DEFER are now
returned instead of being silently ignored.
Fixes: b543e467d1a9 ("ASoC: atmel-i2s: add driver for the new Atmel I2S controller")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/atmel-i2s.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/sound/soc/atmel/atmel-i2s.c b/sound/soc/atmel/atmel-i2s.c
index f28808d980ce..c52d048449f8 100644
--- a/sound/soc/atmel/atmel-i2s.c
+++ b/sound/soc/atmel/atmel-i2s.c
@@ -589,21 +589,15 @@ static int atmel_i2s_sama5d2_mck_init(struct atmel_i2s_dev *dev,
struct device_node *np)
{
struct clk *muxclk;
- int err;
if (!dev->gclk)
return 0;
- /* muxclk is optional, so we return error for probe defer only */
- muxclk = devm_clk_get(dev->dev, "muxclk");
- if (IS_ERR(muxclk)) {
- err = PTR_ERR(muxclk);
- if (err == -EPROBE_DEFER)
- return -EPROBE_DEFER;
- dev_dbg(dev->dev,
- "failed to get the I2S clock control: %d\n", err);
- return 0;
- }
+ /* muxclk is optional */
+ muxclk = devm_clk_get_optional(dev->dev, "muxclk");
+ if (IS_ERR(muxclk))
+ return dev_err_probe(dev->dev, PTR_ERR(muxclk),
+ "failed to get the I2S clock control\n");
return clk_set_parent(muxclk, dev->gclk);
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/5] ASoC: atmel-i2s: use optional API for gclk
2026-10-02 4:38 [PATCH 0/5] ASoC: atmel-i2s: fix clock error handling phucduc.bui
2026-10-02 4:38 ` [PATCH 1/5] ASoC: atmel-i2s: fix MCK generator " phucduc.bui
2026-10-02 4:38 ` [PATCH 2/5] ASoC: atmel-i2s: use optional API for muxclk phucduc.bui
@ 2026-10-02 4:38 ` phucduc.bui
2026-10-02 4:38 ` [PATCH 4/5] ASoC: atmel-i2s: use dev_err_probe() for pclk errors phucduc.bui
2026-10-02 4:38 ` [PATCH 5/5] ASoC: atmel-i2s: remove redundant error message phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-02 4:38 UTC (permalink / raw)
To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
Alexandre Belloni
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Codrin Ciubotariu,
Cyrille Pitchen, linux-sound, linux-arm-kernel, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
The gclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional gclk directly.
Unlike the existing code, errors other than -EPROBE_DEFER are now
returned instead of being silently ignored.
Fixes: 73ad0df57290 ("ASoC: atmel-i2s: Remove unnecessary audio PLL clock (aclk)")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/atmel-i2s.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/sound/soc/atmel/atmel-i2s.c b/sound/soc/atmel/atmel-i2s.c
index c52d048449f8..6ca230f8adc8 100644
--- a/sound/soc/atmel/atmel-i2s.c
+++ b/sound/soc/atmel/atmel-i2s.c
@@ -670,13 +670,10 @@ static int atmel_i2s_probe(struct platform_device *pdev)
}
/* Get audio clock to generate the I2S Master Clock (I2S_MCK) */
- dev->gclk = devm_clk_get(&pdev->dev, "gclk");
- if (IS_ERR(dev->gclk)) {
- if (PTR_ERR(dev->gclk) == -EPROBE_DEFER)
- return -EPROBE_DEFER;
- /* Master Mode not supported */
- dev->gclk = NULL;
- }
+ dev->gclk = devm_clk_get_optional(&pdev->dev, "gclk");
+ if (IS_ERR(dev->gclk))
+ return PTR_ERR(dev->gclk);
+
dev->dev = &pdev->dev;
dev->regmap = regmap;
platform_set_drvdata(pdev, dev);
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/5] ASoC: atmel-i2s: use dev_err_probe() for pclk errors
2026-10-02 4:38 [PATCH 0/5] ASoC: atmel-i2s: fix clock error handling phucduc.bui
` (2 preceding siblings ...)
2026-10-02 4:38 ` [PATCH 3/5] ASoC: atmel-i2s: use optional API for gclk phucduc.bui
@ 2026-10-02 4:38 ` phucduc.bui
2026-10-02 4:38 ` [PATCH 5/5] ASoC: atmel-i2s: remove redundant error message phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-02 4:38 UTC (permalink / raw)
To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
Alexandre Belloni
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Codrin Ciubotariu,
Cyrille Pitchen, linux-sound, linux-arm-kernel, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Use dev_err_probe() when obtaining clocks to avoid redundant error
messages, particularly for probe deferral.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/atmel-i2s.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/sound/soc/atmel/atmel-i2s.c b/sound/soc/atmel/atmel-i2s.c
index 6ca230f8adc8..9b651eb4f0a4 100644
--- a/sound/soc/atmel/atmel-i2s.c
+++ b/sound/soc/atmel/atmel-i2s.c
@@ -662,12 +662,9 @@ static int atmel_i2s_probe(struct platform_device *pdev)
/* Get the peripheral clock. */
dev->pclk = devm_clk_get(&pdev->dev, "pclk");
- if (IS_ERR(dev->pclk)) {
- err = PTR_ERR(dev->pclk);
- dev_err(&pdev->dev,
- "failed to get the peripheral clock: %d\n", err);
- return err;
- }
+ if (IS_ERR(dev->pclk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(dev->pclk),
+ "failed to get the peripheral clock\n");
/* Get audio clock to generate the I2S Master Clock (I2S_MCK) */
dev->gclk = devm_clk_get_optional(&pdev->dev, "gclk");
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 5/5] ASoC: atmel-i2s: remove redundant error message
2026-10-02 4:38 [PATCH 0/5] ASoC: atmel-i2s: fix clock error handling phucduc.bui
` (3 preceding siblings ...)
2026-10-02 4:38 ` [PATCH 4/5] ASoC: atmel-i2s: use dev_err_probe() for pclk errors phucduc.bui
@ 2026-10-02 4:38 ` phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-02 4:38 UTC (permalink / raw)
To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
Alexandre Belloni
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Codrin Ciubotariu,
Cyrille Pitchen, linux-sound, linux-arm-kernel, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
The errors handled here are already reported by the called functions,
either directly or deeper in the call chain. Therefore, the additional
dev_err() call is redundant and can be removed.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/atmel/atmel-i2s.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/sound/soc/atmel/atmel-i2s.c b/sound/soc/atmel/atmel-i2s.c
index 9b651eb4f0a4..e1d8af056234 100644
--- a/sound/soc/atmel/atmel-i2s.c
+++ b/sound/soc/atmel/atmel-i2s.c
@@ -699,7 +699,6 @@ static int atmel_i2s_probe(struct platform_device *pdev)
&atmel_i2s_component,
&atmel_i2s_dai, 1);
if (err) {
- dev_err(&pdev->dev, "failed to register DAI: %d\n", err);
clk_disable_unprepare(dev->pclk);
return err;
}
@@ -714,7 +713,6 @@ static int atmel_i2s_probe(struct platform_device *pdev)
pcm_flags |= SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX;
err = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, pcm_flags);
if (err) {
- dev_err(&pdev->dev, "failed to register PCM: %d\n", err);
clk_disable_unprepare(dev->pclk);
return err;
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-10-02 4:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 4:38 [PATCH 0/5] ASoC: atmel-i2s: fix clock error handling phucduc.bui
2026-10-02 4:38 ` [PATCH 1/5] ASoC: atmel-i2s: fix MCK generator " phucduc.bui
2026-10-02 4:38 ` [PATCH 2/5] ASoC: atmel-i2s: use optional API for muxclk phucduc.bui
2026-10-02 4:38 ` [PATCH 3/5] ASoC: atmel-i2s: use optional API for gclk phucduc.bui
2026-10-02 4:38 ` [PATCH 4/5] ASoC: atmel-i2s: use dev_err_probe() for pclk errors phucduc.bui
2026-10-02 4:38 ` [PATCH 5/5] ASoC: atmel-i2s: remove redundant error message phucduc.bui
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®