greybus: initialize svc connection while creating hd
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 28 Jul 2015 01:58:42 +0000 (07:28 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 28 Jul 2015 21:47:03 +0000 (14:47 -0700)
Its really part of initializing the host device and is required for
every 'hd' that is created. Lets move the call to do basic
initialization of svc connection to greybus_create_hd().

Also add a comment to specify why we need to do it that early.

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

index 7d5cd99157f5730b1cf95ccdefd5507943596ad6..9f105fb12ede7db9e80c6a57af4dc68482b04b23 100644 (file)
@@ -208,6 +208,21 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
        ida_init(&hd->cport_id_map);
        hd->buffer_size_max = buffer_size_max;
 
+       /*
+        * Initialize AP's SVC protocol connection:
+        *
+        * This is required as part of early initialization of the host device
+        * as we need this connection in order to start any kind of message
+        * exchange between the AP and the SVC. SVC will start with a
+        * 'get-version' request followed by a 'svc-hello' message and at that
+        * time we will create a fully initialized svc-connection, as we need
+        * endo-id and AP's interface id for that.
+        */
+       if (!gb_ap_svc_connection_create(hd)) {
+               kref_put_mutex(&hd->kref, free_hd, &hd_mutex);
+               return ERR_PTR(-ENOMEM);
+       }
+
        return hd;
 }
 EXPORT_SYMBOL_GPL(greybus_create_hd);
index 5418f4675ec13587d16929151efbc8c8a104c82e..c1fab375bb0b2eb191c49bc01e3238532990f417 100644 (file)
@@ -563,12 +563,6 @@ static int ap_probe(struct usb_interface *interface,
                return PTR_ERR(hd);
        }
 
-       /* Initialize AP's greybus interface */
-       if (!gb_ap_svc_connection_create(hd)) {
-               retval = -EINVAL;
-               goto error;
-       }
-
        es1 = hd_to_es1(hd);
        es1->hd = hd;
        es1->usb_intf = interface;
index d2c054a2ec0e89feab3dbc607746d0d59e5c28a6..558345cd80af4385ae40042cd3d2c3c7df467aaa 100644 (file)
@@ -663,12 +663,6 @@ static int ap_probe(struct usb_interface *interface,
                return PTR_ERR(hd);
        }
 
-       /* Initialize AP's greybus interface */
-       if (!gb_ap_svc_connection_create(hd)) {
-               retval = -EINVAL;
-               goto error;
-       }
-
        es1 = hd_to_es1(hd);
        es1->hd = hd;
        es1->usb_intf = interface;
index b94a84aca0d8369828d069bf3917dfd97c96532b..784b7709b432210a109f3f8acac7b1759a7e0d67 100644 (file)
@@ -40,7 +40,6 @@ gb_ap_svc_connection_create(struct greybus_host_device *hd)
 
        return connection;
 }
-EXPORT_SYMBOL_GPL(gb_ap_svc_connection_create);
 
 /*
  * We know endo-type and AP's interface id now, lets create a proper svc