]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ALSA: firewire: lib: Use guard() for spin locks
authorTakashi Iwai <tiwai@suse.de>
Thu, 28 Aug 2025 13:27:23 +0000 (15:27 +0200)
committerTakashi Iwai <tiwai@suse.de>
Sat, 30 Aug 2025 08:02:27 +0000 (10:02 +0200)
Clean up the code using guard() for spin locks.

Merely code refactoring, and no behavior change.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250828132802.9032-20-tiwai@suse.de
sound/firewire/fcp.c
sound/firewire/iso-resources.c

index df44dd5dc4b229785e3dac955105e4da27dbcccf..e60bfd0ee4accc036e54457e90064dd58a11f481 100644 (file)
@@ -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 @@ deferred:
                }
        }
 
-       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 = {
index b47ee029d688bbfaad9a70cb41aa38e45f0d16dc..4f63279225c513f106d2d4f6967a4d42469bfa6e 100644 (file)
@@ -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;