usb: gadget: uvc: Fix endianness mismatches
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 16 Sep 2014 14:26:47 +0000 (17:26 +0300)
committerFelipe Balbi <balbi@ti.com>
Tue, 16 Sep 2014 14:59:47 +0000 (09:59 -0500)
The struct usb_endpoint_descriptor wMaxPacketSize field the struct
usb_ss_ep_comp_descriptor wBytesPerInterval field are stored in
little-endian format. Convert the values from CPU order to little endian
before storing the values.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/function/f_uvc.c

index bf9abf4aff226fa3404764d80c706cec6addf560..e126439e4b6509807c05f9bc133224b2ad66e460 100644 (file)
@@ -596,19 +596,20 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
        }
 
        uvc_fs_streaming_ep.wMaxPacketSize =
-               min(opts->streaming_maxpacket, 1023U);
+               cpu_to_le16(min(opts->streaming_maxpacket, 1023U));
        uvc_fs_streaming_ep.bInterval = opts->streaming_interval;
 
-       uvc_hs_streaming_ep.wMaxPacketSize = max_packet_size;
-       uvc_hs_streaming_ep.wMaxPacketSize |= ((max_packet_mult - 1) << 11);
+       uvc_hs_streaming_ep.wMaxPacketSize =
+               cpu_to_le16(max_packet_size | ((max_packet_mult - 1) << 11));
        uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
 
-       uvc_ss_streaming_ep.wMaxPacketSize = max_packet_size;
+       uvc_ss_streaming_ep.wMaxPacketSize = cpu_to_le16(max_packet_size);
        uvc_ss_streaming_ep.bInterval = opts->streaming_interval;
        uvc_ss_streaming_comp.bmAttributes = max_packet_mult - 1;
        uvc_ss_streaming_comp.bMaxBurst = opts->streaming_maxburst;
        uvc_ss_streaming_comp.wBytesPerInterval =
-               max_packet_size * max_packet_mult * opts->streaming_maxburst;
+               cpu_to_le16(max_packet_size * max_packet_mult *
+                           opts->streaming_maxburst);
 
        /* Allocate endpoints. */
        ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);