Re: [PATCH v2 15/24] ASoC: codecs: cs42l43: Use guard() and PM runtime scope helpers
From: Charles Keepax
Date: Mon Jul 06 2026 - 09:23:31 EST
On Fri, Jul 03, 2026 at 12:53:46PM +0700, phucduc.bui@xxxxxxxxx wrote:
> From: bui duc phuc <phucduc.bui@xxxxxxxxx>
>
> Convert mutex locking to guard(mutex) and replace explicit runtime
> PM handling with runtime PM scope helpers.
> This simplifies the control flow by removing explicit cleanup paths
> and unnecessary 'goto' labels.
>
> Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
> ---
> @@ -374,17 +379,18 @@ irqreturn_t cs42l43_button_press(int irq, void *data)
> unsigned int val = 0;
> int i, ret;
>
> - ret = pm_runtime_resume_and_get(priv->dev);
> + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(priv->dev, pm);
> + ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
> if (ret) {
> dev_err(priv->dev, "Failed to resume for button press: %d\n", ret);
> return iret;
iret only really made sense with the goto, might as well drop
the variable and return IRQ_NONE directly.
> }
>
> - mutex_lock(&priv->jack_lock);
> + guard(mutex)(&priv->jack_lock);
>
> if (!priv->button_detect_running) {
> dev_dbg(priv->dev, "Spurious button press IRQ\n");
> - goto error;
> + return iret;
> }
> irqreturn_t cs42l43_button_release(int irq, void *data)
> @@ -439,13 +438,14 @@ irqreturn_t cs42l43_button_release(int irq, void *data)
> irqreturn_t iret = IRQ_NONE;
> int ret;
>
> - ret = pm_runtime_resume_and_get(priv->dev);
> + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(priv->dev, pm);
> + ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
> if (ret) {
> dev_err(priv->dev, "Failed to resume for button release: %d\n", ret);
> return iret;
Same in cs42l43_button_release().
Thanks,
Charles