summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2015-06-12 10:21:11 -0500
committerGreg Kroah-Hartman <gregkh@google.com>2015-06-12 12:14:24 -0700
commitfe53b45ca8143e7f1073ff31d7c4cfb4e92dc824 (patch)
treef02282fc18323472b0c381fc2024fecbb716bb4e /drivers
parentbc942083585da78a5287089023aebcc8952c21f4 (diff)
greybus: bundle: fix gb_bundle_destroy()
Currently gb_bundle_destroy() takes an interface as an argument, and really doesn't do what a function by that name should do. What it now does is delete all bundles associated with a given interface. What it should do is destroy a single bundle. Move the looping logic out of gb_bundle_destroy() and into its caller, gb_interface_destroy(). Pass each bundle in an interface to gb_bundle_destroy(), which will do what's required to destroy a single bundle (including removing it from its interface's bundle list under protection of the lock). Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/greybus/bundle.c18
-rw-r--r--drivers/staging/greybus/bundle.h2
-rw-r--r--drivers/staging/greybus/interface.c6
3 files changed, 9 insertions, 17 deletions
diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c
index 89568b2b0adf..8d0e86fc2cfc 100644
--- a/drivers/staging/greybus/bundle.c
+++ b/drivers/staging/greybus/bundle.c
@@ -215,24 +215,14 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
/*
* Tear down a previously set up bundle.
*/
-void gb_bundle_destroy(struct gb_interface *intf)
+void gb_bundle_destroy(struct gb_bundle *bundle)
{
- LIST_HEAD(list);
- struct gb_bundle *bundle;
- struct gb_bundle *temp;
-
- if (WARN_ON(!intf))
- return;
-
spin_lock_irq(&gb_bundles_lock);
- list_splice_init(&intf->bundles, &list);
+ list_del(&bundle->links);
spin_unlock_irq(&gb_bundles_lock);
- list_for_each_entry_safe(bundle, temp, &list, links) {
- list_del(&bundle->links);
- gb_bundle_connections_exit(bundle);
- device_unregister(&bundle->dev);
- }
+ gb_bundle_connections_exit(bundle);
+ device_unregister(&bundle->dev);
}
int gb_bundle_init(struct gb_bundle *bundle, u8 device_id)
diff --git a/drivers/staging/greybus/bundle.h b/drivers/staging/greybus/bundle.h
index 5c12c72ddcec..887883dabfc0 100644
--- a/drivers/staging/greybus/bundle.h
+++ b/drivers/staging/greybus/bundle.h
@@ -31,7 +31,7 @@ struct gb_bundle {
/* Greybus "private" definitions" */
struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
u8 class);
-void gb_bundle_destroy(struct gb_interface *intf);
+void gb_bundle_destroy(struct gb_bundle *bundle);
int gb_bundle_init(struct gb_bundle *bundle, u8 device_id);
int gb_bundles_init(struct gb_interface *intf, u8 device_id);
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c
index 3483f848240b..5b1621ccf724 100644
--- a/drivers/staging/greybus/interface.c
+++ b/drivers/staging/greybus/interface.c
@@ -141,6 +141,8 @@ put_module:
static void gb_interface_destroy(struct gb_interface *intf)
{
struct gb_module *module;
+ struct gb_bundle *bundle;
+ struct gb_bundle *next;
if (WARN_ON(!intf))
return;
@@ -149,11 +151,11 @@ static void gb_interface_destroy(struct gb_interface *intf)
list_del(&intf->links);
spin_unlock_irq(&gb_interfaces_lock);
- gb_bundle_destroy(intf);
+ list_for_each_entry_safe(bundle, next, &intf->bundles, links)
+ gb_bundle_destroy(bundle);
kfree(intf->product_string);
kfree(intf->vendor_string);
- /* kref_put(module->hd); */
module = intf->module;
device_unregister(&intf->dev);