summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
diff options
context:
space:
mode:
authorViresh Kumar2015-08-31 13:51:13 +0200
committerJohan Hovold2015-09-03 14:45:09 +0200
commitfda2381bd2d96b4f45806e4796d558eec678e3c6 (patch)
treed2a031d10975846a24f08248fc55404d8ec18209 /drivers/staging/greybus/connection.c
parentgreybus: connection: Propagate error properly (diff)
downloadkernel-qcow2-linux-fda2381bd2d96b4f45806e4796d558eec678e3c6.tar.gz
kernel-qcow2-linux-fda2381bd2d96b4f45806e4796d558eec678e3c6.tar.xz
kernel-qcow2-linux-fda2381bd2d96b4f45806e4796d558eec678e3c6.zip
greybus: connection: call gb_connection_exit() from gb_connection_destroy()
Both the routines are always called together and in the same sequence. Rather than duplicating this at different places, make gb_connection_destroy() call gb_connection_exit(). This also makes it more sensible, as gb_connection_init() is never called directly by the users and so its its counterpart shouldn't be called directly as well. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Diffstat (limited to 'drivers/staging/greybus/connection.c')
-rw-r--r--drivers/staging/greybus/connection.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index 8fe056d57493..29870536aa2f 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -318,32 +318,6 @@ static void gb_connection_cancel_operations(struct gb_connection *connection,
spin_unlock_irq(&connection->lock);
}
-/*
- * Tear down a previously set up connection.
- */
-void gb_connection_destroy(struct gb_connection *connection)
-{
- struct ida *id_map;
-
- if (WARN_ON(!connection))
- return;
-
- spin_lock_irq(&gb_connections_lock);
- list_del(&connection->bundle_links);
- list_del(&connection->hd_links);
- spin_unlock_irq(&gb_connections_lock);
-
- if (connection->protocol)
- gb_protocol_put(connection->protocol);
- connection->protocol = NULL;
-
- id_map = &connection->hd->cport_id_map;
- ida_simple_remove(id_map, connection->hd_cport_id);
- connection->hd_cport_id = CPORT_ID_BAD;
-
- device_unregister(&connection->dev);
-}
-
static void gb_connection_disconnected(struct gb_connection *connection)
{
struct gb_control *control;
@@ -420,7 +394,7 @@ disconnect:
return ret;
}
-void gb_connection_exit(struct gb_connection *connection)
+static void gb_connection_exit(struct gb_connection *connection)
{
if (!connection->protocol) {
dev_warn(&connection->dev, "exit without protocol.\n");
@@ -441,14 +415,40 @@ void gb_connection_exit(struct gb_connection *connection)
gb_connection_disconnected(connection);
}
+/*
+ * Tear down a previously set up connection.
+ */
+void gb_connection_destroy(struct gb_connection *connection)
+{
+ struct ida *id_map;
+
+ if (WARN_ON(!connection))
+ return;
+
+ gb_connection_exit(connection);
+
+ spin_lock_irq(&gb_connections_lock);
+ list_del(&connection->bundle_links);
+ list_del(&connection->hd_links);
+ spin_unlock_irq(&gb_connections_lock);
+
+ if (connection->protocol)
+ gb_protocol_put(connection->protocol);
+ connection->protocol = NULL;
+
+ id_map = &connection->hd->cport_id_map;
+ ida_simple_remove(id_map, connection->hd_cport_id);
+ connection->hd_cport_id = CPORT_ID_BAD;
+
+ device_unregister(&connection->dev);
+}
+
void gb_hd_connections_exit(struct greybus_host_device *hd)
{
struct gb_connection *connection;
- list_for_each_entry(connection, &hd->connections, hd_links) {
- gb_connection_exit(connection);
+ list_for_each_entry(connection, &hd->connections, hd_links)
gb_connection_destroy(connection);
- }
}
void gb_connection_bind_protocol(struct gb_connection *connection)