summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
diff options
context:
space:
mode:
authorViresh Kumar2015-06-04 14:46:45 +0200
committerGreg Kroah-Hartman2015-06-09 22:31:23 +0200
commit928f2abd5ff12fa4851b762df7c32e749e846b7c (patch)
tree68fb3fc47c0a657ef41471bca2709eb5ac3c9a9a /drivers/staging/greybus/connection.c
parentgreybus: manifest: clean up a few pr_err() calls (diff)
downloadkernel-qcow2-linux-928f2abd5ff12fa4851b762df7c32e749e846b7c.tar.gz
kernel-qcow2-linux-928f2abd5ff12fa4851b762df7c32e749e846b7c.tar.xz
kernel-qcow2-linux-928f2abd5ff12fa4851b762df7c32e749e846b7c.zip
greybus: Tear down devices in the reverse order
Normally, its a good practice to free resources in the reverse order in which they are allocated, so that all the dependencies can be sorted out properly. This is true while creating/destroying devices as well. For example consider this scenario (I faced a crash with control protocol due to this). For a new module, we will first create a bundle+connection for the control cport and then create other bundles/connections after parsing manifest. And while destroying interface on module hot unplug, we are removing the devices in the order they are added. And so the bundle/connection for the control cport are destroyed first. But, control cport was still required while destroying other bundles/connections. To solve this problem, lets destroy the resources in the reverse order in which they are added. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/connection.c')
-rw-r--r--drivers/staging/greybus/connection.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index a774f677279a..5ab744b14a0d 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -213,8 +213,8 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
"protocol 0x%02hhx handler not found\n", protocol_id);
spin_lock_irq(&gb_connections_lock);
- list_add_tail(&connection->hd_links, &hd->connections);
- list_add_tail(&connection->bundle_links, &bundle->connections);
+ list_add(&connection->hd_links, &hd->connections);
+ list_add(&connection->bundle_links, &bundle->connections);
spin_unlock_irq(&gb_connections_lock);
atomic_set(&connection->op_cycle, 0);