Skip to contentSkip to conversation

macb: fix compile warning

PATCH Superseded Andreas Bießmann 3 participants 6 messages Jun 9, 2011 – Jul 27, 2011 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 macb: fix compile warning

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---

---
BEWARE! this patch is only copile tested!

 drivers/net/macb.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/macb.c +3 -2
index 72ea1fc..da41054 100644
@@ -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 = netdev->enetaddr[0] | netdev->enetaddr[1] << 8 |
+			netdev->enetaddr[2] << 16 | netdev->enetaddr[3] << 24;
 	macb_writel(macb, SA1B, hwaddr_bottom);
-	hwaddr_top = cpu_to_le16(*((u16 *)(dev->enetaddr + 4)));
+	hwaddr_top = netdev->enetaddr[4] | netdev->enetaddr[5] << 8;
 	macb_writel(macb, SA1T, hwaddr_top);
 	return 0;
 }
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH v2 1/1 macb: fix compile warning

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---

---
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(-)
drivers/net/macb.c +3 -2
index 72ea1fc..c63eea9 100644
@@ -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;
 }
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH v2 1/1 macb: fix compile warning

Dear Andreas Bie?mann,

Quoted 8 lines

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---

Quoted 2 lines

---
BEWARE! this patch is only compile tested!

Works well with top9000(at91sam9xe). Thanks.

Quoted 14 lines

changes since v1:
- use correct eth_device

  drivers/net/macb.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/macb.c +0 -0
index 72ea1fc..c63eea9 100644
@@ -522,9 +522,10 @@ static int macb_write_hwaddr(struct eth_device *dev)
  	u16 hwaddr_top;
 

drivers/net/macb.c static int macb_write_hwaddr(struct eth_device *dev) · line 531

Quoted 10 lines
drivers/net/macb.c +3 -2
  	/* 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

#3 lore raw

PATCH 1/1 macb: fix compile warning

In reply to Andreas Bießmann

Dear "=?UTF-8?q?Andreas=20Bie=C3=9Fmann?=",

Quoted 20 lines · In message <[email protected]> you…

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---

---
BEWARE! this patch is only copile tested!

 drivers/net/macb.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/macb.c +0 -0
index 72ea1fc..da41054 100644
@@ -522,9 +522,10 @@ static int macb_write_hwaddr(struct eth_device *dev)
 	u16 hwaddr_top;

drivers/net/macb.c static int macb_write_hwaddr(struct eth_device *dev) · line 530

Quoted 10 lines
drivers/net/macb.c +3 -2
 
 	/* set hardware address */
-	hwaddr_bottom = cpu_to_le32(*((u32 *)dev->enetaddr));
+	hwaddr_bottom = netdev->enetaddr[0] | netdev->enetaddr[1] << 8 |
+			netdev->enetaddr[2] << 16 | netdev->enetaddr[3] << 24;
 	macb_writel(macb, SA1B, hwaddr_bottom);
-	hwaddr_top = cpu_to_le16(*((u16 *)(dev->enetaddr + 4)));
+	hwaddr_top = netdev->enetaddr[4] | netdev->enetaddr[5] << 8;
 	macb_writel(macb, SA1T, hwaddr_top);
 	return 0;

This doesn't apply. Can you please rebase and resubmit? Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"355/113 -- Not the famous irrational number PI,  but  an  incredible
simulation!"
#4 lore raw

PATCH 1/1 macb: fix compile warning

Dear Wolfgang Denk,

Quoted 5 lines

Dear "=?UTF-8?q?Andreas=20Bie=C3=9Fmann?=",

Quoted 2 lines · In message<[email protected]> you…

This patch fixes following compile warning:

Quoted 7 lines
Quoted 6 lines

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

This doesn't apply. Can you please rebase and resubmit? Thanks.

V2 of this patch has been mainlined in June already.
Note: macb is the LAN driver for all Atmel ARM and AVR32 SoCs.

Best Regards,
Reinhard

#5 lore raw

PATCH 1/1 macb: fix compile warning

Dear Reinhard Meyer,

Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 2 lines

This doesn't apply. Can you please rebase and resubmit? Thanks.

V2 of this patch has been mainlined in June already.

I see, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If the car industry behaved like the computer industry over the  last
30  years, a Rolls-Royce would cost $5, get 300 miles per gallon, and
blow up once a year killing all passengers inside.