* [PATCH 0/5] ASoC: kirkwood: Improve clock and error handling
@ 2026-10-26 10:58 phucduc.bui
2026-10-26 10:58 ` [PATCH 1/5] ASoC: kirkwood: kirkwood-i2s: Fix error handling for resource mapping phucduc.bui
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-26 10:58 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
linux-sound, Russell King, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Hi all,
This series improves error handling and clock management in the
Kirkwood I2S driver.
It propagates resource mapping and clock enable errors, removes
redundant error logging, and ensures that clocks are cleaned up in
the correct order on probe failures and device removal.
Compile-tested only.
Best regards,
Phuc
bui duc phuc (5):
ASoC: kirkwood: kirkwood-i2s: Fix error handling for resource mapping
ASoC: kirkwood: kirkwood-i2s: Improve error handling in probe
ASoC: kirkwood: kirkwood-i2s: Check return value of
clk_prepare_enable()
ASoC: kirkwood: kirkwood-i2s: Disable extclk on internal clk error
ASoC: kirkwood: kirkwood-i2s: Disable clocks in reverse order in
remove()
sound/soc/kirkwood/kirkwood-i2s.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] ASoC: kirkwood: kirkwood-i2s: Fix error handling for resource mapping
2026-10-26 10:58 [PATCH 0/5] ASoC: kirkwood: Improve clock and error handling phucduc.bui
@ 2026-10-26 10:58 ` phucduc.bui
2026-10-26 10:58 ` [PATCH 2/5] ASoC: kirkwood: kirkwood-i2s: Improve error handling in probe phucduc.bui
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-26 10:58 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
linux-sound, Russell King, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Return the actual error code from devm_platform_ioremap_resource_byname()
instead of always returning -ENOMEM when resource mapping fails.
This preserves the original error code, allowing callers to identify
the actual cause of the failure.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/kirkwood/kirkwood-i2s.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 739a819d8494..cf4327101b96 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -59,11 +59,11 @@ static int armada_38x_i2s_init_quirk(struct platform_device *pdev,
priv->pll_config = devm_platform_ioremap_resource_byname(pdev, "pll_regs");
if (IS_ERR(priv->pll_config))
- return -ENOMEM;
+ return PTR_ERR(priv->pll_config);
priv->soc_control = devm_platform_ioremap_resource_byname(pdev, "soc_ctrl");
if (IS_ERR(priv->soc_control))
- return -ENOMEM;
+ return PTR_ERR(priv->soc_control);
/* Select one of exceptive modes: I2S or S/PDIF */
reg_val = readl(priv->soc_control);
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/5] ASoC: kirkwood: kirkwood-i2s: Improve error handling in probe
2026-10-26 10:58 [PATCH 0/5] ASoC: kirkwood: Improve clock and error handling phucduc.bui
2026-10-26 10:58 ` [PATCH 1/5] ASoC: kirkwood: kirkwood-i2s: Fix error handling for resource mapping phucduc.bui
@ 2026-10-26 10:58 ` phucduc.bui
2026-10-26 10:58 ` [PATCH 3/5] ASoC: kirkwood: kirkwood-i2s: Check return value of clk_prepare_enable() phucduc.bui
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-26 10:58 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
linux-sound, Russell King, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Use dev_err_probe() to report clock acquisition errors.
Remove the redundant error message when snd_soc_register_component()
fails. The errors handled here are already reported deeper in the
call chain, so the additional dev_err() call is unnecessary.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/kirkwood/kirkwood-i2s.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index cf4327101b96..29641bd4cc60 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -687,10 +687,9 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
}
priv->clk = devm_clk_get(&pdev->dev, np ? "internal" : NULL);
- if (IS_ERR(priv->clk)) {
- dev_err(&pdev->dev, "no clock\n");
- return PTR_ERR(priv->clk);
- }
+ if (IS_ERR(priv->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk),
+ "no clock\n");
priv->extclk = devm_clk_get(&pdev->dev, "extclk");
if (IS_ERR(priv->extclk)) {
@@ -726,10 +725,8 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
err = snd_soc_register_component(&pdev->dev, &kirkwood_soc_component,
soc_dai, 2);
- if (err) {
- dev_err(&pdev->dev, "snd_soc_register_component failed\n");
+ if (err)
goto err_component;
- }
kirkwood_i2s_init(priv);
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/5] ASoC: kirkwood: kirkwood-i2s: Check return value of clk_prepare_enable()
2026-10-26 10:58 [PATCH 0/5] ASoC: kirkwood: Improve clock and error handling phucduc.bui
2026-10-26 10:58 ` [PATCH 1/5] ASoC: kirkwood: kirkwood-i2s: Fix error handling for resource mapping phucduc.bui
2026-10-26 10:58 ` [PATCH 2/5] ASoC: kirkwood: kirkwood-i2s: Improve error handling in probe phucduc.bui
@ 2026-10-26 10:58 ` phucduc.bui
2026-10-26 10:58 ` [PATCH 4/5] ASoC: kirkwood: kirkwood-i2s: Disable extclk on internal clk error phucduc.bui
2026-10-26 10:58 ` [PATCH 5/5] ASoC: kirkwood: kirkwood-i2s: Disable clocks in reverse order in remove() phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-26 10:58 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
linux-sound, Russell King, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
kirkwood_i2s_dev_probe() ignores the return value of
clk_prepare_enable() when enabling the external clock.
If enabling the clock fails, the driver still selects the external
clock DAI configuration and may later call clk_disable_unprepare()
on a clock that was never successfully enabled, triggering an
unbalanced disable warning.
Check the return value and fail probe if enabling the clock fails.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/kirkwood/kirkwood-i2s.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 29641bd4cc60..395790682355 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -701,7 +701,9 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
priv->extclk = ERR_PTR(-EINVAL);
} else {
dev_info(&pdev->dev, "found external clock\n");
- clk_prepare_enable(priv->extclk);
+ err = clk_prepare_enable(priv->extclk);
+ if (err < 0)
+ return err;
soc_dai = kirkwood_i2s_dai_extclk;
}
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/5] ASoC: kirkwood: kirkwood-i2s: Disable extclk on internal clk error
2026-10-26 10:58 [PATCH 0/5] ASoC: kirkwood: Improve clock and error handling phucduc.bui
` (2 preceding siblings ...)
2026-10-26 10:58 ` [PATCH 3/5] ASoC: kirkwood: kirkwood-i2s: Check return value of clk_prepare_enable() phucduc.bui
@ 2026-10-26 10:58 ` phucduc.bui
2026-10-26 10:58 ` [PATCH 5/5] ASoC: kirkwood: kirkwood-i2s: Disable clocks in reverse order in remove() phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-26 10:58 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
linux-sound, Russell King, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
kirkwood_i2s_dev_probe() enables the external clock before the
internal clock. If enabling the internal clock fails, the probe
returns directly, leaving the external clock enabled.
Jump to err_clk to disable the external clock on failure. Also reorder
the error path to disable the clocks in reverse order of enabling,
allowing the error labels to fall through.
Fixes: 4523817d51bc ("ASoC: kirkwood: fix external clock probe defer")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/kirkwood/kirkwood-i2s.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 395790682355..cf6b96054b82 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -710,7 +710,7 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
err = clk_prepare_enable(priv->clk);
if (err < 0)
- return err;
+ goto err_clk;
/* Some sensible defaults - this reflects the powerup values */
priv->ctl_play = KIRKWOOD_PLAYCTL_SIZE_24;
@@ -734,10 +734,11 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
return 0;
- err_component:
+err_component:
+ clk_disable_unprepare(priv->clk);
+err_clk:
if (!IS_ERR(priv->extclk))
clk_disable_unprepare(priv->extclk);
- clk_disable_unprepare(priv->clk);
return err;
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 5/5] ASoC: kirkwood: kirkwood-i2s: Disable clocks in reverse order in remove()
2026-10-26 10:58 [PATCH 0/5] ASoC: kirkwood: Improve clock and error handling phucduc.bui
` (3 preceding siblings ...)
2026-10-26 10:58 ` [PATCH 4/5] ASoC: kirkwood: kirkwood-i2s: Disable extclk on internal clk error phucduc.bui
@ 2026-10-26 10:58 ` phucduc.bui
4 siblings, 0 replies; 6+ messages in thread
From: phucduc.bui @ 2026-10-26 10:58 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
linux-sound, Russell King, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Disable the internal clock before the external one in
kirkwood_i2s_dev_remove(), matching the reverse order of enabling and
the error path in kirkwood_i2s_dev_probe().
No functional change intended.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/kirkwood/kirkwood-i2s.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index cf6b96054b82..c26326b82c19 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -748,9 +748,9 @@ static void kirkwood_i2s_dev_remove(struct platform_device *pdev)
struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_component(&pdev->dev);
+ clk_disable_unprepare(priv->clk);
if (!IS_ERR(priv->extclk))
clk_disable_unprepare(priv->extclk);
- clk_disable_unprepare(priv->clk);
}
#ifdef CONFIG_OF
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-10-26 10:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 10:58 [PATCH 0/5] ASoC: kirkwood: Improve clock and error handling phucduc.bui
2026-10-26 10:58 ` [PATCH 1/5] ASoC: kirkwood: kirkwood-i2s: Fix error handling for resource mapping phucduc.bui
2026-10-26 10:58 ` [PATCH 2/5] ASoC: kirkwood: kirkwood-i2s: Improve error handling in probe phucduc.bui
2026-10-26 10:58 ` [PATCH 3/5] ASoC: kirkwood: kirkwood-i2s: Check return value of clk_prepare_enable() phucduc.bui
2026-10-26 10:58 ` [PATCH 4/5] ASoC: kirkwood: kirkwood-i2s: Disable extclk on internal clk error phucduc.bui
2026-10-26 10:58 ` [PATCH 5/5] ASoC: kirkwood: kirkwood-i2s: Disable clocks in reverse order in remove() 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®