greybus_module_release(&gmod->dev);
}
+static void gb_delete_module(struct gb_module *gmod)
+{
+ /* FIXME - tear down interfaces first */
+
+ device_del(&gmod->dev);
+}
+
void gb_remove_module(struct greybus_host_device *hd, u8 module_id)
{
struct gb_module *gmod;
}
if (found)
- greybus_remove_device(gmod);
+ gb_delete_module(gmod);
else
dev_err(hd->parent, "module id %d remove error\n", module_id);
}
-void greybus_remove_device(struct gb_module *gmod)
+static void gb_remove_modules(struct greybus_host_device *hd)
{
- device_del(&gmod->dev);
- put_device(&gmod->dev);
+ struct gb_module *gmod, *temp;
+
+ list_for_each_entry_safe(gmod, temp, &hd->modules, links) {
+ gb_delete_module(gmod);
+ }
}
static DEFINE_MUTEX(hd_mutex);
void greybus_remove_hd(struct greybus_host_device *hd)
{
+ gb_remove_modules(hd);
kref_put_mutex(&hd->kref, free_hd, &hd_mutex);
}
EXPORT_SYMBOL_GPL(greybus_remove_hd);
int greybus_disabled(void);
-void greybus_remove_device(struct gb_module *gmod);
-
/* Internal functions to gb module, move to internal .h file eventually. */
void gb_add_module(struct greybus_host_device *hd, u8 module_id,