From 6271b5bac99c2d06543adbdbecb9157d77765831 Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Tue, 21 Oct 2014 22:43:29 -0400 Subject: [PATCH] greybus: module: add gb_module_find() Add support for getting a struct gb_module from a Module ID. Signed-off-by: Matt Porter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/module.c | 11 +++++++++++ drivers/staging/greybus/module.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c index 2883947fb630..50139f41fe20 100644 --- a/drivers/staging/greybus/module.c +++ b/drivers/staging/greybus/module.c @@ -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; diff --git a/drivers/staging/greybus/module.h b/drivers/staging/greybus/module.h index 2c6707d6d85f..82def46e5ab1 100644 --- a/drivers/staging/greybus/module.h +++ b/drivers/staging/greybus/module.h @@ -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 */