Commit 1db1b243 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: bundle: kill the bundle lock

Kill the bundle lock, which looked like it protected the interface
bundle lists but really did not as lock-less manipulations were still
made.

No locking for the interface bundle list is in fact needed as bundles
are created along with the interface, and the list is only used to check
for duplicate bundle ids when parsing the manifest and to destroy the
bundles when removing the interface itself.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 1e6fb9a1
...@@ -65,6 +65,19 @@ static struct attribute *bundle_attrs[] = { ...@@ -65,6 +65,19 @@ static struct attribute *bundle_attrs[] = {
ATTRIBUTE_GROUPS(bundle); ATTRIBUTE_GROUPS(bundle);
static struct gb_bundle *gb_bundle_find(struct gb_interface *intf,
u8 bundle_id)
{
struct gb_bundle *bundle;
list_for_each_entry(bundle, &intf->bundles, links) {
if (bundle->id == bundle_id)
return bundle;
}
return NULL;
}
static void gb_bundle_release(struct device *dev) static void gb_bundle_release(struct device *dev)
{ {
struct gb_bundle *bundle = to_gb_bundle(dev); struct gb_bundle *bundle = to_gb_bundle(dev);
...@@ -78,9 +91,6 @@ struct device_type greybus_bundle_type = { ...@@ -78,9 +91,6 @@ struct device_type greybus_bundle_type = {
.release = gb_bundle_release, .release = gb_bundle_release,
}; };
/* XXX This could be per-host device or per-module */
static DEFINE_SPINLOCK(gb_bundles_lock);
/* /*
* Create a gb_bundle structure to represent a discovered * Create a gb_bundle structure to represent a discovered
* bundle. Returns a pointer to the new bundle or a null * bundle. Returns a pointer to the new bundle or a null
...@@ -127,9 +137,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, ...@@ -127,9 +137,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
return NULL; return NULL;
} }
spin_lock_irq(&gb_bundles_lock);
list_add(&bundle->links, &intf->bundles); list_add(&bundle->links, &intf->bundles);
spin_unlock_irq(&gb_bundles_lock);
return bundle; return bundle;
} }
...@@ -149,25 +157,10 @@ static void gb_bundle_connections_exit(struct gb_bundle *bundle) ...@@ -149,25 +157,10 @@ static void gb_bundle_connections_exit(struct gb_bundle *bundle)
*/ */
void gb_bundle_destroy(struct gb_bundle *bundle) void gb_bundle_destroy(struct gb_bundle *bundle)
{ {
spin_lock_irq(&gb_bundles_lock);
list_del(&bundle->links); list_del(&bundle->links);
spin_unlock_irq(&gb_bundles_lock);
gb_bundle_connections_exit(bundle); gb_bundle_connections_exit(bundle);
device_unregister(&bundle->dev); device_unregister(&bundle->dev);
} }
struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id)
{
struct gb_bundle *bundle;
spin_lock_irq(&gb_bundles_lock);
list_for_each_entry(bundle, &intf->bundles, links)
if (bundle->id == bundle_id)
goto found;
bundle = NULL;
found:
spin_unlock_irq(&gb_bundles_lock);
return bundle;
}
...@@ -33,6 +33,4 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, ...@@ -33,6 +33,4 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
u8 class); u8 class);
void gb_bundle_destroy(struct gb_bundle *bundle); void gb_bundle_destroy(struct gb_bundle *bundle);
struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id);
#endif /* __BUNDLE_H */ #endif /* __BUNDLE_H */
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