Commit 1653d2f8 authored by Thomas Pugliese's avatar Thomas Pugliese Committed by Greg Kroah-Hartman

usb: wusbcore: preserve endianness of cached descriptors

Do not overwrite the multi-byte fields of usb_wa_descriptor with their
cpu format values after reading the descriptor.  Leave the values as
__le16 and swap on use.  This is more consistent with other uses of USB
descriptors.
Signed-off-by: default avatarThomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 679ee475
...@@ -570,14 +570,10 @@ static int wa_fill_descr(struct wahc *wa) ...@@ -570,14 +570,10 @@ static int wa_fill_descr(struct wahc *wa)
goto error; goto error;
} }
wa->wa_descr = wa_descr = (struct usb_wa_descriptor *) hdr; wa->wa_descr = wa_descr = (struct usb_wa_descriptor *) hdr;
/* Make LE fields CPU order */ if (le16_to_cpu(wa_descr->bcdWAVersion) > 0x0100)
wa_descr->bcdWAVersion = le16_to_cpu(wa_descr->bcdWAVersion);
wa_descr->wNumRPipes = le16_to_cpu(wa_descr->wNumRPipes);
wa_descr->wRPipeMaxBlock = le16_to_cpu(wa_descr->wRPipeMaxBlock);
if (wa_descr->bcdWAVersion > 0x0100)
dev_warn(dev, "Wire Adapter v%d.%d newer than groked v1.0\n", dev_warn(dev, "Wire Adapter v%d.%d newer than groked v1.0\n",
wa_descr->bcdWAVersion & 0xff00 >> 8, le16_to_cpu(wa_descr->bcdWAVersion) & 0xff00 >> 8,
wa_descr->bcdWAVersion & 0x00ff); le16_to_cpu(wa_descr->bcdWAVersion) & 0x00ff);
result = 0; result = 0;
error: error:
return result; return result;
......
...@@ -480,7 +480,7 @@ int rpipe_get_by_ep(struct wahc *wa, struct usb_host_endpoint *ep, ...@@ -480,7 +480,7 @@ int rpipe_get_by_ep(struct wahc *wa, struct usb_host_endpoint *ep,
*/ */
int wa_rpipes_create(struct wahc *wa) int wa_rpipes_create(struct wahc *wa)
{ {
wa->rpipes = wa->wa_descr->wNumRPipes; wa->rpipes = le16_to_cpu(wa->wa_descr->wNumRPipes);
wa->rpipe_bm = kzalloc(BITS_TO_LONGS(wa->rpipes)*sizeof(unsigned long), wa->rpipe_bm = kzalloc(BITS_TO_LONGS(wa->rpipes)*sizeof(unsigned long),
GFP_KERNEL); GFP_KERNEL);
if (wa->rpipe_bm == NULL) if (wa->rpipe_bm == NULL)
......
...@@ -279,11 +279,11 @@ struct wa_xfer_result { ...@@ -279,11 +279,11 @@ struct wa_xfer_result {
struct usb_wa_descriptor { struct usb_wa_descriptor {
u8 bLength; u8 bLength;
u8 bDescriptorType; u8 bDescriptorType;
u16 bcdWAVersion; __le16 bcdWAVersion;
u8 bNumPorts; /* don't use!! */ u8 bNumPorts; /* don't use!! */
u8 bmAttributes; /* Reserved == 0 */ u8 bmAttributes; /* Reserved == 0 */
u16 wNumRPipes; __le16 wNumRPipes;
u16 wRPipeMaxBlock; __le16 wRPipeMaxBlock;
u8 bRPipeBlockSize; u8 bRPipeBlockSize;
u8 bPwrOn2PwrGood; u8 bPwrOn2PwrGood;
u8 bNumMMCIEs; u8 bNumMMCIEs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment