From 1b7a9cd5a54536af5a97738097780369779c62d9 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Mon, 7 Sep 2015 16:01:22 +0530 Subject: [PATCH] greybus: connection: destroy svc connection on connection exit or errors While initializing a connection, the AP requests the SVC to create a connection between a cport on AP and a cport on the Module. The opposite of that is missing, when connection is destroyed or if errors occur after creating the connection. Fix it. Reviewed-by: Johan Hovold Signed-off-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/connection.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 973d841d8e91..de3962ab07bc 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -312,6 +312,19 @@ static void gb_connection_cancel_operations(struct gb_connection *connection, spin_unlock_irq(&connection->lock); } +static void +gb_connection_svc_connection_destroy(struct gb_connection *connection) +{ + if (connection->hd_cport_id == GB_SVC_CPORT_ID) + return; + + gb_svc_connection_destroy(connection->hd->svc, + connection->hd->endo->ap_intf_id, + connection->hd_cport_id, + connection->bundle->intf->interface_id, + connection->intf_cport_id); +} + static void gb_connection_disconnected(struct gb_connection *connection) { struct gb_control *control; @@ -373,7 +386,7 @@ static int gb_connection_init(struct gb_connection *connection) dev_err(&connection->dev, "Failed to connect CPort-%d (%d)\n", cport_id, ret); - return ret; + goto svc_destroy; } } @@ -406,6 +419,9 @@ disconnect: spin_unlock_irq(&connection->lock); gb_connection_disconnected(connection); +svc_destroy: + gb_connection_svc_connection_destroy(connection); + return ret; } @@ -426,6 +442,7 @@ static void gb_connection_exit(struct gb_connection *connection) connection->protocol->connection_exit(connection); gb_connection_disconnected(connection); + gb_connection_svc_connection_destroy(connection); } /* -- 2.20.1