]> git.sur5r.net Git - u-boot/blobdiff - drivers/usb/gadget/f_mass_storage.c
usb:composite: use memcpy to avoid unaligned access
[u-boot] / drivers / usb / gadget / f_mass_storage.c
index c28866f7d3c2e5dbcae7766d4d9b0958113c2ec2..5b348d7a6ef2a6b50bd59b55e165279d9f53c778 100644 (file)
@@ -577,9 +577,9 @@ static int fsg_setup(struct usb_function *f,
 {
        struct fsg_dev          *fsg = fsg_from_func(f);
        struct usb_request      *req = fsg->common->ep0req;
-       u16                     w_index = le16_to_cpu(ctrl->wIndex);
-       u16                     w_value = le16_to_cpu(ctrl->wValue);
-       u16                     w_length = le16_to_cpu(ctrl->wLength);
+       u16                     w_index = get_unaligned_le16(&ctrl->wIndex);
+       u16                     w_value = get_unaligned_le16(&ctrl->wValue);
+       u16                     w_length = get_unaligned_le16(&ctrl->wLength);
 
        if (!fsg_is_set(fsg->common))
                return -EOPNOTSUPP;
@@ -617,7 +617,7 @@ static int fsg_setup(struct usb_function *f,
             "unknown class-specific control req "
             "%02x.%02x v%04x i%04x l%u\n",
             ctrl->bRequestType, ctrl->bRequest,
-            le16_to_cpu(ctrl->wValue), w_index, w_length);
+            get_unaligned_le16(&ctrl->wValue), w_index, w_length);
        return -EOPNOTSUPP;
 }
 
@@ -2261,7 +2261,8 @@ reset:
        if (rc)
                goto reset;
        fsg->bulk_out_enabled = 1;
-       common->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize);
+       common->bulk_out_maxpacket =
+                               le16_to_cpu(get_unaligned(&d->wMaxPacketSize));
        clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags);
 
        /* Allocate the requests */