Commit 1b7a9cd5 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

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: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent a1163fae
......@@ -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 @@ static int gb_connection_init(struct gb_connection *connection)
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);
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment