staging: vchiq_arm: pass vchiq instance to 'handle_to_service'
authorAdrien Thierry <athierry@redhat.com>
Wed, 18 May 2022 19:11:18 +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. This will
allow accessing the vchiq state through the vchiq instance instead of
through the global array.

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

index a5f0a75..3bcb893 100644 (file)
@@ -1059,7 +1059,7 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason,
        DEBUG_TRACE(SERVICE_CALLBACK_LINE);
 
        rcu_read_lock();
-       service = handle_to_service(handle);
+       service = handle_to_service(instance, handle);
        if (WARN_ON(!service)) {
                rcu_read_unlock();
                return VCHIQ_SUCCESS;
index d4fed18..be2ee84 100644 (file)
@@ -240,7 +240,7 @@ find_service_by_handle(struct vchiq_instance *instance, unsigned int handle)
        struct vchiq_service *service;
 
        rcu_read_lock();
-       service = handle_to_service(handle);
+       service = handle_to_service(instance, handle);
        if (service && service->srvstate != VCHIQ_SRVSTATE_FREE &&
            service->handle == handle &&
            kref_get_unless_zero(&service->ref_count)) {
@@ -281,7 +281,7 @@ find_service_for_instance(struct vchiq_instance *instance, unsigned int handle)
        struct vchiq_service *service;
 
        rcu_read_lock();
-       service = handle_to_service(handle);
+       service = handle_to_service(instance, handle);
        if (service && service->srvstate != VCHIQ_SRVSTATE_FREE &&
            service->handle == handle &&
            service->instance == instance &&
@@ -302,7 +302,7 @@ find_closed_service_for_instance(struct vchiq_instance *instance, unsigned int h
        struct vchiq_service *service;
 
        rcu_read_lock();
-       service = handle_to_service(handle);
+       service = handle_to_service(instance, handle);
        if (service &&
            (service->srvstate == VCHIQ_SRVSTATE_FREE ||
             service->srvstate == VCHIQ_SRVSTATE_CLOSED) &&
@@ -404,7 +404,7 @@ vchiq_get_client_id(struct vchiq_instance *instance, unsigned int handle)
        int id;
 
        rcu_read_lock();
-       service = handle_to_service(handle);
+       service = handle_to_service(instance, handle);
        id = service ? service->client_id : 0;
        rcu_read_unlock();
        return id;
@@ -417,7 +417,7 @@ vchiq_get_service_userdata(struct vchiq_instance *instance, unsigned int handle)
        struct vchiq_service *service;
 
        rcu_read_lock();
-       service = handle_to_service(handle);
+       service = handle_to_service(instance, handle);
        userdata = service ? service->base.userdata : NULL;
        rcu_read_unlock();
        return userdata;
index c08d1f8..3eb70d6 100644 (file)
@@ -509,7 +509,7 @@ request_poll(struct vchiq_state *state, struct vchiq_service *service,
             int poll_type);
 
 static inline struct vchiq_service *
-handle_to_service(unsigned int handle)
+handle_to_service(struct vchiq_instance *instance, unsigned int handle)
 {
        int idx = handle & (VCHIQ_MAX_SERVICES - 1);
        struct vchiq_state *state = vchiq_states[(handle / VCHIQ_MAX_SERVICES) &