Re: [PATCH 13/24] ASoC: codecs: cs35l56: Use guard() and PM runtime scope helpers

Richard Fitzgerald <[email protected]> Mon, 6 Jul 2026 10:19:25 +0100
Newsgroups dev.linux.lists.chrome-platform,dev.linux.lists.asahi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound
Message-ID <[email protected]>
On 26/06/2026 7:13 am, [email protected] wrote:
> From: bui duc phuc <[email protected]>
> 
> Convert the interrupt handler to use guard(mutex) for automatic mutex
> unlocking and PM_RUNTIME_ACQUIRE_IF_ENABLED() to manage the runtime PM
> reference through scope-based cleanup.
> This removes the explicit cleanup paths while preserving the existing
> behavior.
> 
> Signed-off-by: bui duc phuc <[email protected]>
> ---
>   sound/soc/codecs/cs35l56-shared.c | 19 +++++++------------
>   1 file changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c
> index f14e2eaaa4ee..73fe1cba3f5b 100644
> --- a/sound/soc/codecs/cs35l56-shared.c
> +++ b/sound/soc/codecs/cs35l56-shared.c
> @@ -645,18 +645,19 @@ irqreturn_t cs35l56_irq(int irq, void *data)
>   	if (!cs35l56_base->init_done)
>   		return IRQ_NONE;
>   
> -	mutex_lock(&cs35l56_base->irq_lock);
> +	guard(mutex)(&cs35l56_base->irq_lock);
>   
> -	rv = pm_runtime_resume_and_get(cs35l56_base->dev);
> +	PM_RUNTIME_ACQUIRE_IF_ENABLED(cs35l56_base->dev, pm);
> +	rv = PM_RUNTIME_ACQUIRE_ERR(&pm);
>   	if (rv < 0) {
>   		dev_err(cs35l56_base->dev, "irq: failed to get pm_runtime: %d\n", rv);
> -		goto err_unlock;
> +		return ret;

Should change all the error returns to directly return IRQ_NONE.
It looks like a bug that it checks rv but returns ret.

The reason for ret was so it could use common exit code to 
pm_runtime_put() and mutex_unlock() for the error and success cases.
But this isn't needed now.

The local ret variable can be deleted.

>   	}
>   
>   	regmap_read(cs35l56_base->regmap, CS35L56_IRQ1_STATUS, &val);
>   	if ((val & CS35L56_IRQ1_STS_MASK) == 0) {
>   		dev_dbg(cs35l56_base->dev, "Spurious IRQ: no pending interrupt\n");
> -		goto err;
> +		return ret;
>   	}
>   
>   	/* Ack interrupts */
> @@ -680,7 +681,7 @@ irqreturn_t cs35l56_irq(int irq, void *data)
>   
>   	/* Check to see if unmasked bits are active */
>   	if (!status1 && !status8 && !status20)
> -		goto err;
> +		return ret;
>   
>   	if (status1 & CS35L56_AMP_SHORT_ERR_EINT1_MASK)
>   		dev_crit(cs35l56_base->dev, "Amp short error\n");
> @@ -688,14 +689,8 @@ irqreturn_t cs35l56_irq(int irq, void *data)
>   	if (status8 & CS35L56_TEMP_ERR_EINT1_MASK)
>   		dev_crit(cs35l56_base->dev, "Overtemp error\n");
>   
> -	ret = IRQ_HANDLED;
> +	return IRQ_HANDLED;
>   
> -err:
> -	pm_runtime_put(cs35l56_base->dev);
> -err_unlock:
> -	mutex_unlock(&cs35l56_base->irq_lock);
> -
> -	return ret;
>   }
>   EXPORT_SYMBOL_NS_GPL(cs35l56_irq, "SND_SOC_CS35L56_SHARED");
>