summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-09-07 16:01:21 +0530
committerGreg Kroah-Hartman <gregkh@google.com>2015-09-14 21:19:46 -0700
commita1163fae63079f01c24d9c062b1e22e5ada89f91 (patch)
tree1a9ca617dfdd8f11471b0ccdaf281dcdeb4a9049 /drivers/staging/greybus/connection.c
parent4317f874f48d14fbd5b1d408336843dbe129ab3e (diff)
downloadlinux-stable-a1163fae63079f01c24d9c062b1e22e5ada89f91.tar.gz
linux-stable-a1163fae63079f01c24d9c062b1e22e5ada89f91.tar.bz2
linux-stable-a1163fae63079f01c24d9c062b1e22e5ada89f91.zip
greybus: connection: call gb_svc_connection_create() from gb_connection_init()
There are two operations which very much work together: - AP asks the SVC to create a connection between a cport of AP and a cport of module. - AP tells the module that the connection is created. Its better (logically) to do these two operations together and so call gb_svc_connection_create() from gb_connection_init() instead. Also check its return value properly. Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/connection.c')
-rw-r--r--drivers/staging/greybus/connection.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index c25e5705f865..973d841d8e91 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -258,14 +258,6 @@ gb_connection_create_range(struct greybus_host_device *hd,
spin_unlock_irq(&gb_connections_lock);
- if (hd_cport_id != GB_SVC_CPORT_ID) {
- gb_svc_connection_create(hd->svc,
- hd->endo->ap_intf_id, hd_cport_id,
- bundle->intf->interface_id, cport_id);
- if (hd->driver->connection_create)
- hd->driver->connection_create(connection);
- }
-
gb_connection_bind_protocol(connection);
if (!connection->protocol)
dev_warn(&connection->dev,
@@ -345,9 +337,30 @@ static void gb_connection_disconnected(struct gb_connection *connection)
static int gb_connection_init(struct gb_connection *connection)
{
int cport_id = connection->intf_cport_id;
+ struct greybus_host_device *hd = connection->hd;
int ret;
/*
+ * Request the SVC to create a connection from AP's cport to interface's
+ * cport.
+ */
+ if (connection->hd_cport_id != GB_SVC_CPORT_ID) {
+ ret = gb_svc_connection_create(hd->svc,
+ hd->endo->ap_intf_id, connection->hd_cport_id,
+ connection->bundle->intf->interface_id,
+ cport_id);
+ if (ret) {
+ dev_err(&connection->dev,
+ "%s: Failed to create svc connection (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+
+ if (hd->driver->connection_create)
+ hd->driver->connection_create(connection);
+ }
+
+ /*
* Inform Interface about Active CPorts. We don't need to do this
* operation for control cport.
*/