* [PATCH 1/2] ASoC: samsung: i2s: Avoid mixing goto with guard()
2026-07-01 4:13 [PATCH 0/2] ASoC: Fix mixed goto and guard() usage phucduc.bui
@ 2026-07-01 4:13 ` phucduc.bui
2026-07-01 4:13 ` [PATCH 2/2] ASoC: ti: j721e-evm: " phucduc.bui
2026-07-01 15:42 ` [PATCH 0/2] ASoC: Fix mixed goto and guard() usage Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-07-01 4:13 UTC (permalink / raw)
To: Sylwester Nawrocki, Liam Girdwood, Mark Brown, Jaroslav Kysela
Cc: Takashi Iwai, linux-sound, linux-kernel, Sen Wang, Jarkko Nikula,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
cleanup.h recommends not mixing goto-based error handling with cleanup
helpers in the same function.
Remove the goto path and rely on guard(pm_runtime) for automatic cleanup
instead.
Fixes: 3d08517b5c67 ("ASoC: samsung: i2s: Use guard() for spin locks")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/samsung/i2s.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index f80f697a5d55..f80e8d498156 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -8,6 +8,7 @@
#include <dt-bindings/sound/samsung-i2s.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
@@ -512,7 +513,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
u32 mod, mask, val = 0;
int ret = 0;
- pm_runtime_get_sync(dai->dev);
+ guard(pm_runtime_active)(dai->dev);
scoped_guard(spinlock_irqsave, &priv->lock)
mod = readl(priv->addr + I2SMOD);
@@ -537,8 +538,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
&& (mod & cdcon_mask))))) {
dev_err(&i2s->pdev->dev,
"%s:%d Other DAI busy\n", __func__, __LINE__);
- ret = -EAGAIN;
- goto err;
+ return -EAGAIN;
}
if (dir == SND_SOC_CLOCK_IN)
@@ -566,7 +566,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
} else {
priv->rclk_srcrate =
clk_get_rate(priv->op_clk);
- goto done;
+ return 0;
}
}
@@ -580,14 +580,14 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
if (WARN_ON(IS_ERR(priv->op_clk))) {
ret = PTR_ERR(priv->op_clk);
priv->op_clk = NULL;
- goto err;
+ return ret;
}
ret = clk_prepare_enable(priv->op_clk);
if (ret) {
clk_put(priv->op_clk);
priv->op_clk = NULL;
- goto err;
+ return ret;
}
priv->rclk_srcrate = clk_get_rate(priv->op_clk);
@@ -595,11 +595,10 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
|| (clk_id && !(mod & rsrc_mask))) {
dev_err(&i2s->pdev->dev,
"%s:%d Other DAI busy\n", __func__, __LINE__);
- ret = -EAGAIN;
- goto err;
+ return -EAGAIN;
} else {
/* Call can't be on the active DAI */
- goto done;
+ return 0;
}
if (clk_id == 1)
@@ -607,8 +606,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
break;
default:
dev_err(&i2s->pdev->dev, "We don't serve that!\n");
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
scoped_guard(spinlock_irqsave, &priv->lock) {
@@ -616,13 +614,8 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
mod = (mod & ~mask) | val;
writel(mod, priv->addr + I2SMOD);
}
-done:
- pm_runtime_put(dai->dev);
return 0;
-err:
- pm_runtime_put(dai->dev);
- return ret;
}
static int i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] ASoC: ti: j721e-evm: Avoid mixing goto with guard()
2026-07-01 4:13 [PATCH 0/2] ASoC: Fix mixed goto and guard() usage phucduc.bui
2026-07-01 4:13 ` [PATCH 1/2] ASoC: samsung: i2s: Avoid mixing goto with guard() phucduc.bui
@ 2026-07-01 4:13 ` phucduc.bui
2026-07-01 15:42 ` [PATCH 0/2] ASoC: Fix mixed goto and guard() usage Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-07-01 4:13 UTC (permalink / raw)
To: Sylwester Nawrocki, Liam Girdwood, Mark Brown, Jaroslav Kysela
Cc: Takashi Iwai, linux-sound, linux-kernel, Sen Wang, Jarkko Nikula,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
The previous guard(mutex) conversion mixed cleanup helpers with
goto-based error handling, which is discouraged by the cleanup.h
guidelines.
Restore mutex_lock()/mutex_unlock() instead.
Fixes: 6f4cf77320ae ("ASoC: ti: j721e-evm: Use guard() for mutex locks")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/ti/j721e-evm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/ti/j721e-evm.c b/sound/soc/ti/j721e-evm.c
index c214ae0d7b95..312298e0b004 100644
--- a/sound/soc/ti/j721e-evm.c
+++ b/sound/soc/ti/j721e-evm.c
@@ -4,6 +4,7 @@
* Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
*/
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -263,7 +264,7 @@ static int j721e_audio_startup(struct snd_pcm_substream *substream)
int ret = 0;
int i;
- guard(mutex)(&priv->mutex);
+ mutex_lock(&priv->mutex);
domain->active++;
@@ -303,6 +304,7 @@ static int j721e_audio_startup(struct snd_pcm_substream *substream)
out:
if (ret)
domain->active--;
+ mutex_unlock(&priv->mutex);
return ret;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] ASoC: Fix mixed goto and guard() usage
2026-07-01 4:13 [PATCH 0/2] ASoC: Fix mixed goto and guard() usage phucduc.bui
2026-07-01 4:13 ` [PATCH 1/2] ASoC: samsung: i2s: Avoid mixing goto with guard() phucduc.bui
2026-07-01 4:13 ` [PATCH 2/2] ASoC: ti: j721e-evm: " phucduc.bui
@ 2026-07-01 15:42 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-07-01 15:42 UTC (permalink / raw)
To: Sylwester Nawrocki, Liam Girdwood, Jaroslav Kysela, phucduc.bui
Cc: Takashi Iwai, linux-sound, linux-kernel, Sen Wang, Jarkko Nikula
On Wed, 01 Jul 2026 11:13:08 +0700, phucduc.bui@gmail.com wrote:
> ASoC: Fix mixed goto and guard() usage
>
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> Hi all,
>
> These two patches fix the remaining cases of mixed goto-based error
> handling and cleanup helpers introduced by the recent guard() conversion
> patches that have already been merged for the 7.2 development cycle.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/2] ASoC: samsung: i2s: Avoid mixing goto with guard()
https://git.kernel.org/broonie/sound/c/02fd694e60a7
[2/2] ASoC: ti: j721e-evm: Avoid mixing goto with guard()
https://git.kernel.org/broonie/sound/c/47a0dde9a3bd
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread