summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/module.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2014-11-14 17:25:07 +0530
committerGreg Kroah-Hartman <greg@kroah.com>2014-11-14 13:49:04 -0800
commit676daaf45869e810dcbe97cf6996f7c8e2fb7d32 (patch)
treec3bc7d8e80f62e9f52421e94a3fb4b4b1c3f931a /drivers/staging/greybus/module.c
parent9ca4d62f15bc8e1977ed2c6c2dfc84449b6ab35f (diff)
downloadlinux-676daaf45869e810dcbe97cf6996f7c8e2fb7d32.tar.gz
linux-676daaf45869e810dcbe97cf6996f7c8e2fb7d32.tar.bz2
linux-676daaf45869e810dcbe97cf6996f7c8e2fb7d32.zip
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 <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/module.c')
-rw-r--r--drivers/staging/greybus/module.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c
index 22b35e427926..9583b5a18bd6 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)
{