summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2025-08-29 17:13:26 +0200
committerTakashi Iwai <tiwai@suse.de>2025-09-01 13:54:27 +0200
commit3d10c26fae4ec629a78b1c3189a6f6a0a8c053ba (patch)
tree4f53bf68dc219a9dcd56ea0726105496bce05da8
parent89008621bb2dcfcb8905f58a64cadcbdb16c9214 (diff)
ALSA: sparc: 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-13-tiwai@suse.de
-rw-r--r--sound/sparc/cs4231.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 1a1fe3ceb76c..8d54617e2526 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -608,7 +608,7 @@ static void snd_cs4231_playback_format(struct snd_cs4231 *chip,
{
unsigned long flags;
- mutex_lock(&chip->mce_mutex);
+ guard(mutex)(&chip->mce_mutex);
snd_cs4231_calibrate_mute(chip, 1);
snd_cs4231_mce_up(chip);
@@ -623,7 +623,6 @@ static void snd_cs4231_playback_format(struct snd_cs4231 *chip,
snd_cs4231_mce_down(chip);
snd_cs4231_calibrate_mute(chip, 0);
- mutex_unlock(&chip->mce_mutex);
}
static void snd_cs4231_capture_format(struct snd_cs4231 *chip,
@@ -632,7 +631,7 @@ static void snd_cs4231_capture_format(struct snd_cs4231 *chip,
{
unsigned long flags;
- mutex_lock(&chip->mce_mutex);
+ guard(mutex)(&chip->mce_mutex);
snd_cs4231_calibrate_mute(chip, 1);
snd_cs4231_mce_up(chip);
@@ -653,7 +652,6 @@ static void snd_cs4231_capture_format(struct snd_cs4231 *chip,
snd_cs4231_mce_down(chip);
snd_cs4231_calibrate_mute(chip, 0);
- mutex_unlock(&chip->mce_mutex);
}
/*
@@ -775,14 +773,11 @@ static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode)
{
unsigned long flags;
- mutex_lock(&chip->open_mutex);
- if ((chip->mode & mode)) {
- mutex_unlock(&chip->open_mutex);
+ guard(mutex)(&chip->open_mutex);
+ if ((chip->mode & mode))
return -EAGAIN;
- }
if (chip->mode & CS4231_MODE_OPEN) {
chip->mode |= mode;
- mutex_unlock(&chip->open_mutex);
return 0;
}
/* ok. now enable and ack CODEC IRQ */
@@ -802,7 +797,6 @@ static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode)
spin_unlock_irqrestore(&chip->lock, flags);
chip->mode = mode;
- mutex_unlock(&chip->open_mutex);
return 0;
}
@@ -810,12 +804,10 @@ static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode)
{
unsigned long flags;
- mutex_lock(&chip->open_mutex);
+ guard(mutex)(&chip->open_mutex);
chip->mode &= ~mode;
- if (chip->mode & CS4231_MODE_OPEN) {
- mutex_unlock(&chip->open_mutex);
+ if (chip->mode & CS4231_MODE_OPEN)
return;
- }
snd_cs4231_calibrate_mute(chip, 1);
/* disable IRQ */
@@ -851,7 +843,6 @@ static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode)
snd_cs4231_calibrate_mute(chip, 0);
chip->mode = 0;
- mutex_unlock(&chip->open_mutex);
}
/*