Skip to content

Commit

Permalink
usb: gadget: uvc: Fix endianness mismatches
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
  • Loading branch information
pinchartl authored and Felipe Balbi committed Sep 16, 2014
1 parent 4a6698b commit e102609
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/usb/gadget/function/f_uvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e102609

Please sign in to comment.