greybus: interface: Update gb_create_control_connection() to support SVC protocol
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 21 Jul 2015 12:14:17 +0000 (17:44 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 22 Jul 2015 17:12:41 +0000 (10:12 -0700)
We need to create bundle/connection for svc cport after the endo layout
and interface id is known to the AP. gb_create_control_connection() can
be reused for this, but it should be renamed to something more
appropriate, as its not about control-connection anymore.

Lets name it gb_create_bundle_connection().

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

index dfc31a0..6d61285 100644 (file)
@@ -70,19 +70,39 @@ struct device_type greybus_interface_type = {
 
 /*
  * Create kernel structures corresponding to a bundle and connection for
- * managing control CPort.
+ * managing control/svc CPort.
  */
-static int gb_create_control_connection(struct gb_interface *intf)
+int gb_create_bundle_connection(struct gb_interface *intf, u8 class)
 {
        struct gb_bundle *bundle;
+       u32 ida_start, ida_end;
+       u8 bundle_id, protocol_id;
+       u16 cport_id;
+
+       if (class == GREYBUS_CLASS_CONTROL) {
+               protocol_id = GREYBUS_PROTOCOL_CONTROL;
+               bundle_id = GB_CONTROL_BUNDLE_ID;
+               cport_id = GB_CONTROL_CPORT_ID;
+               ida_start = 0;
+               ida_end = CPORT_ID_MAX;
+       } else if (class == GREYBUS_CLASS_SVC) {
+               protocol_id = GREYBUS_PROTOCOL_SVC;
+               bundle_id = GB_SVC_BUNDLE_ID;
+               cport_id = GB_SVC_CPORT_ID;
+               ida_start = GB_SVC_CPORT_ID;
+               ida_end = GB_SVC_CPORT_ID + 1;
+       } else {
+               WARN_ON(1);
+               return -EINVAL;
+       }
 
-       bundle = gb_bundle_create(intf, GB_CONTROL_BUNDLE_ID,
-                                 GREYBUS_CLASS_CONTROL);
+       bundle = gb_bundle_create(intf, bundle_id, class);
        if (!bundle)
                return -EINVAL;
 
-       if (!gb_connection_create(bundle, GB_CONTROL_CPORT_ID,
-                                 GREYBUS_PROTOCOL_CONTROL))
+       if (!gb_connection_create_range(bundle->intf->hd, bundle, &bundle->dev,
+                                       cport_id, protocol_id, ida_start,
+                                       ida_end))
                return -EINVAL;
 
        return 0;
@@ -202,7 +222,7 @@ int gb_interface_init(struct gb_interface *intf, u8 device_id)
        intf->device_id = device_id;
 
        /* Establish control CPort connection */
-       ret = gb_create_control_connection(intf);
+       ret = gb_create_bundle_connection(intf, GREYBUS_CLASS_CONTROL);
        if (ret) {
                dev_err(&intf->dev, "Failed to create control CPort connection (%d)\n", ret);
                return ret;
index c2bcb92..04d330c 100644 (file)
@@ -56,5 +56,5 @@ int gb_interface_init(struct gb_interface *intf, u8 device_id);
 void gb_interface_remove(struct greybus_host_device *hd, u8 interface_id);
 void gb_interfaces_remove(struct greybus_host_device *hd);
 
-
+int gb_create_bundle_connection(struct gb_interface *intf, u8 class);
 #endif /* __INTERFACE_H */