]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: svc: save pointer to struct gb_svc in struct gb_interface
authorViresh Kumar <viresh.kumar@linaro.org>
Fri, 3 Jul 2015 11:30:30 +0000 (17:00 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 8 Jul 2015 18:44:25 +0000 (11:44 -0700)
Its another special protocol (just like control protocol) and is
required to be accessed from other files, lets save a pointer to it in
interface structure.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/interface.h
drivers/staging/greybus/svc.c
drivers/staging/greybus/svc.h

index 86eb8947a3d634c3203eb1754b836be4cbb0f5c3..c2bcb92dacdb6946462e184e56b67d183aeaa2a3 100644 (file)
@@ -14,6 +14,7 @@
 struct gb_interface {
        struct device dev;
        struct gb_control *control;
+       struct gb_svc *svc;
 
        struct list_head bundles;
        struct list_head links; /* greybus_host_device->interfaces */
index 8a5a9b7c375d81b735d803791ba4496958c9473c..ce789c909c5fd31119a5415e7134980c67004320 100644 (file)
@@ -9,12 +9,6 @@
 
 #include "greybus.h"
 
-struct gb_svc {
-       struct gb_connection    *connection;
-       u8                      version_major;
-       u8                      version_minor;
-};
-
 /* Define get_version() routine */
 define_get_version(gb_svc, SVC);
 
@@ -217,6 +211,9 @@ static int gb_svc_connection_init(struct gb_connection *connection)
        if (ret)
                kfree(svc);
 
+       /* Set interface's svc connection */
+       connection->bundle->intf->svc = svc;
+
        return ret;
 }
 
@@ -224,9 +221,11 @@ static void gb_svc_connection_exit(struct gb_connection *connection)
 {
        struct gb_svc *svc = connection->private;
 
-       if (!svc)
+       if (WARN_ON(connection->bundle->intf->svc != svc))
                return;
 
+       connection->bundle->intf->svc = NULL;
+
        kfree(svc);
 }
 
index b039aea4c4097899257003a509c00a8b640a0546..ebabe5ff7c6d2c910b566e51c15758cc88031fb5 100644 (file)
 #ifndef __SVC_H
 #define __SVC_H
 
-struct gb_svc;
+struct gb_svc {
+       struct gb_connection    *connection;
+       u8                      version_major;
+       u8                      version_minor;
+};
+
 
 int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id);
 int gb_svc_intf_reset(struct gb_svc *svc, u8 intf_id);