diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2015-12-07 15:05:32 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-12-08 15:31:14 -0500 |
commit | 30c2de77aedeb0f576356fe152e1e22c4806d239 (patch) | |
tree | cf249f034619485691b7aa0633389a34f4855e57 | |
parent | 74c831653309872b4a514cb27f456f20a7914173 (diff) | |
download | linux-30c2de77aedeb0f576356fe152e1e22c4806d239.tar.bz2 |
greybus: connection: bind protocol at init
Bind protocol at connection init.
This is an intermediate step in separating connection creation and
enabling.
Note that the protocol is currently still unbound when the connection is
destroyed.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
-rw-r--r-- | drivers/staging/greybus/connection.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index ae8cb6603a5e..38803604e603 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -13,6 +13,7 @@ static int gb_connection_bind_protocol(struct gb_connection *connection); +static int gb_connection_init(struct gb_connection *connection); static DEFINE_SPINLOCK(gb_connections_lock); @@ -192,9 +193,9 @@ gb_connection_create(struct gb_host_device *hd, int hd_cport_id, spin_unlock_irq(&gb_connections_lock); - retval = gb_connection_bind_protocol(connection); + retval = gb_connection_init(connection); if (retval) { - dev_err(&hd->dev, "%s: failed to bind protocol: %d\n", + dev_err(&hd->dev, "%s: failed to initialize connection: %d\n", connection->name, retval); gb_connection_destroy(connection); return NULL; @@ -396,9 +397,12 @@ static int gb_connection_protocol_get_version(struct gb_connection *connection) static int gb_connection_init(struct gb_connection *connection) { - struct gb_protocol *protocol = connection->protocol; int ret; + ret = gb_connection_bind_protocol(connection); + if (ret) + return ret; + ret = gb_connection_hd_cport_enable(connection); if (ret) return ret; @@ -420,7 +424,7 @@ static int gb_connection_init(struct gb_connection *connection) if (ret) goto err_disconnect; - ret = protocol->connection_init(connection); + ret = connection->protocol->connection_init(connection); if (ret) goto err_disconnect; @@ -527,7 +531,6 @@ EXPORT_SYMBOL_GPL(gb_connection_latency_tag_disable); static int gb_connection_bind_protocol(struct gb_connection *connection) { struct gb_protocol *protocol; - int ret; /* If we already have a protocol bound here, just return */ if (connection->protocol) @@ -545,12 +548,5 @@ static int gb_connection_bind_protocol(struct gb_connection *connection) } connection->protocol = protocol; - ret = gb_connection_init(connection); - if (ret) { - gb_protocol_put(protocol); - connection->protocol = NULL; - return ret; - } - return 0; } |