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>
This commit is contained in:
Johan Hovold 2015-12-07 15:05:32 +01:00 committed by Greg Kroah-Hartman
parent 74c8316533
commit 30c2de77ae
1 changed files with 8 additions and 12 deletions

View File

@ -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;
}