]> git.sur5r.net Git - u-boot/blobdiff - drivers/usb/gadget/config.c
mtd: nand: mxs_nand: add use_minimum_ecc to struct
[u-boot] / drivers / usb / gadget / config.c
index f9163a80ed17cbcf912f0e4baf2a9b39fc6705e5..e96782644f314c0d3ef011a929ce309253258d80 100644 (file)
@@ -1,28 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * usb/gadget/config.c -- simplify building config descriptors
  *
  * Copyright (C) 2003 David Brownell
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Ported to U-boot by: Thomas Smits <ts.smits@gmail.com> and
+ * Ported to U-Boot by: Thomas Smits <ts.smits@gmail.com> and
  *                      Remy Bohmer <linux@bohmer.net>
  */
 
 #include <common.h>
-#include <asm/errno.h>
+#include <asm/unaligned.h>
+#include <linux/errno.h>
 #include <linux/list.h>
 #include <linux/string.h>
 
@@ -98,7 +86,8 @@ int usb_gadget_config_buf(
        /* config descriptor first */
        if (length < USB_DT_CONFIG_SIZE || !desc)
                return -EINVAL;
-       *cp = *config;
+       /* config need not be aligned */
+       memcpy(cp, config, sizeof(*cp));
 
        /* then interface/endpoint/class/vendor/... */
        len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8 *)buf,
@@ -112,7 +101,7 @@ int usb_gadget_config_buf(
        /* patch up the config descriptor */
        cp->bLength = USB_DT_CONFIG_SIZE;
        cp->bDescriptorType = USB_DT_CONFIG;
-       cp->wTotalLength = cpu_to_le16(len);
+       put_unaligned_le16(len, &cp->wTotalLength);
        cp->bmAttributes |= USB_CONFIG_ATT_ONE;
        return len;
 }