From: Viresh Kumar Date: Tue, 11 Aug 2015 02:05:56 +0000 (+0530) Subject: greybus: connection: disconnect connection on failures during initialization X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=186906590280c907ee497ed5e48bb94926d7b960;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git greybus: connection: disconnect connection on failures during initialization Its possible for connection_init() to fail, in such cases the disconnected event must be sent to the module. It is missing currently, fix it. Signed-off-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 3b553e682359..7a5840bb8473 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -330,6 +330,27 @@ void gb_connection_destroy(struct gb_connection *connection) device_unregister(&connection->dev); } +static void gb_connection_disconnected(struct gb_connection *connection) +{ + struct gb_control *control; + int cport_id = connection->intf_cport_id; + int ret; + + /* + * Inform Interface about In-active CPorts. We don't need to do this + * operation for control cport. + */ + if (cport_id == GB_CONTROL_CPORT_ID) + return; + + control = connection->bundle->intf->control; + + ret = gb_control_disconnected_operation(control, cport_id); + if (ret) + dev_warn(&connection->dev, + "Failed to disconnect CPort-%d (%d)\n", cport_id, ret); +} + int gb_connection_init(struct gb_connection *connection) { int cport_id = connection->intf_cport_id; @@ -366,15 +387,18 @@ int gb_connection_init(struct gb_connection *connection) spin_lock_irq(&connection->lock); connection->state = GB_CONNECTION_STATE_ERROR; spin_unlock_irq(&connection->lock); + goto disconnect; } + return 0; + +disconnect: + gb_connection_disconnected(connection); return ret; } void gb_connection_exit(struct gb_connection *connection) { - int cport_id = connection->intf_cport_id; - if (!connection->protocol) { dev_warn(&connection->dev, "exit without protocol.\n"); return; @@ -391,21 +415,7 @@ void gb_connection_exit(struct gb_connection *connection) gb_connection_cancel_operations(connection, -ESHUTDOWN); connection->protocol->connection_exit(connection); - - /* - * Inform Interface about In-active CPorts. We don't need to do this - * operation for control cport. - */ - if (cport_id != GB_CONTROL_CPORT_ID) { - struct gb_control *control = connection->bundle->intf->control; - int ret; - - ret = gb_control_disconnected_operation(control, cport_id); - if (ret) - dev_warn(&connection->dev, - "Failed to disconnect CPort-%d (%d)\n", - cport_id, ret); - } + gb_connection_disconnected(connection); } void gb_hd_connections_exit(struct greybus_host_device *hd)