From 1a4c013a44add7f174e0507f0240f3b3cc810301 Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Tue, 21 Oct 2014 22:43:30 -0400 Subject: [PATCH] greybus: interface: add gb_interface_find() Add support for getting a struct gb_interface from an Interface ID. Signed-off-by: Matt Porter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/interface.c | 12 ++++++++++++ drivers/staging/greybus/interface.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index 645f05b..0415db5 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -60,6 +60,18 @@ void gb_interface_destroy(struct gb_interface *interface) kfree(interface); } +struct gb_interface *gb_interface_find(struct gb_module *module, + u8 interface_id) +{ + struct gb_interface *interface; + + list_for_each_entry(interface, &module->interfaces, links) + if (interface->id == interface_id) + return interface; + + return NULL; +} + int gb_interface_connections_init(struct gb_interface *interface) { struct gb_connection *connection; diff --git a/drivers/staging/greybus/interface.h b/drivers/staging/greybus/interface.h index f0c9e1d..907b634 100644 --- a/drivers/staging/greybus/interface.h +++ b/drivers/staging/greybus/interface.h @@ -14,6 +14,7 @@ struct gb_interface { struct gb_module *gmod; u8 id; + u8 device_id; struct list_head connections; struct list_head links; /* module->interfaces */ @@ -22,6 +23,8 @@ struct gb_interface { struct gb_interface *gb_interface_create(struct gb_module *gmod, u8 module_id); void gb_interface_destroy(struct gb_interface *interface); +struct gb_interface *gb_interface_find(struct gb_module *gmod, u8 interface_id); + int gb_interface_connections_init(struct gb_interface *interface); void gb_interface_connections_exit(struct gb_interface *interface); -- 2.7.4