linux-sound.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>,
	Clemens Ladisch <clemens@ladisch.de>
Subject: [PATCH v2 09/19] ALSA: firewire: isight: Use guard() for mutex locks
Date: Thu, 28 Aug 2025 15:27:13 +0200	[thread overview]
Message-ID: <20250828132802.9032-10-tiwai@suse.de> (raw)
In-Reply-To: <20250828132802.9032-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/firewire/isight.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
index ee574b5d7406..2b7f071d593b 100644
--- a/sound/firewire/isight.c
+++ b/sound/firewire/isight.c
@@ -327,9 +327,8 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
 
 	WRITE_ONCE(isight->pcm_active, false);
 
-	mutex_lock(&isight->mutex);
+	guard(mutex)(&isight->mutex);
 	isight_stop_streaming(isight);
-	mutex_unlock(&isight->mutex);
 
 	return 0;
 }
@@ -400,16 +399,12 @@ static int isight_start_streaming(struct isight *isight)
 static int isight_prepare(struct snd_pcm_substream *substream)
 {
 	struct isight *isight = substream->private_data;
-	int err;
 
 	isight->buffer_pointer = 0;
 	isight->period_counter = 0;
 
-	mutex_lock(&isight->mutex);
-	err = isight_start_streaming(isight);
-	mutex_unlock(&isight->mutex);
-
-	return err;
+	guard(mutex)(&isight->mutex);
+	return isight_start_streaming(isight);
 }
 
 static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
@@ -677,9 +672,8 @@ static void isight_bus_reset(struct fw_unit *unit)
 	if (fw_iso_resources_update(&isight->resources) < 0) {
 		isight_pcm_abort(isight);
 
-		mutex_lock(&isight->mutex);
+		guard(mutex)(&isight->mutex);
 		isight_stop_streaming(isight);
-		mutex_unlock(&isight->mutex);
 	}
 }
 
@@ -691,9 +685,9 @@ static void isight_remove(struct fw_unit *unit)
 
 	snd_card_disconnect(isight->card);
 
-	mutex_lock(&isight->mutex);
-	isight_stop_streaming(isight);
-	mutex_unlock(&isight->mutex);
+	scoped_guard(mutex, &isight->mutex) {
+		isight_stop_streaming(isight);
+	}
 
 	// Block till all of ALSA character devices are released.
 	snd_card_free(isight->card);
-- 
2.50.1


  parent reply	other threads:[~2025-08-28 13:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-28 13:27 [PATCH v2 00/19] ALSA: firewire: Use auto-cleanup macros Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 01/19] ALSA: firewire: bebob: Use guard() for mutex locks Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 02/19] ALSA: firewire: dice: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 03/19] ALSA: firewire: digi00x: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 04/19] ALSA: firewire: fireworks: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 05/19] ALSA: firewire: motu: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 06/19] ALSA: firewire: oxfw: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 07/19] ALSA: firewire: tascam: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 08/19] ALSA: firewire: fireface: " Takashi Iwai
2025-08-28 13:27 ` Takashi Iwai [this message]
2025-08-28 13:27 ` [PATCH v2 10/19] ALSA: firewire: lib: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 11/19] ALSA: firewire: bebob: Use guard() for spin locks Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 12/19] ALSA: firewire: dice: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 13/19] ALSA: firewire: digi00x: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 14/19] ALSA: firewire: fireface: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 15/19] ALSA: firewire: fireworks: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 16/19] ALSA: firewire: motu: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 17/19] ALSA: firewire: oxfw: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 18/19] ALSA: firewire: tascam: " Takashi Iwai
2025-08-28 13:27 ` [PATCH v2 19/19] ALSA: firewire: lib: " Takashi Iwai
2025-08-29 23:47 ` [PATCH v2 00/19] ALSA: firewire: Use auto-cleanup macros Takashi Sakamoto
2025-08-30  7:34   ` 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=20250828132802.9032-10-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=clemens@ladisch.de \
    --cc=linux-sound@vger.kernel.org \
    --cc=o-takashi@sakamocchi.jp \
    /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).