From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH 06/19] ALSA: x86: Use guard() for mutex locks
Date: Fri, 29 Aug 2025 17:13:20 +0200 [thread overview]
Message-ID: <20250829151335.7342-7-tiwai@suse.de> (raw)
In-Reply-To: <20250829151335.7342-1-tiwai@suse.de>
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>
---
sound/x86/intel_hdmi_audio.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 01f49555c5f6..c1506a9f7e15 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -554,16 +554,13 @@ static int had_chmap_ctl_get(struct snd_kcontrol *kcontrol,
memset(ucontrol->value.integer.value, 0,
sizeof(long) * HAD_MAX_CHANNEL);
- mutex_lock(&intelhaddata->mutex);
- if (!intelhaddata->chmap->chmap) {
- mutex_unlock(&intelhaddata->mutex);
+ guard(mutex)(&intelhaddata->mutex);
+ if (!intelhaddata->chmap->chmap)
return 0;
- }
chmap = intelhaddata->chmap->chmap;
for (i = 0; i < chmap->channels; i++)
ucontrol->value.integer.value[i] = chmap->map[i];
- mutex_unlock(&intelhaddata->mutex);
return 0;
}
@@ -1394,14 +1391,13 @@ static int had_iec958_get(struct snd_kcontrol *kcontrol,
{
struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol);
- mutex_lock(&intelhaddata->mutex);
+ guard(mutex)(&intelhaddata->mutex);
ucontrol->value.iec958.status[0] = (intelhaddata->aes_bits >> 0) & 0xff;
ucontrol->value.iec958.status[1] = (intelhaddata->aes_bits >> 8) & 0xff;
ucontrol->value.iec958.status[2] =
(intelhaddata->aes_bits >> 16) & 0xff;
ucontrol->value.iec958.status[3] =
(intelhaddata->aes_bits >> 24) & 0xff;
- mutex_unlock(&intelhaddata->mutex);
return 0;
}
@@ -1426,12 +1422,11 @@ static int had_iec958_put(struct snd_kcontrol *kcontrol,
(ucontrol->value.iec958.status[1] << 8) |
(ucontrol->value.iec958.status[2] << 16) |
(ucontrol->value.iec958.status[3] << 24);
- mutex_lock(&intelhaddata->mutex);
+ guard(mutex)(&intelhaddata->mutex);
if (intelhaddata->aes_bits != val) {
intelhaddata->aes_bits = val;
changed = 1;
}
- mutex_unlock(&intelhaddata->mutex);
return changed;
}
@@ -1448,10 +1443,9 @@ static int had_ctl_eld_get(struct snd_kcontrol *kcontrol,
{
struct snd_intelhad *intelhaddata = snd_kcontrol_chip(kcontrol);
- mutex_lock(&intelhaddata->mutex);
+ guard(mutex)(&intelhaddata->mutex);
memcpy(ucontrol->value.bytes.data, intelhaddata->eld,
HDMI_MAX_ELD_BYTES);
- mutex_unlock(&intelhaddata->mutex);
return 0;
}
--
2.50.1
next prev parent reply other threads:[~2025-08-29 15:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 15:13 [PATCH 00/19] ALSA: Use auto-cleanup for misc drivers Takashi Iwai
2025-08-29 15:13 ` [PATCH 01/19] ALSA: i2c: Use guard() for mutex locks Takashi Iwai
2025-08-29 15:13 ` [PATCH 02/19] ALSA: i2c: Use guard() for spin locks Takashi Iwai
2025-08-29 15:13 ` [PATCH 03/19] ALSA: synth: Use guard() for mutex locks Takashi Iwai
2025-08-29 15:13 ` [PATCH 04/19] ALSA: synth: Use guard() for spin locks Takashi Iwai
2025-08-29 15:13 ` [PATCH 05/19] ALSA: synth: Use guard() for preset locks Takashi Iwai
2025-08-29 15:13 ` Takashi Iwai [this message]
2025-08-29 15:13 ` [PATCH 07/19] ALSA: x86: Use guard() for spin locks Takashi Iwai
2025-08-29 15:13 ` [PATCH 08/19] ALSA: xen: Use guard() for mutex locks Takashi Iwai
2025-08-29 15:13 ` [PATCH 09/19] ALSA: at73c213: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 10/19] ALSA: pdaudiocf: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 11/19] ALSA: vxpocket: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 12/19] ALSA: sparc: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 13/19] ALSA: aoa: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 14/19] ALSA: aaci: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 15/19] ALSA: pxa2xx: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 16/19] ALSA: atmel: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 17/19] ALSA: ac97bus: " Takashi Iwai
2025-08-29 15:13 ` [PATCH 18/19] ALSA: virtio: Use guard() for spin locks Takashi Iwai
2025-08-29 15:13 ` [PATCH 19/19] ALSA: misc: " Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250829151335.7342-7-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-sound@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).