diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-07-09 10:56:30 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-07-13 15:40:37 -0700 |
commit | e99f305bb7cc3e22c508440d2a52e8c84c9b507a (patch) | |
tree | bb25c01bfb6d030f0c8194ee5844e82e8d1ae679 /drivers/staging/greybus/core.c | |
parent | e4340b13fd2cf9bcf1f0a40ae15de454ffdb74f8 (diff) |
greybus: Cleanup connection leftovers
This wouldn't happen normally, but in a buggy corner case it is possible
that all the connections aren't removed properly and they are still
present after the interfaces and endo are removed.
Warn in such a case and cleanup connections, so that /sys/bus/greybus/
can be removed while removing greybus modules.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/core.c')
-rw-r--r-- | drivers/staging/greybus/core.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 925e1dc00eff..3b1be2dd2359 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -235,6 +235,13 @@ void greybus_remove_hd(struct greybus_host_device *hd) */ gb_interfaces_remove(hd); gb_endo_remove(hd->endo); + + /* + * Make sure there are no leftovers that can potentially corrupt sysfs. + */ + if (WARN_ON(!list_empty(&hd->connections))) + gb_hd_connections_exit(hd); + kref_put_mutex(&hd->kref, free_hd, &hd_mutex); } EXPORT_SYMBOL_GPL(greybus_remove_hd); |