greybus: module: add gb_module_find()
authorMatt Porter <mporter@linaro.org>
Wed, 22 Oct 2014 02:43:29 +0000 (22:43 -0400)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 22 Oct 2014 05:57:49 +0000 (13:57 +0800)
Add support for getting a struct gb_module from a
Module ID.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/module.c
drivers/staging/greybus/module.h

index 2883947..50139f4 100644 (file)
@@ -107,6 +107,17 @@ void gb_module_destroy(struct gb_module *gmod)
        kfree(gmod);
 }
 
+struct gb_module *gb_module_find(struct greybus_host_device *hd, u8 module_id)
+{
+       struct gb_module *module;
+
+       list_for_each_entry(module, &hd->modules, links)
+               if (module->module_id == module_id)
+                       return module;
+
+       return NULL;
+}
+
 void gb_module_interfaces_init(struct gb_module *gmod)
 {
        struct gb_interface *interface;
index 2c6707d..82def46 100644 (file)
@@ -52,6 +52,9 @@ struct gb_module *gb_module_create(struct greybus_host_device *hd,
                                        u8 module_id);
 void gb_module_destroy(struct gb_module *module);
 
+struct gb_module *gb_module_find(struct greybus_host_device *hd,
+                               u8 module_id);
+
 void gb_module_interfaces_init(struct gb_module *gmod);
 
 #endif /* __MODULE_H */