Patchwork [U-Boot,v2] macb: fix compile warning

login
register
mail settings
Submitter Andreas Bießmann
Date June 9, 2011, 12:08 p.m.
Message ID <1307621326-17010-1-git-send-email-andreas.devel@gmail.com>
Download mbox | patch
Permalink /patch/99740/
State Accepted
Commit 6c169c12d7782335be2f1d303622bcd0e1d00a02
Delegated to: Reinhard Meyer
Headers show

Comments

Andreas Bießmann - June 9, 2011, 12:08 p.m.
This patch fixes following compile warning:

---8<---
macb.c: In function 'macb_write_hwaddr':
macb.c:525:2: warning: dereferencing type-punned pointer will break strict-aliasing rules
--->8---

Signed-off-by: Andreas Bießmann <andreas.devel@gmail.com>
---
BEWARE! this patch is only compile tested!

changes since v1:
 - use correct eth_device

 drivers/net/macb.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Reinhard Meyer - June 9, 2011, 7:02 p.m.
Dear Andreas Bießmann,
> This patch fixes following compile warning:
>
> ---8<---
> macb.c: In function 'macb_write_hwaddr':
> macb.c:525:2: warning: dereferencing type-punned pointer will break strict-aliasing rules
> --->8---
>
> Signed-off-by: Andreas Bießmann<andreas.devel@gmail.com>
Tested-by: Reinhard Meyer<u-boot@emk-elektronik.de>
> ---
> BEWARE! this patch is only compile tested!
Works well with top9000(at91sam9xe). Thanks.
>
> changes since v1:
>   - use correct eth_device
>
>   drivers/net/macb.c |    5 +++--
>   1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index 72ea1fc..c63eea9 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -522,9 +522,10 @@ static int macb_write_hwaddr(struct eth_device *dev)
>   	u16 hwaddr_top;
>
>   	/* set hardware address */
> -	hwaddr_bottom = cpu_to_le32(*((u32 *)dev->enetaddr));
> +	hwaddr_bottom = dev->enetaddr[0] | dev->enetaddr[1]<<  8 |
> +			dev->enetaddr[2]<<  16 | dev->enetaddr[3]<<  24;
>   	macb_writel(macb, SA1B, hwaddr_bottom);
> -	hwaddr_top = cpu_to_le16(*((u16 *)(dev->enetaddr + 4)));
> +	hwaddr_top = dev->enetaddr[4] | dev->enetaddr[5]<<  8;
>   	macb_writel(macb, SA1T, hwaddr_top);
>   	return 0;
>   }

Applied to u-boot-atmel/master. Thanks,
Reinhard

Patch

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 72ea1fc..c63eea9 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -522,9 +522,10 @@  static int macb_write_hwaddr(struct eth_device *dev)
 	u16 hwaddr_top;
 
 	/* set hardware address */
-	hwaddr_bottom = cpu_to_le32(*((u32 *)dev->enetaddr));
+	hwaddr_bottom = dev->enetaddr[0] | dev->enetaddr[1] << 8 |
+			dev->enetaddr[2] << 16 | dev->enetaddr[3] << 24;
 	macb_writel(macb, SA1B, hwaddr_bottom);
-	hwaddr_top = cpu_to_le16(*((u16 *)(dev->enetaddr + 4)));
+	hwaddr_top = dev->enetaddr[4] | dev->enetaddr[5] << 8;
 	macb_writel(macb, SA1T, hwaddr_top);
 	return 0;
 }