]> git.karo-electronics.de Git - karo-tx-linux.git/commit
greybus: Unregister devices to get them freed
authorViresh Kumar <viresh.kumar@linaro.org>
Thu, 2 Apr 2015 12:23:47 +0000 (17:53 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Sun, 5 Apr 2015 14:23:22 +0000 (16:23 +0200)
commit2352a73212a503dfe77970c48a891c008b7edd5b
tree261e48edda13b9be7b968a016c22b9516879c0ef
parent045235f118917210ab9574c768b2625231e2069b
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>
drivers/staging/greybus/bundle.c
drivers/staging/greybus/connection.c
drivers/staging/greybus/interface.c
drivers/staging/greybus/module.c
drivers/staging/greybus/module.h