We can have multiple usb_functions which origin is the same "instance".
Within one USB configuration there should be only one function of an
instance. This back pointer helps configfs to recoginze to which
instance a given usb_function belongs.

Signed-off-by: Sebastian Andrzej Siewior <bige...@linutronix.de>
---
 drivers/usb/gadget/functions.c |    8 +++++++-
 include/linux/usb/composite.h  |    1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/functions.c b/drivers/usb/gadget/functions.c
index f9cdf8e..b13f839 100644
--- a/drivers/usb/gadget/functions.c
+++ b/drivers/usb/gadget/functions.c
@@ -55,7 +55,13 @@ EXPORT_SYMBOL_GPL(usb_get_function_instance);
 
 struct usb_function *usb_get_function(struct usb_function_instance *fi)
 {
-       return fi->fd->alloc_func(fi);
+       struct usb_function *f;
+
+       f = fi->fd->alloc_func(fi);
+       if (IS_ERR(f))
+               return f;
+       f->fi = fi;
+       return f;
 }
 EXPORT_SYMBOL_GPL(usb_get_function);
 
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 6596cc2..cde6a49 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -161,6 +161,7 @@ struct usb_function {
        /* internals */
        struct list_head                list;
        DECLARE_BITMAP(endpoints, 32);
+       const struct usb_function_instance *fi;
 };
 
 int usb_add_function(struct usb_configuration *, struct usb_function *);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to