diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2008-06-19 20:52:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-07-21 18:16:00 -0400 |
commit | a4c39c41bf3592684e36fa0dbbd4ab1a31f969b9 (patch) | |
tree | 548a902e3dc3999742fba83ff93c7584f995b73a /include | |
parent | a7707adf9ee8de3c5b67e3793b98888f551ad00d (diff) |
usb gadget: descriptor copying support
Define three new descriptor manipulation utilities, for use when
setting up functions that may have multiple instances:
usb_copy_descriptors() to copy a vector of descriptors
usb_free_descriptors() to free the copy
usb_find_endpoint() to find a copied version
These will be used as follows. Functions will continue to have static
tables of descriptors they update, now used as __initdata templates.
When a function creates a new instance, it patches those tables with
relevant interface and string IDs, plus endpoint assignments. Then it
copies those morphed descriptors, associates the copies with the new
function instance, and records the endpoint descriptors to use when
activating the endpoints. When initialization is done, only the copies
remain in memory. The copies are freed on driver removal.
This ensures that each instance has descriptors which hold the right
instance-specific data. Two instances in the same configuration will
obviously never share the same interface IDs or use the same endpoints.
Instances in different configurations won't do so either, which means
this is slightly less memory-efficient in some cases.
This also includes a bugfix to the epautoconf code that shows up with
this usage model. It must replace the previous endpoint number when
updating the template descriptors, not just mask in a few more bits.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/usb/gadget.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index cf468fbdbf8e..0ebedaec075d 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
@@ -858,6 +858,25 @@ int usb_descriptor_fillbuf(void *, unsigned, | |||
858 | int usb_gadget_config_buf(const struct usb_config_descriptor *config, | 858 | int usb_gadget_config_buf(const struct usb_config_descriptor *config, |
859 | void *buf, unsigned buflen, const struct usb_descriptor_header **desc); | 859 | void *buf, unsigned buflen, const struct usb_descriptor_header **desc); |
860 | 860 | ||
861 | /* copy a NULL-terminated vector of descriptors */ | ||
862 | struct usb_descriptor_header **usb_copy_descriptors( | ||
863 | struct usb_descriptor_header **); | ||
864 | |||
865 | /* return copy of endpoint descriptor given original descriptor set */ | ||
866 | struct usb_endpoint_descriptor *usb_find_endpoint( | ||
867 | struct usb_descriptor_header **src, | ||
868 | struct usb_descriptor_header **copy, | ||
869 | struct usb_endpoint_descriptor *match); | ||
870 | |||
871 | /** | ||
872 | * usb_free_descriptors - free descriptors returned by usb_copy_descriptors() | ||
873 | * @v: vector of descriptors | ||
874 | */ | ||
875 | static inline void usb_free_descriptors(struct usb_descriptor_header **v) | ||
876 | { | ||
877 | kfree(v); | ||
878 | } | ||
879 | |||
861 | /*-------------------------------------------------------------------------*/ | 880 | /*-------------------------------------------------------------------------*/ |
862 | 881 | ||
863 | /* utility wrapping a simple endpoint selection policy */ | 882 | /* utility wrapping a simple endpoint selection policy */ |