diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2024-09-09 23:00:17 +0900 |
---|---|---|
committer | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2024-09-09 23:00:17 +0900 |
commit | e97fb38fa1404abef72bac7de2c5bf2bbab4d93b (patch) | |
tree | 9471d2dbdf0b4fe564f250effb59c1f949e33138 /drivers/firewire/core-iso.c | |
parent | 7b713929bbd80a400ceb90f398bffe58e5cc8fc8 (diff) | |
download | linux-e97fb38fa1404abef72bac7de2c5bf2bbab4d93b.tar.gz linux-e97fb38fa1404abef72bac7de2c5bf2bbab4d93b.tar.bz2 linux-e97fb38fa1404abef72bac7de2c5bf2bbab4d93b.zip |
firewire: core: move workqueue handler from 1394 OHCI driver to core function
In current implementation, the work item for isochronous context executes
the same procedure of fw_iso_context_flush_completions() internally. There
is a space to refactor the implementation.
This commit calls fw_iso_context_flush_completions() in the work item. It
obsoletes fw_iso_context_init_work(). It also obsoletes a pair of
disable_work_sync() and enable_work() since the usage of
test_and_set_bit_lock() mediates concurrent call already.
Link: https://lore.kernel.org/r/20240909140018.65289-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Diffstat (limited to 'drivers/firewire/core-iso.c')
-rw-r--r-- | drivers/firewire/core-iso.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index f2394f3ed194..9f41c78878ad 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c @@ -131,6 +131,13 @@ size_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t completed) return 0; } +static void flush_completions_work(struct work_struct *work) +{ + struct fw_iso_context *ctx = container_of(work, struct fw_iso_context, work); + + fw_iso_context_flush_completions(ctx); +} + struct fw_iso_context *fw_iso_context_create(struct fw_card *card, int type, int channel, int speed, size_t header_size, fw_iso_callback_t callback, void *callback_data) @@ -149,6 +156,7 @@ struct fw_iso_context *fw_iso_context_create(struct fw_card *card, ctx->header_size = header_size; ctx->callback.sc = callback; ctx->callback_data = callback_data; + INIT_WORK(&ctx->work, flush_completions_work); trace_isoc_outbound_allocate(ctx, channel, speed); trace_isoc_inbound_single_allocate(ctx, channel, header_size); @@ -218,29 +226,15 @@ EXPORT_SYMBOL(fw_iso_context_queue_flush); * to process the context asynchronously, fw_iso_context_schedule_flush_completions() is available * instead. * - * Context: Process context. May sleep due to disable_work_sync(). + * Context: Process context. */ int fw_iso_context_flush_completions(struct fw_iso_context *ctx) { - int err; - trace_isoc_outbound_flush_completions(ctx); trace_isoc_inbound_single_flush_completions(ctx); trace_isoc_inbound_multiple_flush_completions(ctx); - might_sleep(); - - // Avoid dead lock due to programming mistake. - if (WARN_ON_ONCE(current_work() == &ctx->work)) - return 0; - - disable_work_sync(&ctx->work); - - err = ctx->card->driver->flush_iso_completions(ctx); - - enable_work(&ctx->work); - - return err; + return ctx->card->driver->flush_iso_completions(ctx); } EXPORT_SYMBOL(fw_iso_context_flush_completions); |