usb: thor: fix possible alignment issues
[profile/mobile/platform/kernel/u-boot-tm1.git] / property / usb / cdc_descriptor.c
old mode 100755 (executable)
new mode 100644 (file)
index 25db750..6dba80f
@@ -1,11 +1,15 @@
 #include <asm/arch/sci_types.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/cdc.h>
+#include <linux/usb/gadget.h>
 #include <linux/byteorder/little_endian.h>
+#include <linux/string.h>
 
 #define THOR_VENDOR_NUM                        0x04E8
 #define THOR_PRODUCT_NUM               0x685D
 
+typedef struct { __le16 val; } __attribute__((aligned(16))) __le16_packed;
+
 static struct usb_device_descriptor thor_device_desc_high __align (32)= {
        .bLength                        = sizeof(thor_device_desc_high),
        .bDescriptorType        = USB_DT_DEVICE,
@@ -233,8 +237,6 @@ static struct usb_qualifier_descriptor thor_dev_qualifier_desc __align(32) = {
        .bRESERVED                      = 0x00,
 };
 
-static char thor_device_qualifer_desc_buf[sizeof(struct usb_qualifier_descriptor)] __align(32);
-
 unsigned char g_USB_Other_Speed_ConfigDescr[] __align(32) =
 {
        0x09,0x07,0x43,0x00,0x02,0x01,0x00,0xC0,
@@ -272,14 +274,15 @@ unsigned char *thor_get_config_desc(unsigned int speed)
        return (unsigned char *) &function_desc_buf;
 }
 
-static void str2wide (char *str, u16 * wide)
+static void str2wide (char *str, void *wide)
 {
        int i;
+       __le16_packed   *tmp = wide;
        for (i = 0; i < strlen (str) && str[i]; i++){
                #if defined(__LITTLE_ENDIAN)
-                       wide[i] = (u16) str[i];
+                       tmp[i].val = (u16) str[i];
                #elif defined(__BIG_ENDIAN)
-                       wide[i] = ((u16)(str[i])<<8);
+                       tmp[i].val = ((u16)(str[i])<<8);
                #else
                        #error "__LITTLE_ENDIAN or __BIG_ENDIAN undefined"
                #endif