Message ID | 1375399657-25642-8-git-send-email-troy.kisky@boundarydevices.com |
---|---|
State | Changes Requested |
Delegated to: | Marek Vasut |
Headers | show |
Dear Troy Kisky, I don't understand what this patch does and why. It's not very clear from the (missing) commit message either. > Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> > --- > drivers/usb/gadget/config.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c > index f563afe..014a679 100644 > --- a/drivers/usb/gadget/config.c > +++ b/drivers/usb/gadget/config.c > @@ -10,6 +10,7 @@ > */ > > #include <common.h> > +#include <asm/unaligned.h> > #include <asm/errno.h> > #include <linux/list.h> > #include <linux/string.h> > @@ -86,7 +87,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, > @@ -100,7 +102,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; > } Best regards, Marek Vasut
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index f563afe..014a679 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -10,6 +10,7 @@ */ #include <common.h> +#include <asm/unaligned.h> #include <asm/errno.h> #include <linux/list.h> #include <linux/string.h> @@ -86,7 +87,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, @@ -100,7 +102,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; }
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> --- drivers/usb/gadget/config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)