From 676daaf45869e810dcbe97cf6996f7c8e2fb7d32 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Fri, 14 Nov 2014 17:25:07 +0530 Subject: [PATCH] greybus: module: move module specific code to module.c Some of module specific routines were present in core.c instead of module.c. Move them to the right place. Signed-off-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/core.c | 59 --------------------------------------- drivers/staging/greybus/greybus.h | 1 + drivers/staging/greybus/module.c | 59 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 59 deletions(-) diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 851a302..be190e7 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -119,65 +119,6 @@ void greybus_deregister(struct greybus_driver *driver) EXPORT_SYMBOL_GPL(greybus_deregister); -/** - * gb_add_module - * - * Pass in a buffer that _should_ contain a Greybus module manifest - * and register a greybus device structure with the kernel core. - */ -void gb_add_module(struct greybus_host_device *hd, u8 module_id, - u8 *data, int size) -{ - struct gb_module *gmod; - - gmod = gb_module_create(hd, module_id); - if (!gmod) { - dev_err(hd->parent, "failed to create module\n"); - return; - } - - /* - * Parse the manifest and build up our data structures - * representing what's in it. - */ - if (!gb_manifest_parse(gmod, data, size)) { - dev_err(hd->parent, "manifest error\n"); - goto err_module; - } - - /* - * XXX - * We've successfully parsed the manifest. Now we need to - * allocate CPort Id's for connecting to the CPorts found on - * other modules. For each of these, establish a connection - * between the local and remote CPorts (including - * configuring the switch to allow them to communicate). - */ - - return; - -err_module: - gb_module_destroy(gmod); -} - -void gb_remove_module(struct greybus_host_device *hd, u8 module_id) -{ - struct gb_module *gmod = gb_module_find(hd, module_id); - - if (gmod) - gb_module_destroy(gmod); - else - dev_err(hd->parent, "module id %d not found\n", module_id); -} - -static void gb_remove_modules(struct greybus_host_device *hd) -{ - struct gb_module *gmod, *temp; - - list_for_each_entry_safe(gmod, temp, &hd->modules, links) - gb_module_destroy(gmod); -} - static DEFINE_MUTEX(hd_mutex); static void free_hd(struct kref *kref) diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index d64c181..284be84 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -240,6 +240,7 @@ int greybus_disabled(void); void gb_add_module(struct greybus_host_device *hd, u8 module_id, u8 *data, int size); void gb_remove_module(struct greybus_host_device *hd, u8 module_id); +void gb_remove_modules(struct greybus_host_device *hd); int greybus_svc_in(struct greybus_host_device *hd, u8 *data, int length); int gb_ap_init(void); diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c index 22b35e4..9583b5a 100644 --- a/drivers/staging/greybus/module.c +++ b/drivers/staging/greybus/module.c @@ -143,6 +143,65 @@ void gb_module_destroy(struct gb_module *gmod) device_del(&gmod->dev); } +/** + * gb_add_module + * + * Pass in a buffer that _should_ contain a Greybus module manifest + * and register a greybus device structure with the kernel core. + */ +void gb_add_module(struct greybus_host_device *hd, u8 module_id, + u8 *data, int size) +{ + struct gb_module *gmod; + + gmod = gb_module_create(hd, module_id); + if (!gmod) { + dev_err(hd->parent, "failed to create module\n"); + return; + } + + /* + * Parse the manifest and build up our data structures + * representing what's in it. + */ + if (!gb_manifest_parse(gmod, data, size)) { + dev_err(hd->parent, "manifest error\n"); + goto err_module; + } + + /* + * XXX + * We've successfully parsed the manifest. Now we need to + * allocate CPort Id's for connecting to the CPorts found on + * other modules. For each of these, establish a connection + * between the local and remote CPorts (including + * configuring the switch to allow them to communicate). + */ + + return; + +err_module: + gb_module_destroy(gmod); +} + +void gb_remove_module(struct greybus_host_device *hd, u8 module_id) +{ + struct gb_module *gmod = gb_module_find(hd, module_id); + + if (gmod) + gb_module_destroy(gmod); + else + dev_err(hd->parent, "module id %d not found\n", module_id); +} + +void gb_remove_modules(struct greybus_host_device *hd) +{ + struct gb_module *gmod, *temp; + + list_for_each_entry_safe(gmod, temp, &hd->modules, links) + gb_module_destroy(gmod); +} + int gb_module_interface_init(struct gb_module *gmod, u8 interface_id, u8 device_id) { -- 2.7.4