From 9612f2bcd466364a244b8c2a012de69abd8fb258 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Tue, 28 Jul 2015 07:28:42 +0530 Subject: [PATCH] greybus: initialize svc connection while creating hd 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/core.c | 15 +++++++++++++++ drivers/staging/greybus/es1.c | 6 ------ drivers/staging/greybus/es2.c | 6 ------ drivers/staging/greybus/svc.c | 1 - 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 7d5cd99..9f105fb 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -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); diff --git a/drivers/staging/greybus/es1.c b/drivers/staging/greybus/es1.c index 5418f46..c1fab37 100644 --- a/drivers/staging/greybus/es1.c +++ b/drivers/staging/greybus/es1.c @@ -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; diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c index d2c054a..558345c 100644 --- a/drivers/staging/greybus/es2.c +++ b/drivers/staging/greybus/es2.c @@ -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; diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c index b94a84a..784b770 100644 --- a/drivers/staging/greybus/svc.c +++ b/drivers/staging/greybus/svc.c @@ -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 -- 2.7.4