summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2015-09-17 13:17:25 +0200
committerGreg Kroah-Hartman <gregkh@google.com>2015-09-17 14:33:47 -0700
commit2846d3ed2e5608bcdb773cf308af7fabbfcb663e (patch)
tree8973f134ee829959e70c23026c368f17110b86e7 /drivers/staging/greybus/connection.c
parent9d7fc25b3c05a3330002560c19f0dfbfe83ea8a0 (diff)
downloadlinux-stable-2846d3ed2e5608bcdb773cf308af7fabbfcb663e.tar.gz
linux-stable-2846d3ed2e5608bcdb773cf308af7fabbfcb663e.tar.bz2
linux-stable-2846d3ed2e5608bcdb773cf308af7fabbfcb663e.zip
greybus: connection: add protocol-version helper
Add protocol-version to improve readability. 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.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index de5581267fce..91d1e477a6b6 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -412,9 +412,30 @@ gb_connection_control_disconnected(struct gb_connection *connection)
}
}
+/*
+ * Request protocol version supported by the module. We don't need to do
+ * this for SVC as that is initiated by the SVC.
+ */
+static int gb_connection_protocol_get_version(struct gb_connection *connection)
+{
+ struct gb_protocol *protocol = connection->protocol;
+ int ret;
+
+ if (protocol->flags & GB_PROTOCOL_SKIP_VERSION)
+ return 0;
+
+ ret = gb_protocol_get_version(connection);
+ if (ret) {
+ dev_err(&connection->dev,
+ "failed to get protocol version: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
static int gb_connection_init(struct gb_connection *connection)
{
- int cport_id = connection->intf_cport_id;
struct gb_protocol *protocol = connection->protocol;
int ret;
@@ -431,19 +452,9 @@ static int gb_connection_init(struct gb_connection *connection)
connection->state = GB_CONNECTION_STATE_ENABLED;
spin_unlock_irq(&connection->lock);
- /*
- * Request protocol version supported by the module. We don't need to do
- * this for SVC as that is initiated by the SVC.
- */
- if (!(protocol->flags & GB_PROTOCOL_SKIP_VERSION)) {
- ret = gb_protocol_get_version(connection);
- if (ret) {
- dev_err(&connection->dev,
- "Failed to get version CPort-%d (%d)\n",
- cport_id, ret);
- goto err_disconnect;
- }
- }
+ ret = gb_connection_protocol_get_version(connection);
+ if (ret)
+ goto err_disconnect;
ret = protocol->connection_init(connection);
if (ret)