]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
usb: gadget: dfu: add functional descriptor in descriptor set
authorPatrick Delaunay <patrick.delaunay@st.com>
Thu, 8 Dec 2016 17:10:49 +0000 (18:10 +0100)
committerMarek Vasut <marex@denx.de>
Sun, 26 Feb 2017 12:24:30 +0000 (13:24 +0100)
The "DFU descriptor set" must contain the "DFU functional descriptor"
but it is missing today in U-Boot code
(cf: DFU spec 1.1, chapter 4.2 DFU Mode Descriptor Set)
This patch only allocate buffer and copy DFU functional descriptor
after interfaces.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
drivers/usb/gadget/f_dfu.c

index 8e7c981657c3b6be4b5ddbad802f5e00b3abb419..73b32f8ae5eb91adfa3e4d34c67f608c495373fe 100644 (file)
@@ -654,7 +654,7 @@ static int dfu_prepare_function(struct f_dfu *f_dfu, int n)
        struct usb_interface_descriptor *d;
        int i = 0;
 
-       f_dfu->function = calloc(sizeof(struct usb_descriptor_header *), n + 1);
+       f_dfu->function = calloc(sizeof(struct usb_descriptor_header *), n + 2);
        if (!f_dfu->function)
                goto enomem;
 
@@ -673,6 +673,14 @@ static int dfu_prepare_function(struct f_dfu *f_dfu, int n)
 
                f_dfu->function[i] = (struct usb_descriptor_header *)d;
        }
+
+       /* add DFU Functional Descriptor */
+       f_dfu->function[i] = calloc(sizeof(dfu_func), 1);
+       if (!f_dfu->function[i])
+               goto enomem;
+       memcpy(f_dfu->function[i], &dfu_func, sizeof(dfu_func));
+
+       i++;
        f_dfu->function[i] = NULL;
 
        return 0;