summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/module.h
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-04-02 17:53:47 +0530
committerGreg Kroah-Hartman <gregkh@google.com>2015-04-05 16:23:22 +0200
commit2352a73212a503dfe77970c48a891c008b7edd5b (patch)
tree261e48edda13b9be7b968a016c22b9516879c0ef /drivers/staging/greybus/module.h
parent045235f118917210ab9574c768b2625231e2069b (diff)
downloadlinux-2352a73212a503dfe77970c48a891c008b7edd5b.tar.bz2
greybus: Unregister devices to get them freed
Devices registered with the device-core needs to be freed by calling device_unregister(). For module we are calling just put_device() and for bundle, connection and interface we are calling device_del(). All of these are incomplete and so none of them get freed, i.e. the .release() routine is never called for their devices. Module being a special case that it needs to maintain a refcount or a list of interfaces to trace its usage count. I have chosen refcount. And so once the refcount is zero, we can Unregister the device and module will get free as well. Because of this bug in freeing devices, their sysfs directories were not getting removed properly and after a manifest is parsed with the help of gbsim, removing modules was creating problems. The sysfs directory 'greybus' wasn't getting removed. And inserting the modules again resulted in warnings and insmod failure. WARNING: CPU: 3 PID: 4277 at /build/buildd/linux-3.13.0/fs/sysfs/dir.c:486 sysfs_warn_dup+0x86/0xa0() Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/module.h')
-rw-r--r--drivers/staging/greybus/module.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/greybus/module.h b/drivers/staging/greybus/module.h
index 75a8818de1c5..4f02e46301e1 100644
--- a/drivers/staging/greybus/module.h
+++ b/drivers/staging/greybus/module.h
@@ -13,6 +13,7 @@
struct gb_module {
struct device dev;
u8 module_id; /* Physical location within the Endo */
+ u16 refcount;
};
#define to_gb_module(d) container_of(d, struct gb_module, dev)
@@ -21,6 +22,7 @@ struct greybus_host_device;
/* Greybus "private" definitions */
struct gb_module *gb_module_find_or_create(struct greybus_host_device *hd,
u8 module_id);
+void gb_module_remove(struct gb_module *module);
#endif /* __MODULE_H */