aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorDmytro Milinevskyy <milinevskyy@gmail.com>2012-10-04 18:44:04 -0400
committerFelipe Balbi <balbi@ti.com>2012-11-08 09:05:39 -0500
commitf72e3b78867142a19b77f1de0698ce8b03dc6cbd (patch)
treed516544d63e566385e5a745e9b7dfed94ee60899 /drivers/usb
parent23834e533184bd2185bce500c789f86b3668739b (diff)
usb: gadget: ncm: correct endianess conversion
Convert USB descriptor's fields to CPU byte order before using locally in USB NCM gadget driver. Tested on MIPS32 big-endian device. Signed-off-by: Dmytro Milinevskyy <milinevskyy@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/f_ncm.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index f1f66e9c76ba..6c8362f937be 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -102,7 +102,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
102 USB_CDC_NCM_NTB32_SUPPORTED) 102 USB_CDC_NCM_NTB32_SUPPORTED)
103 103
104static struct usb_cdc_ncm_ntb_parameters ntb_parameters = { 104static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
105 .wLength = sizeof ntb_parameters, 105 .wLength = cpu_to_le16(sizeof(ntb_parameters)),
106 .bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED), 106 .bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED),
107 .dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE), 107 .dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE),
108 .wNdpInDivisor = cpu_to_le16(4), 108 .wNdpInDivisor = cpu_to_le16(4),
@@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
869 struct sk_buff *skb2; 869 struct sk_buff *skb2;
870 int ncb_len = 0; 870 int ncb_len = 0;
871 __le16 *tmp; 871 __le16 *tmp;
872 int div = ntb_parameters.wNdpInDivisor; 872 int div;
873 int rem = ntb_parameters.wNdpInPayloadRemainder; 873 int rem;
874 int pad; 874 int pad;
875 int ndp_align = ntb_parameters.wNdpInAlignment; 875 int ndp_align;
876 int ndp_pad; 876 int ndp_pad;
877 unsigned max_size = ncm->port.fixed_in_len; 877 unsigned max_size = ncm->port.fixed_in_len;
878 struct ndp_parser_opts *opts = ncm->parser_opts; 878 struct ndp_parser_opts *opts = ncm->parser_opts;
879 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; 879 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
880 880
881 div = le16_to_cpu(ntb_parameters.wNdpInDivisor);
882 rem = le16_to_cpu(ntb_parameters.wNdpInPayloadRemainder);
883 ndp_align = le16_to_cpu(ntb_parameters.wNdpInAlignment);
884
881 ncb_len += opts->nth_size; 885 ncb_len += opts->nth_size;
882 ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len; 886 ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len;
883 ncb_len += ndp_pad; 887 ncb_len += ndp_pad;