diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-08-11 07:35:59 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-08-11 17:53:43 -0700 |
commit | 7ba26a8ced4a391133aa899a61647154d8d4d24c (patch) | |
tree | 3e1f039573b1ab4cecaefd739acd31efd56a345f /drivers/staging/greybus/connection.c | |
parent | d653f4b19163aa9f3a8046bd6e895b8615856d11 (diff) | |
download | linux-stable-7ba26a8ced4a391133aa899a61647154d8d4d24c.tar.gz linux-stable-7ba26a8ced4a391133aa899a61647154d8d4d24c.tar.bz2 linux-stable-7ba26a8ced4a391133aa899a61647154d8d4d24c.zip |
greybus: connection: request protocol version before initializing connection
This can (should) be done from a common place as its required for most
of the protocols. Do it.
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.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 7a5840bb8473..b1f1df81be50 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -382,17 +382,34 @@ int gb_connection_init(struct gb_connection *connection) connection->state = GB_CONNECTION_STATE_ENABLED; spin_unlock_irq(&connection->lock); - ret = connection->protocol->connection_init(connection); - if (ret) { - spin_lock_irq(&connection->lock); - connection->state = GB_CONNECTION_STATE_ERROR; - spin_unlock_irq(&connection->lock); - goto disconnect; + /* + * Request protocol version supported by the module. We don't need to do + * this for SVC as that is initiated by the SVC. + */ + if (connection->hd_cport_id != GB_SVC_CPORT_ID) { + struct gb_protocol_version_response response; + + ret = gb_protocol_get_version(connection, + GB_REQUEST_TYPE_PROTOCOL_VERSION, + NULL, 0, &response, + connection->protocol->major); + if (ret) { + dev_err(&connection->dev, + "Failed to get version CPort-%d (%d)\n", + cport_id, ret); + goto disconnect; + } } - return 0; + ret = connection->protocol->connection_init(connection); + if (!ret) + return 0; disconnect: + spin_lock_irq(&connection->lock); + connection->state = GB_CONNECTION_STATE_ERROR; + spin_unlock_irq(&connection->lock); + gb_connection_disconnected(connection); return ret; } |