]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firewire: core: add function variants for isochronous context creation
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 17 Jan 2026 14:28:14 +0000 (23:28 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 18 Jan 2026 08:18:48 +0000 (17:18 +0900)
The fw_iso_callback union was added by a commit ebe4560ed5c ("firewire:
Remove function callback casts") to remove function pointer cast.

That change affected the cdev layer of the core code, but it is more
convenient for fw_iso_context_create() to accept the union directly.

This commit renames and changes the existing function to take the union
argument, and add static inline wrapper functions as variants.

Link: https://lore.kernel.org/r/20260117142823.440811-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-cdev.c
drivers/firewire/core-iso.c
drivers/firewire/core.h
include/linux/firewire.h

index bb4d0f938f5b1243ac3fe4690e16de37a217e339..c26bea2532088696d2fbd5586c07dd93893728e5 100644 (file)
@@ -1026,25 +1026,10 @@ static enum dma_data_direction iso_dma_direction(struct fw_iso_context *context)
                        return DMA_FROM_DEVICE;
 }
 
-static struct fw_iso_context *fw_iso_mc_context_create(struct fw_card *card,
-                                               fw_iso_mc_callback_t callback,
-                                               void *callback_data)
-{
-       struct fw_iso_context *ctx;
-
-       ctx = fw_iso_context_create(card, FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL,
-                                   0, 0, 0, NULL, callback_data);
-       if (!IS_ERR(ctx))
-               ctx->callback.mc = callback;
-
-       return ctx;
-}
-
 static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
 {
        struct fw_cdev_create_iso_context *a = &arg->create_iso_context;
        struct fw_iso_context *context;
-       union fw_iso_callback cb;
        int ret;
 
        BUILD_BUG_ON(FW_CDEV_ISO_CONTEXT_TRANSMIT != FW_ISO_CONTEXT_TRANSMIT ||
@@ -1056,20 +1041,15 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
        case FW_ISO_CONTEXT_TRANSMIT:
                if (a->speed > SCODE_3200 || a->channel > 63)
                        return -EINVAL;
-
-               cb.sc = iso_callback;
                break;
 
        case FW_ISO_CONTEXT_RECEIVE:
                if (a->header_size < 4 || (a->header_size & 3) ||
                    a->channel > 63)
                        return -EINVAL;
-
-               cb.sc = iso_callback;
                break;
 
        case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
-               cb.mc = iso_mc_callback;
                break;
 
        default:
@@ -1077,12 +1057,10 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
        }
 
        if (a->type == FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL)
-               context = fw_iso_mc_context_create(client->device->card, cb.mc,
-                                                  client);
+               context = fw_iso_mc_context_create(client->device->card, iso_mc_callback, client);
        else
-               context = fw_iso_context_create(client->device->card, a->type,
-                                               a->channel, a->speed,
-                                               a->header_size, cb.sc, client);
+               context = fw_iso_context_create(client->device->card, a->type, a->channel, a->speed,
+                                               a->header_size, iso_callback, client);
        if (IS_ERR(context))
                return PTR_ERR(context);
        if (client->version < FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW)
index 3f36243ec0c1183c2e5001ff543972bab78be20f..d9b8896c8ce145f47baa2584e58260c356d6a0b3 100644 (file)
@@ -137,9 +137,8 @@ size_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t completed)
        return 0;
 }
 
-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)
+struct fw_iso_context *__fw_iso_context_create(struct fw_card *card, int type, int channel,
+               int speed, size_t header_size, union fw_iso_callback callback, void *callback_data)
 {
        struct fw_iso_context *ctx;
 
@@ -153,7 +152,7 @@ struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
        ctx->channel = channel;
        ctx->speed = speed;
        ctx->header_size = header_size;
-       ctx->callback.sc = callback;
+       ctx->callback = callback;
        ctx->callback_data = callback_data;
 
        trace_isoc_outbound_allocate(ctx, channel, speed);
@@ -162,7 +161,7 @@ struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
 
        return ctx;
 }
-EXPORT_SYMBOL(fw_iso_context_create);
+EXPORT_SYMBOL(__fw_iso_context_create);
 
 void fw_iso_context_destroy(struct fw_iso_context *ctx)
 {
index 26868f00713115994683523945ebcb7bab773e92..e0ae948605e16d8159e6ae421e86a85813378642 100644 (file)
@@ -173,6 +173,15 @@ static inline void fw_iso_context_init_work(struct fw_iso_context *ctx, work_fun
        INIT_WORK(&ctx->work, func);
 }
 
+static inline struct fw_iso_context *fw_iso_mc_context_create(struct fw_card *card,
+               fw_iso_mc_callback_t callback, void *callback_data)
+{
+       union fw_iso_callback cb = { .mc = callback };
+
+       return __fw_iso_context_create(card, FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL, 0, 0, 0, cb,
+                                      callback_data);
+}
+
 
 /* -topology */
 
index 09c8484f743050857b6ad133d969682504040d54..68161b8a8a58d725178e4b476676d6bc921d707f 100644 (file)
@@ -558,9 +558,8 @@ struct fw_iso_context {
        void *callback_data;
 };
 
-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);
+struct fw_iso_context *__fw_iso_context_create(struct fw_card *card, int type, int channel,
+               int speed, size_t header_size, union fw_iso_callback callback, void *callback_data);
 int fw_iso_context_set_channels(struct fw_iso_context *ctx, u64 *channels);
 int fw_iso_context_queue(struct fw_iso_context *ctx,
                         struct fw_iso_packet *packet,
@@ -569,6 +568,15 @@ int fw_iso_context_queue(struct fw_iso_context *ctx,
 void fw_iso_context_queue_flush(struct fw_iso_context *ctx);
 int fw_iso_context_flush_completions(struct fw_iso_context *ctx);
 
+static inline 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)
+{
+       union fw_iso_callback cb = { .sc = callback };
+
+       return __fw_iso_context_create(card, type, channel, speed, header_size, cb, callback_data);
+}
+
 /**
  * fw_iso_context_schedule_flush_completions() - schedule work item to process isochronous context.
  * @ctx: the isochronous context