From d7f9be4867e060712b6d9aaa1a8c98d15976c71d Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Fri, 3 Oct 2014 14:32:35 -0400 Subject: [PATCH] greybus: implement core module removal path Implement gb_remove_module() by finding the gb_module to be removed via the supplied module_id. Add support for removing the actual device into greybus_remove_device() after all the subdevs are disconnected. Signed-off-by: Matt Porter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/core.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 8237f5f64015..8811f35f9eaa 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -252,7 +252,19 @@ error: void gb_remove_module(struct greybus_host_device *hd, u8 module_id) { - // FIXME should be the remove_device call... + struct gb_module *gmod; + bool found = false; + + list_for_each_entry(gmod, &hd->modules, links) + if (gmod->module_id == module_id) { + found = true; + break; + } + + if (found) + greybus_remove_device(gmod); + else + dev_err(hd->parent, "module id %d remove error\n", module_id); } void greybus_remove_device(struct gb_module *gmod) @@ -264,7 +276,8 @@ void greybus_remove_device(struct gb_module *gmod) gb_tty_disconnect(gmod); gb_battery_disconnect(gmod); - // FIXME - device_remove(&gmod->dev); + device_del(&gmod->dev); + put_device(&gmod->dev); } static DEFINE_MUTEX(hd_mutex); -- 2.39.2