From 8d7a712ca86b4da7220b8c3da37f118fed3e0bb2 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 17 Sep 2015 13:17:22 +0200 Subject: [PATCH] greybus: connection: clean up init error paths Clearly mark error-path labels as such and clean up control flow. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/connection.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 8abac19f0c43..5b8aa04a9f15 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -405,7 +405,7 @@ static int gb_connection_init(struct gb_connection *connection) dev_err(&connection->dev, "Failed to connect CPort-%d (%d)\n", cport_id, ret); - goto svc_destroy; + goto err_svc_destroy; } } @@ -424,21 +424,23 @@ static int gb_connection_init(struct gb_connection *connection) dev_err(&connection->dev, "Failed to get version CPort-%d (%d)\n", cport_id, ret); - goto disconnect; + goto err_disconnect; } } ret = protocol->connection_init(connection); - if (!ret) - return 0; + if (ret) + goto err_disconnect; + + return 0; -disconnect: +err_disconnect: spin_lock_irq(&connection->lock); connection->state = GB_CONNECTION_STATE_ERROR; spin_unlock_irq(&connection->lock); gb_connection_disconnected(connection); -svc_destroy: +err_svc_destroy: gb_connection_svc_connection_destroy(connection); return ret; -- 2.20.1