Skip to content

Commit cf123b0

Browse files
committed
firewire: core: use guard macro to maintain isochronous context for userspace client
The core function allows one isochronous contexts per userspace client. The concurrent access to the context is protected by spinlock in the instance of client. This commit uses guard macro to maintain the spinlock. Link: https://lore.kernel.org/r/20240805085408.251763-12-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent d3816b8 commit cf123b0

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

drivers/firewire/core-cdev.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,10 +1062,10 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
10621062
if (client->version < FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW)
10631063
context->drop_overflow_headers = true;
10641064

1065-
/* We only support one context at this time. */
1066-
spin_lock_irq(&client->lock);
1065+
// We only support one context at this time.
1066+
guard(spinlock_irq)(&client->lock);
1067+
10671068
if (client->iso_context != NULL) {
1068-
spin_unlock_irq(&client->lock);
10691069
fw_iso_context_destroy(context);
10701070

10711071
return -EBUSY;
@@ -1075,7 +1075,6 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
10751075
client->device->card,
10761076
iso_dma_direction(context));
10771077
if (ret < 0) {
1078-
spin_unlock_irq(&client->lock);
10791078
fw_iso_context_destroy(context);
10801079

10811080
return ret;
@@ -1084,7 +1083,6 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
10841083
}
10851084
client->iso_closure = a->closure;
10861085
client->iso_context = context;
1087-
spin_unlock_irq(&client->lock);
10881086

10891087
a->handle = 0;
10901088

@@ -1806,16 +1804,15 @@ static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma)
18061804
if (ret < 0)
18071805
return ret;
18081806

1809-
spin_lock_irq(&client->lock);
1810-
if (client->iso_context) {
1811-
ret = fw_iso_buffer_map_dma(&client->buffer,
1812-
client->device->card,
1813-
iso_dma_direction(client->iso_context));
1814-
client->buffer_is_mapped = (ret == 0);
1807+
scoped_guard(spinlock_irq, &client->lock) {
1808+
if (client->iso_context) {
1809+
ret = fw_iso_buffer_map_dma(&client->buffer, client->device->card,
1810+
iso_dma_direction(client->iso_context));
1811+
if (ret < 0)
1812+
goto fail;
1813+
client->buffer_is_mapped = true;
1814+
}
18151815
}
1816-
spin_unlock_irq(&client->lock);
1817-
if (ret < 0)
1818-
goto fail;
18191816

18201817
ret = vm_map_pages_zero(vma, client->buffer.pages,
18211818
client->buffer.page_count);

0 commit comments

Comments
 (0)