From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Cc: David Rhodes <david.rhodes@cirrus.com>,
Richard Fitzgerald <rf@opensource.cirrus.com>,
patches@opensource.cirrus.com,
Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
Baojun Xu <baojun.xu@ti.com>
Subject: [PATCH 14/25] ALSA: hda/cs8409: Use guard() for mutex locks
Date: Mon, 11 Aug 2025 12:07:48 +0200 [thread overview]
Message-ID: <20250811100807.7962-15-tiwai@suse.de> (raw)
In-Reply-To: <20250811100807.7962-1-tiwai@suse.de>
Replace the manual mutex lock/unlock pairs with guard().
Only code refactoring, and no behavior change.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/hda/codecs/cirrus/cs8409.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/sound/hda/codecs/cirrus/cs8409.c b/sound/hda/codecs/cirrus/cs8409.c
index e32b462cdc5e..2c02d3be89ee 100644
--- a/sound/hda/codecs/cirrus/cs8409.c
+++ b/sound/hda/codecs/cirrus/cs8409.c
@@ -92,13 +92,12 @@ static void cs8409_disable_i2c_clock(struct hda_codec *codec)
{
struct cs8409_spec *spec = codec->spec;
- mutex_lock(&spec->i2c_mux);
+ guard(mutex)(&spec->i2c_mux);
if (spec->i2c_clck_enabled) {
cs8409_vendor_coef_set(spec->codec, 0x0,
cs8409_vendor_coef_get(spec->codec, 0x0) & 0xfffffff7);
spec->i2c_clck_enabled = 0;
}
- mutex_unlock(&spec->i2c_mux);
}
/*
@@ -204,7 +203,7 @@ static int cs8409_i2c_read(struct sub_codec *scodec, unsigned int addr)
if (scodec->suspended)
return -EPERM;
- mutex_lock(&spec->i2c_mux);
+ guard(mutex)(&spec->i2c_mux);
cs8409_enable_i2c_clock(codec);
cs8409_set_i2c_dev_addr(codec, scodec->addr);
@@ -219,12 +218,9 @@ static int cs8409_i2c_read(struct sub_codec *scodec, unsigned int addr)
/* Register in bits 15-8 and the data in 7-0 */
read_data = cs8409_vendor_coef_get(codec, CS8409_I2C_QREAD);
- mutex_unlock(&spec->i2c_mux);
-
return read_data & 0x0ff;
error:
- mutex_unlock(&spec->i2c_mux);
codec_err(codec, "%s() Failed 0x%02x : 0x%04x\n", __func__, scodec->addr, addr);
return -EIO;
}
@@ -247,7 +243,7 @@ static int cs8409_i2c_bulk_read(struct sub_codec *scodec, struct cs8409_i2c_para
if (scodec->suspended)
return -EPERM;
- mutex_lock(&spec->i2c_mux);
+ guard(mutex)(&spec->i2c_mux);
cs8409_set_i2c_dev_addr(codec, scodec->addr);
for (i = 0; i < count; i++) {
@@ -264,12 +260,9 @@ static int cs8409_i2c_bulk_read(struct sub_codec *scodec, struct cs8409_i2c_para
seq[i].value = cs8409_vendor_coef_get(codec, CS8409_I2C_QREAD) & 0xff;
}
- mutex_unlock(&spec->i2c_mux);
-
return 0;
error:
- mutex_unlock(&spec->i2c_mux);
codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr);
return -EIO;
}
@@ -291,7 +284,7 @@ static int cs8409_i2c_write(struct sub_codec *scodec, unsigned int addr, unsigne
if (scodec->suspended)
return -EPERM;
- mutex_lock(&spec->i2c_mux);
+ guard(mutex)(&spec->i2c_mux);
cs8409_enable_i2c_clock(codec);
cs8409_set_i2c_dev_addr(codec, scodec->addr);
@@ -305,11 +298,9 @@ static int cs8409_i2c_write(struct sub_codec *scodec, unsigned int addr, unsigne
if (cs8409_i2c_wait_complete(codec) < 0)
goto error;
- mutex_unlock(&spec->i2c_mux);
return 0;
error:
- mutex_unlock(&spec->i2c_mux);
codec_err(codec, "%s() Failed 0x%02x : 0x%04x\n", __func__, scodec->addr, addr);
return -EIO;
}
@@ -333,7 +324,7 @@ static int cs8409_i2c_bulk_write(struct sub_codec *scodec, const struct cs8409_i
if (scodec->suspended)
return -EPERM;
- mutex_lock(&spec->i2c_mux);
+ guard(mutex)(&spec->i2c_mux);
cs8409_set_i2c_dev_addr(codec, scodec->addr);
for (i = 0; i < count; i++) {
@@ -353,12 +344,9 @@ static int cs8409_i2c_bulk_write(struct sub_codec *scodec, const struct cs8409_i
fsleep(seq[i].delay);
}
- mutex_unlock(&spec->i2c_mux);
-
return 0;
error:
- mutex_unlock(&spec->i2c_mux);
codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr);
return -EIO;
}
--
2.50.1
next prev parent reply other threads:[~2025-08-11 10:08 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 10:07 [PATCH 00/25] ALSA: hda: Use auto-cleanup macros Takashi Iwai
2025-08-11 10:07 ` [PATCH 01/25] ALSA: hda: Introduce auto cleanup macros for PM Takashi Iwai
2025-08-11 10:07 ` [PATCH 02/25] ALSA: hda/ca0132: Use cleanup macros for PM controls Takashi Iwai
2025-08-11 10:07 ` [PATCH 03/25] ALSA: hda/hdmi: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 04/25] ALSA: hda/realtek: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 05/25] ALSA: hda/common: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 06/25] ALSA: hda: Use auto cleanup macros for DSP loader locks Takashi Iwai
2025-08-11 10:07 ` [PATCH 07/25] ALSA: hda/common: Use guard() for mutex locks Takashi Iwai
2025-08-11 10:07 ` [PATCH 08/25] ALSA: hda/core: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 09/25] ALSA: hda/ca0132: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 10/25] ALSA: hda/hdmi: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 11/25] ALSA: hda/realtek: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 12/25] ALSA: hda/cs35l41: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 13/25] ALSA: hda/tas2781: " Takashi Iwai
2025-08-11 10:07 ` Takashi Iwai [this message]
2025-08-11 10:07 ` [PATCH 15/25] ALSA: hda/component: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 16/25] ALSA: hda/generic: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 17/25] ALSA: hda/analog: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 18/25] ALSA: hda/intel: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 19/25] ALSA: hda/common: Use auto cleanup for temporary buffers Takashi Iwai
2025-08-11 10:07 ` [PATCH 20/25] ALSA: hda/realtek: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 21/25] ALSA: hda/generic: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 22/25] ALSA: hda/ext: Use guard() for spinlocks Takashi Iwai
2025-08-11 10:07 ` [PATCH 23/25] ALSA: hda/core: " Takashi Iwai
2025-08-13 14:07 ` Andy Shevchenko
2025-08-13 14:10 ` Andy Shevchenko
2025-08-13 14:19 ` Takashi Iwai
2025-08-11 10:07 ` [PATCH 24/25] ALSA: hda/common: " Takashi Iwai
2025-08-11 10:07 ` [PATCH 25/25] ALSA: hda/intel: " 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=20250811100807.7962-15-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=baojun.xu@ti.com \
--cc=david.rhodes@cirrus.com \
--cc=kevin-lu@ti.com \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rf@opensource.cirrus.com \
--cc=shenghao-ding@ti.com \
/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