diff options
author | Johan Hovold | 2015-09-17 13:17:21 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2015-09-17 23:33:07 +0200 |
commit | a95c258c6fe6b4929f52398d1b6cd5432efe2c86 (patch) | |
tree | edcc36f0efe63c5f09aa04f755b72710675f2c98 /drivers/staging/greybus/connection.c | |
parent | greybus: es{1,2}: remove obselete define (diff) | |
download | kernel-qcow2-linux-a95c258c6fe6b4929f52398d1b6cd5432efe2c86.tar.gz kernel-qcow2-linux-a95c258c6fe6b4929f52398d1b6cd5432efe2c86.tar.xz kernel-qcow2-linux-a95c258c6fe6b4929f52398d1b6cd5432efe2c86.zip |
greybus: connection: clean up svc-connection creation
Move SVC-connection creation to its own helper.
Note that the connection_create host-driver callback is really
unrelated to the SVC connection, and will be removed by a later patch.
It is is included for now as the connection_destroy callback is
currently made from the SVC-connection-destroy helper.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/connection.c')
-rw-r--r-- | drivers/staging/greybus/connection.c | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index dc45298ad099..8abac19f0c43 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -321,6 +321,37 @@ static void gb_connection_cancel_operations(struct gb_connection *connection, spin_unlock_irq(&connection->lock); } +/* + * Request the SVC to create a connection from AP's cport to interface's + * cport. + */ +static int +gb_connection_svc_connection_create(struct gb_connection *connection) +{ + struct greybus_host_device *hd = connection->hd; + struct gb_protocol *protocol = connection->protocol; + int ret; + + if (protocol->flags & GB_PROTOCOL_SKIP_SVC_CONNECTION) + return 0; + + ret = gb_svc_connection_create(hd->svc, + hd->endo->ap_intf_id, + connection->hd_cport_id, + connection->bundle->intf->interface_id, + connection->intf_cport_id); + if (ret) { + dev_err(&connection->dev, + "failed to create svc connection: %d\n", ret); + return ret; + } + + if (hd->driver->connection_create) + hd->driver->connection_create(connection); + + return 0; +} + static void gb_connection_svc_connection_destroy(struct gb_connection *connection) { @@ -358,29 +389,13 @@ 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; struct gb_protocol *protocol = connection->protocol; int ret; - /* - * Request the SVC to create a connection from AP's cport to interface's - * cport. - */ - if (!(protocol->flags & GB_PROTOCOL_SKIP_SVC_CONNECTION)) { - 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; - } + ret = gb_connection_svc_connection_create(connection); + if (ret) + return ret; - if (hd->driver->connection_create) - hd->driver->connection_create(connection); - } /* Inform Interface about active CPorts */ if (!(protocol->flags & GB_PROTOCOL_SKIP_CONTROL_CONNECTED)) { struct gb_control *control = connection->bundle->intf->control; |