staging: vchiq_arm: pass vchiq instance to service callbacks
authorAdrien Thierry <athierry@redhat.com>
Wed, 18 May 2022 19:11:14 +0000 (15:11 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Jun 2022 06:03:46 +0000 (08:03 +0200)
In order to remove the 'vchiq_states' global array, we need to pass the
vchiq_instance reference to the 'handle_to_service' function, as well as
to all functions that call 'handle_to_service'. This will allow
accessing the vchiq state through the vchiq instance instead of through
the global array.

'handle_to_service' is called by 'service_callback'. Therefore, pass the
vchiq instance reference to 'service_callback'. This also requires
adding the vchiq instance reference to the service callbacks prototype,
and update all other callbacks accordingly.

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Adrien Thierry <athierry@redhat.com>
Link: https://lore.kernel.org/r/20220518191126.60396-4-athierry@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c

index 701abe4..c32c8c9 100644 (file)
@@ -89,7 +89,8 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio_instance *instance,
        return bcm2835_audio_send_msg(instance, &m, wait);
 }
 
-static enum vchiq_status audio_vchi_callback(enum vchiq_reason reason,
+static enum vchiq_status audio_vchi_callback(struct vchiq_instance *vchiq_instance,
+                                            enum vchiq_reason reason,
                                             struct vchiq_header *header,
                                             unsigned int handle, void *userdata)
 {
index 715f02e..97537d3 100644 (file)
@@ -53,9 +53,12 @@ struct vchiq_element {
        unsigned int size;
 };
 
+struct vchiq_instance;
+
 struct vchiq_service_base {
        int fourcc;
-       enum vchiq_status (*callback)(enum vchiq_reason reason,
+       enum vchiq_status (*callback)(struct vchiq_instance *instance,
+                                     enum vchiq_reason reason,
                                      struct vchiq_header *header,
                                      unsigned int handle,
                                      void *bulk_userdata);
@@ -71,7 +74,8 @@ struct vchiq_completion_data_kernel {
 
 struct vchiq_service_params_kernel {
        int fourcc;
-       enum vchiq_status (*callback)(enum vchiq_reason reason,
+       enum vchiq_status (*callback)(struct vchiq_instance *instance,
+                                     enum vchiq_reason reason,
                                      struct vchiq_header *header,
                                      unsigned int handle,
                                      void *bulk_userdata);
index 3b447c6..ffb2429 100644 (file)
@@ -1041,8 +1041,8 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason,
 }
 
 enum vchiq_status
-service_callback(enum vchiq_reason reason, struct vchiq_header *header,
-                unsigned int handle, void *bulk_userdata)
+service_callback(struct vchiq_instance *instance, enum vchiq_reason reason,
+                struct vchiq_header *header, unsigned int handle, void *bulk_userdata)
 {
        /*
         * How do we ensure the callback goes to the right client?
@@ -1052,7 +1052,6 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header,
         */
        struct user_service *user_service;
        struct vchiq_service *service;
-       struct vchiq_instance *instance;
        bool skip_completion = false;
 
        DEBUG_INITIALISE(g_state.local);
@@ -1067,7 +1066,6 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header,
        }
 
        user_service = (struct user_service *)service->base.userdata;
-       instance = user_service->instance;
 
        if (!instance || instance->closing) {
                rcu_read_unlock();
@@ -1313,7 +1311,8 @@ vchiq_get_state(void)
  */
 
 static enum vchiq_status
-vchiq_keepalive_vchiq_callback(enum vchiq_reason reason,
+vchiq_keepalive_vchiq_callback(struct vchiq_instance *instance,
+                              enum vchiq_reason reason,
                               struct vchiq_header *header,
                               unsigned int service_user, void *bulk_user)
 {
index 2aa46b1..f671c39 100644 (file)
@@ -138,8 +138,8 @@ static inline int vchiq_register_chrdev(struct device *parent) { return 0; }
 #endif /* IS_ENABLED(CONFIG_VCHIQ_CDEV) */
 
 extern enum vchiq_status
-service_callback(enum vchiq_reason reason, struct vchiq_header *header,
-                unsigned int handle, void *bulk_userdata);
+service_callback(struct vchiq_instance *vchiq_instance, enum vchiq_reason reason,
+                struct vchiq_header *header, unsigned int handle, void *bulk_userdata);
 
 extern void
 free_bulk_waiter(struct vchiq_instance *instance);
index 04eec18..547af55 100644 (file)
@@ -466,7 +466,8 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason,
        vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %pK, %pK)",
                        service->state->id, service->localport, reason_names[reason],
                        header, bulk_userdata);
-       status = service->base.callback(reason, header, service->handle, bulk_userdata);
+       status = service->base.callback(service->instance, reason, header, service->handle,
+                                       bulk_userdata);
        if (status == VCHIQ_ERROR) {
                vchiq_log_warning(vchiq_core_log_level,
                                  "%d: ignoring ERROR from callback to service %x",
index 145021a..55f290b 100644 (file)
@@ -548,7 +548,8 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance,
 }
 
 /* incoming event service callback */
-static enum vchiq_status service_callback(enum vchiq_reason reason,
+static enum vchiq_status service_callback(struct vchiq_instance *vchiq_instance,
+                                         enum vchiq_reason reason,
                                          struct vchiq_header *header,
                                          unsigned int handle, void *bulk_ctx)
 {