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);
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;
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;
if (ret)
goto err_disconnect;
- ret = protocol->connection_init(connection);
+ ret = connection->protocol->connection_init(connection);
if (ret)
goto err_disconnect;
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)
}
connection->protocol = protocol;
- ret = gb_connection_init(connection);
- if (ret) {
- gb_protocol_put(protocol);
- connection->protocol = NULL;
- return ret;
- }
-
return 0;
}