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 19/19] ALSA: firewire: lib: Use guard() for spin locks
Date: Wed, 27 Aug 2025 11:20:13 +0200 [thread overview]
Message-ID: <20250827092017.29014-20-tiwai@suse.de> (raw)
In-Reply-To: <20250827092017.29014-1-tiwai@suse.de>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/firewire/fcp.c | 19 ++++++++-----------
sound/firewire/iso-resources.c | 16 ++++++++--------
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/sound/firewire/fcp.c b/sound/firewire/fcp.c
index df44dd5dc4b2..e60bfd0ee4ac 100644
--- a/sound/firewire/fcp.c
+++ b/sound/firewire/fcp.c
@@ -242,9 +242,9 @@ int fcp_avc_transaction(struct fw_unit *unit,
init_waitqueue_head(&t.wait);
t.deferrable = (*(const u8 *)command == 0x00 || *(const u8 *)command == 0x03);
- spin_lock_irq(&transactions_lock);
- list_add_tail(&t.list, &transactions);
- spin_unlock_irq(&transactions_lock);
+ scoped_guard(spinlock_irq, &transactions_lock) {
+ list_add_tail(&t.list, &transactions);
+ }
for (;;) {
tcode = command_size == 4 ? TCODE_WRITE_QUADLET_REQUEST
@@ -280,9 +280,9 @@ int fcp_avc_transaction(struct fw_unit *unit,
}
}
- spin_lock_irq(&transactions_lock);
- list_del(&t.list);
- spin_unlock_irq(&transactions_lock);
+ scoped_guard(spinlock_irq, &transactions_lock) {
+ list_del(&t.list);
+ }
return ret;
}
@@ -300,7 +300,7 @@ void fcp_bus_reset(struct fw_unit *unit)
{
struct fcp_transaction *t;
- spin_lock_irq(&transactions_lock);
+ guard(spinlock_irq)(&transactions_lock);
list_for_each_entry(t, &transactions, list) {
if (t->unit == unit &&
(t->state == STATE_PENDING ||
@@ -309,7 +309,6 @@ void fcp_bus_reset(struct fw_unit *unit)
wake_up(&t->wait);
}
}
- spin_unlock_irq(&transactions_lock);
}
EXPORT_SYMBOL(fcp_bus_reset);
@@ -341,12 +340,11 @@ static void fcp_response(struct fw_card *card, struct fw_request *request,
void *data, size_t length, void *callback_data)
{
struct fcp_transaction *t;
- unsigned long flags;
if (length < 1 || (*(const u8 *)data & 0xf0) != CTS_AVC)
return;
- spin_lock_irqsave(&transactions_lock, flags);
+ guard(spinlock_irqsave)(&transactions_lock);
list_for_each_entry(t, &transactions, list) {
struct fw_device *device = fw_parent_device(t->unit);
if (device->card != card ||
@@ -370,7 +368,6 @@ static void fcp_response(struct fw_card *card, struct fw_request *request,
wake_up(&t->wait);
}
}
- spin_unlock_irqrestore(&transactions_lock, flags);
}
static struct fw_address_handler response_register_handler = {
diff --git a/sound/firewire/iso-resources.c b/sound/firewire/iso-resources.c
index b47ee029d688..4f63279225c5 100644
--- a/sound/firewire/iso-resources.c
+++ b/sound/firewire/iso-resources.c
@@ -114,10 +114,10 @@ int fw_iso_resources_allocate(struct fw_iso_resources *r,
r->bandwidth = packet_bandwidth(max_payload_bytes, speed);
retry_after_bus_reset:
- spin_lock_irq(&card->lock);
- r->generation = card->generation;
- r->bandwidth_overhead = current_bandwidth_overhead(card);
- spin_unlock_irq(&card->lock);
+ scoped_guard(spinlock_irq, &card->lock) {
+ r->generation = card->generation;
+ r->bandwidth_overhead = current_bandwidth_overhead(card);
+ }
err = wait_isoch_resource_delay_after_bus_reset(card);
if (err < 0)
@@ -167,10 +167,10 @@ int fw_iso_resources_update(struct fw_iso_resources *r)
if (!r->allocated)
return 0;
- spin_lock_irq(&card->lock);
- r->generation = card->generation;
- r->bandwidth_overhead = current_bandwidth_overhead(card);
- spin_unlock_irq(&card->lock);
+ scoped_guard(spinlock_irq, &card->lock) {
+ r->generation = card->generation;
+ r->bandwidth_overhead = current_bandwidth_overhead(card);
+ }
bandwidth = r->bandwidth + r->bandwidth_overhead;
--
2.50.1
next prev parent reply other threads:[~2025-08-27 9:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 9:19 [PATCH 00/19] ALSA: firewire: Use auto-cleanup macros Takashi Iwai
2025-08-27 9:19 ` [PATCH 01/19] ALSA: firewire: bebob: Use guard() for mutex locks Takashi Iwai
2025-08-27 9:19 ` [PATCH 02/19] ALSA: firewire: dice: " Takashi Iwai
2025-08-27 9:19 ` [PATCH 03/19] ALSA: firewire: " Takashi Iwai
2025-08-27 9:19 ` [PATCH 04/19] ALSA: firewire: fireworks: " Takashi Iwai
2025-08-27 9:19 ` [PATCH 05/19] ALSA: firewire: motu: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 06/19] ALSA: firewire: oxfw: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 07/19] ALSA: firewire: tascam: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 08/19] ALSA: firewire: fireface: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 09/19] ALSA: firewire: isight: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 10/19] ALSA: firewire: lib: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 11/19] ALSA: firewire: bebob: Use guard() for spin locks Takashi Iwai
2025-08-27 9:20 ` [PATCH 12/19] ALSA: firewire: dice: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 13/19] ALSA: firewire: digi00x: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 14/19] ALSA: firewire: fireface: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 15/19] ALSA: firewire: fireworks: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 16/19] ALSA: firewire: motu: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 17/19] ALSA: firewire: oxfw: " Takashi Iwai
2025-08-27 9:20 ` [PATCH 18/19] ALSA: firewire: tascam: " Takashi Iwai
2025-08-27 9:20 ` Takashi Iwai [this message]
2025-08-28 12:56 ` [PATCH 00/19] ALSA: firewire: Use auto-cleanup macros Takashi Sakamoto
2025-08-28 13:23 ` 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=20250827092017.29014-20-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.