Skip to content

Commit b954544

Browse files
committed
firewire: core: use guard macro to maintain list of receivers for phy configuration packets
The core function maintains clients to receive phy configuration packets by list in the instance of fw_card. The concurrent access to the list is protected by spinlock in the instance. This commit uses guard macro to maintain the list. Link: https://lore.kernel.org/r/20240805085408.251763-13-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent cf123b0 commit b954544

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

drivers/firewire/core-cdev.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,26 +1659,22 @@ static int ioctl_receive_phy_packets(struct client *client, union ioctl_arg *arg
16591659
if (!client->device->is_local)
16601660
return -ENOSYS;
16611661

1662-
spin_lock_irq(&card->lock);
1662+
guard(spinlock_irq)(&card->lock);
16631663

16641664
list_move_tail(&client->phy_receiver_link, &card->phy_receiver_list);
16651665
client->phy_receiver_closure = a->closure;
16661666

1667-
spin_unlock_irq(&card->lock);
1668-
16691667
return 0;
16701668
}
16711669

16721670
void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p)
16731671
{
16741672
struct client *client;
1675-
struct inbound_phy_packet_event *e;
1676-
unsigned long flags;
16771673

1678-
spin_lock_irqsave(&card->lock, flags);
1674+
guard(spinlock_irqsave)(&card->lock);
16791675

16801676
list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) {
1681-
e = kmalloc(sizeof(*e) + 8, GFP_ATOMIC);
1677+
struct inbound_phy_packet_event *e = kmalloc(sizeof(*e) + 8, GFP_ATOMIC);
16821678
if (e == NULL)
16831679
break;
16841680

@@ -1706,8 +1702,6 @@ void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p)
17061702
queue_event(client, &e->event, &e->phy_packet, sizeof(*pp) + 8, NULL, 0);
17071703
}
17081704
}
1709-
1710-
spin_unlock_irqrestore(&card->lock, flags);
17111705
}
17121706

17131707
static int (* const ioctl_handlers[])(struct client *, union ioctl_arg *) = {
@@ -1855,9 +1849,8 @@ static int fw_device_op_release(struct inode *inode, struct file *file)
18551849
struct client *client = file->private_data;
18561850
struct event *event, *next_event;
18571851

1858-
spin_lock_irq(&client->device->card->lock);
1859-
list_del(&client->phy_receiver_link);
1860-
spin_unlock_irq(&client->device->card->lock);
1852+
scoped_guard(spinlock_irq, &client->device->card->lock)
1853+
list_del(&client->phy_receiver_link);
18611854

18621855
scoped_guard(mutex, &client->device->client_list_mutex)
18631856
list_del(&client->link);

0 commit comments

Comments
 (0)