Patchwork [U-Boot,2/4] usb:composite: use memcpy to avoid unaligned access

login
register
mail settings
Submitter Piotr Wilczek
Date April 10, 2013, 12:07 p.m.
Message ID <1365595673-23272-3-git-send-email-p.wilczek@samsung.com>
Download mbox | patch
Permalink /patch/235379/
State Awaiting Upstream
Delegated to: Marek Vasut
Headers show

Comments

Piotr Wilczek - April 10, 2013, 12:07 p.m.
This patch memcpy is used instead of an assignment to
avoid unaligned access execption on some ARM platforms.

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/usb/gadget/composite.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Heiko Schocher - May 16, 2013, 1:51 p.m.
Hello Piotr,

Am 10.04.2013 14:07, schrieb Piotr Wilczek:
> This patch memcpy is used instead of an assignment to
> avoid unaligned access execption on some ARM platforms.
> 
> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/usb/gadget/composite.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

just digged into this bug on an am335x based board, this patch
helped me out!

Thanks!

Tested-by: Heiko Schocher <hs@denx.de>
Acked-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
Heiko Schocher - June 25, 2013, 4:20 a.m.
Hello Prafulla,

just saw, that the below patch is delegated to you:
(added also Marek Vasut to cc, as he is the usb maintainer)

Am 10.04.2013 14:07, schrieb Piotr Wilczek:
> This patch memcpy is used instead of an assignment to
> avoid unaligned access execption on some ARM platforms.
> 
> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/usb/gadget/composite.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 2c5600e..0716e52 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -997,7 +997,8 @@ static int composite_bind(struct usb_gadget *gadget)
>  	if (status < 0)
>  		goto fail;
>  
> -	cdev->desc = *composite->dev;
> +	memcpy(&cdev->desc, composite->dev,
> +	       sizeof(struct usb_device_descriptor));
>  	cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
>  
>  	debug("%s: ready\n", composite->name);
> 

This fixes a bug... do you plan to work it in for this release? Or
are there some issues with this patch?

bye,
Heiko
Marek Vasut - June 26, 2013, 11:32 a.m.
Dear Heiko Schocher,

> Hello Prafulla,
> 
> just saw, that the below patch is delegated to you:
> (added also Marek Vasut to cc, as he is the usb maintainer)

Applied

Best regards,
Marek Vasut

Patch

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 2c5600e..0716e52 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -997,7 +997,8 @@  static int composite_bind(struct usb_gadget *gadget)
 	if (status < 0)
 		goto fail;
 
-	cdev->desc = *composite->dev;
+	memcpy(&cdev->desc, composite->dev,
+	       sizeof(struct usb_device_descriptor));
 	cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
 
 	debug("%s: ready\n", composite->name);