diff options
author | Claudiu Manoil <claudiu.manoil@freescale.com> | 2014-10-07 03:44:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-09 01:40:37 -0400 |
commit | 83bfc3c4765c35ef0dfff8a3d6dedab88f3f50ea (patch) | |
tree | dcdf7fd08ae731364ea09aef2fa725b6b3e6e597 | |
parent | d6ef0bcce386531f250a8abee3c3595214ea1629 (diff) |
gianfar: Make MAC addr setup endian safe, cleanup
Fix the 32-bit memory access that is not endian safe,
i.e. not giving the desired byte layout for a LE CPU:
tempval = *((u32 *) (tmpbuf + 4)), where 'char tmpbuf[]'.
Get rid of rendundant local vars (tmpbuf[] and idx) and
forced casts. Cleanup comments.
Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 37e060478630..961198a2bfa8 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -3248,22 +3248,21 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num, | |||
3248 | { | 3248 | { |
3249 | struct gfar_private *priv = netdev_priv(dev); | 3249 | struct gfar_private *priv = netdev_priv(dev); |
3250 | struct gfar __iomem *regs = priv->gfargrp[0].regs; | 3250 | struct gfar __iomem *regs = priv->gfargrp[0].regs; |
3251 | int idx; | ||
3252 | char tmpbuf[ETH_ALEN]; | ||
3253 | u32 tempval; | 3251 | u32 tempval; |
3254 | u32 __iomem *macptr = ®s->macstnaddr1; | 3252 | u32 __iomem *macptr = ®s->macstnaddr1; |
3255 | 3253 | ||
3256 | macptr += num*2; | 3254 | macptr += num*2; |
3257 | 3255 | ||
3258 | /* Now copy it into the mac registers backwards, cuz | 3256 | /* For a station address of 0x12345678ABCD in transmission |
3259 | * little endian is silly | 3257 | * order (BE), MACnADDR1 is set to 0xCDAB7856 and |
3258 | * MACnADDR2 is set to 0x34120000. | ||
3260 | */ | 3259 | */ |
3261 | for (idx = 0; idx < ETH_ALEN; idx++) | 3260 | tempval = (addr[5] << 24) | (addr[4] << 16) | |
3262 | tmpbuf[ETH_ALEN - 1 - idx] = addr[idx]; | 3261 | (addr[3] << 8) | addr[2]; |
3263 | 3262 | ||
3264 | gfar_write(macptr, *((u32 *) (tmpbuf))); | 3263 | gfar_write(macptr, tempval); |
3265 | 3264 | ||
3266 | tempval = *((u32 *) (tmpbuf + 4)); | 3265 | tempval = (addr[1] << 24) | (addr[0] << 16); |
3267 | 3266 | ||
3268 | gfar_write(macptr+1, tempval); | 3267 | gfar_write(macptr+1, tempval); |
3269 | } | 3268 | } |