ALSA: pxa2xx: Use guard() for mutex locks

JIRA: https://issues.redhat.com/browse/RHEL-118911

Assisted-by: Patchpal AI
Conflicts: no readl/writel use

commit 372020ddaa76ba9d18806de90448562ca12ad53e
Author: Takashi Iwai <tiwai@suse.de>
Date: Fri Aug 29 17:13:29 2025 +0200

    ALSA: pxa2xx: Use guard() for mutex locks

    Replace the manual mutex lock/unlock pairs with guard() for code
    simplification.

    Only code refactoring, and no behavior change.

    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Link: https://patch.msgid.link/20250829151335.7342-16-tiwai@suse.de

Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
This commit is contained in:
Jaroslav Kysela
2026-02-15 21:33:35 +01:00
parent e463a30196
commit ff70e3cc68
+4 -8
View File
@@ -51,7 +51,7 @@ int pxa2xx_ac97_read(int slot, unsigned short reg)
if (slot > 0)
return -ENODEV;
mutex_lock(&car_mutex);
guard(mutex)(&car_mutex);
/* set up primary or secondary codec space */
if (cpu_is_pxa25x() && reg == AC97_GPIO_STATUS)
@@ -65,13 +65,12 @@ int pxa2xx_ac97_read(int slot, unsigned short reg)
gsr_bits = 0;
val = (*reg_addr & 0xffff);
if (reg == AC97_GPIO_STATUS)
goto out;
return val;
if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 &&
!((GSR | gsr_bits) & GSR_SDONE)) {
printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",
__func__, reg, GSR | gsr_bits);
val = -ETIMEDOUT;
goto out;
return -ETIMEDOUT;
}
/* valid data now */
@@ -80,8 +79,6 @@ int pxa2xx_ac97_read(int slot, unsigned short reg)
val = (*reg_addr & 0xffff);
/* but we've just started another cycle... */
wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
out: mutex_unlock(&car_mutex);
return val;
}
EXPORT_SYMBOL_GPL(pxa2xx_ac97_read);
@@ -91,7 +88,7 @@ int pxa2xx_ac97_write(int slot, unsigned short reg, unsigned short val)
volatile u32 *reg_addr;
int ret = 0;
mutex_lock(&car_mutex);
guard(mutex)(&car_mutex);
/* set up primary or secondary codec space */
if (cpu_is_pxa25x() && reg == AC97_GPIO_STATUS)
@@ -110,7 +107,6 @@ int pxa2xx_ac97_write(int slot, unsigned short reg, unsigned short val)
ret = -EIO;
}
mutex_unlock(&car_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(pxa2xx_ac97_write);