From: Johan Hovold Date: Mon, 7 Dec 2015 14:05:32 +0000 (+0100) Subject: greybus: connection: bind protocol at init X-Git-Tag: Ubuntu-5.13.0-19.19~14927^2~378^2~21^2~950 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=30c2de77aedeb0f576356fe152e1e22c4806d239;p=mirror_ubuntu-jammy-kernel.git 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 Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- 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; }