diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-04-29 04:03:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:27 -0400 |
commit | 6caf52a453d5fe0bc584a2895bfd39a3d9054829 (patch) | |
tree | 5429f92ee7f418a34d356141b86778fdbd16ec4c | |
parent | 48b2cf9e2921581c3f72295397da07673cdde072 (diff) |
net: use get/put_unaligned_* helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: Auke Kok <auke-jan.h.kok@intel.com>
Cc: John Ronciak <john.ronciak@intel.com>
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/net/e100.c | 2 | ||||
-rw-r--r-- | drivers/net/hamachi.c | 2 | ||||
-rw-r--r-- | drivers/net/irda/mcs7780.c | 2 | ||||
-rw-r--r-- | drivers/net/irda/stir4200.c | 2 | ||||
-rw-r--r-- | drivers/net/tulip/de4x5.c | 35 | ||||
-rw-r--r-- | drivers/net/tulip/de4x5.h | 2 | ||||
-rw-r--r-- | drivers/net/tulip/tulip.h | 7 | ||||
-rw-r--r-- | drivers/net/tulip/tulip_core.c | 10 | ||||
-rw-r--r-- | drivers/net/yellowfin.c | 2 |
9 files changed, 30 insertions, 34 deletions
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 2d139ec79777..f3cba5e24ec5 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -1802,7 +1802,7 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) | |||
1802 | * it is protected by the before last buffer's el bit being set */ | 1802 | * it is protected by the before last buffer's el bit being set */ |
1803 | if (rx->prev->skb) { | 1803 | if (rx->prev->skb) { |
1804 | struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; | 1804 | struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; |
1805 | put_unaligned(cpu_to_le32(rx->dma_addr), &prev_rfd->link); | 1805 | put_unaligned_le32(rx->dma_addr, &prev_rfd->link); |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | return 0; | 1808 | return 0; |
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c index b53f6b6491b3..e5c2380f50ca 100644 --- a/drivers/net/hamachi.c +++ b/drivers/net/hamachi.c | |||
@@ -1508,7 +1508,7 @@ static int hamachi_rx(struct net_device *dev) | |||
1508 | hmp->rx_buf_sz, | 1508 | hmp->rx_buf_sz, |
1509 | PCI_DMA_FROMDEVICE); | 1509 | PCI_DMA_FROMDEVICE); |
1510 | buf_addr = (u8 *) hmp->rx_skbuff[entry]->data; | 1510 | buf_addr = (u8 *) hmp->rx_skbuff[entry]->data; |
1511 | frame_status = le32_to_cpu(get_unaligned((__le32*)&(buf_addr[data_size - 12]))); | 1511 | frame_status = get_unaligned_le32(&(buf_addr[data_size - 12])); |
1512 | if (hamachi_debug > 4) | 1512 | if (hamachi_debug > 4) |
1513 | printk(KERN_DEBUG " hamachi_rx() status was %8.8x.\n", | 1513 | printk(KERN_DEBUG " hamachi_rx() status was %8.8x.\n", |
1514 | frame_status); | 1514 | frame_status); |
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c index 93916cf33f29..ad92d3ff1c40 100644 --- a/drivers/net/irda/mcs7780.c +++ b/drivers/net/irda/mcs7780.c | |||
@@ -464,7 +464,7 @@ static void mcs_unwrap_fir(struct mcs_cb *mcs, __u8 *buf, int len) | |||
464 | } | 464 | } |
465 | 465 | ||
466 | fcs = ~(crc32_le(~0, buf, new_len)); | 466 | fcs = ~(crc32_le(~0, buf, new_len)); |
467 | if(fcs != le32_to_cpu(get_unaligned((__le32 *)(buf+new_len)))) { | 467 | if(fcs != get_unaligned_le32(buf + new_len)) { |
468 | IRDA_ERROR("crc error calc 0x%x len %d\n", fcs, new_len); | 468 | IRDA_ERROR("crc error calc 0x%x len %d\n", fcs, new_len); |
469 | mcs->stats.rx_errors++; | 469 | mcs->stats.rx_errors++; |
470 | mcs->stats.rx_crc_errors++; | 470 | mcs->stats.rx_crc_errors++; |
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c index e59c485bc497..051963782749 100644 --- a/drivers/net/irda/stir4200.c +++ b/drivers/net/irda/stir4200.c | |||
@@ -329,7 +329,7 @@ static void fir_eof(struct stir_cb *stir) | |||
329 | } | 329 | } |
330 | 330 | ||
331 | fcs = ~(crc32_le(~0, rx_buff->data, len)); | 331 | fcs = ~(crc32_le(~0, rx_buff->data, len)); |
332 | if (fcs != le32_to_cpu(get_unaligned((__le32 *)(rx_buff->data+len)))) { | 332 | if (fcs != get_unaligned_le32(rx_buff->data + len)) { |
333 | pr_debug("crc error calc 0x%x len %d\n", fcs, len); | 333 | pr_debug("crc error calc 0x%x len %d\n", fcs, len); |
334 | stir->stats.rx_errors++; | 334 | stir->stats.rx_errors++; |
335 | stir->stats.rx_crc_errors++; | 335 | stir->stats.rx_crc_errors++; |
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c index 6c6fc325c8f9..bc30c6e8fea2 100644 --- a/drivers/net/tulip/de4x5.c +++ b/drivers/net/tulip/de4x5.c | |||
@@ -482,7 +482,6 @@ | |||
482 | static char version[] __devinitdata = "de4x5.c:V0.546 2001/02/22 davies@maniac.ultranet.com\n"; | 482 | static char version[] __devinitdata = "de4x5.c:V0.546 2001/02/22 davies@maniac.ultranet.com\n"; |
483 | 483 | ||
484 | #define c_char const char | 484 | #define c_char const char |
485 | #define TWIDDLE(a) (u_short)le16_to_cpu(get_unaligned((__le16 *)(a))) | ||
486 | 485 | ||
487 | /* | 486 | /* |
488 | ** MII Information | 487 | ** MII Information |
@@ -4405,7 +4404,7 @@ srom_infoleaf_info(struct net_device *dev) | |||
4405 | } | 4404 | } |
4406 | } | 4405 | } |
4407 | 4406 | ||
4408 | lp->infoleaf_offset = TWIDDLE(p+1); | 4407 | lp->infoleaf_offset = get_unaligned_le16(p + 1); |
4409 | 4408 | ||
4410 | return 0; | 4409 | return 0; |
4411 | } | 4410 | } |
@@ -4476,7 +4475,7 @@ srom_exec(struct net_device *dev, u_char *p) | |||
4476 | 4475 | ||
4477 | while (count--) { | 4476 | while (count--) { |
4478 | gep_wr(((lp->chipset==DC21140) && (lp->ibn!=5) ? | 4477 | gep_wr(((lp->chipset==DC21140) && (lp->ibn!=5) ? |
4479 | *p++ : TWIDDLE(w++)), dev); | 4478 | *p++ : get_unaligned_le16(w++)), dev); |
4480 | mdelay(2); /* 2ms per action */ | 4479 | mdelay(2); /* 2ms per action */ |
4481 | } | 4480 | } |
4482 | 4481 | ||
@@ -4711,10 +4710,10 @@ type1_infoblock(struct net_device *dev, u_char count, u_char *p) | |||
4711 | lp->active = *p++; | 4710 | lp->active = *p++; |
4712 | lp->phy[lp->active].gep = (*p ? p : NULL); p += (*p + 1); | 4711 | lp->phy[lp->active].gep = (*p ? p : NULL); p += (*p + 1); |
4713 | lp->phy[lp->active].rst = (*p ? p : NULL); p += (*p + 1); | 4712 | lp->phy[lp->active].rst = (*p ? p : NULL); p += (*p + 1); |
4714 | lp->phy[lp->active].mc = TWIDDLE(p); p += 2; | 4713 | lp->phy[lp->active].mc = get_unaligned_le16(p); p += 2; |
4715 | lp->phy[lp->active].ana = TWIDDLE(p); p += 2; | 4714 | lp->phy[lp->active].ana = get_unaligned_le16(p); p += 2; |
4716 | lp->phy[lp->active].fdx = TWIDDLE(p); p += 2; | 4715 | lp->phy[lp->active].fdx = get_unaligned_le16(p); p += 2; |
4717 | lp->phy[lp->active].ttm = TWIDDLE(p); | 4716 | lp->phy[lp->active].ttm = get_unaligned_le16(p); |
4718 | return 0; | 4717 | return 0; |
4719 | } else if ((lp->media == INIT) && (lp->timeout < 0)) { | 4718 | } else if ((lp->media == INIT) && (lp->timeout < 0)) { |
4720 | lp->ibn = 1; | 4719 | lp->ibn = 1; |
@@ -4751,16 +4750,16 @@ type2_infoblock(struct net_device *dev, u_char count, u_char *p) | |||
4751 | lp->infoblock_media = (*p) & MEDIA_CODE; | 4750 | lp->infoblock_media = (*p) & MEDIA_CODE; |
4752 | 4751 | ||
4753 | if ((*p++) & EXT_FIELD) { | 4752 | if ((*p++) & EXT_FIELD) { |
4754 | lp->cache.csr13 = TWIDDLE(p); p += 2; | 4753 | lp->cache.csr13 = get_unaligned_le16(p); p += 2; |
4755 | lp->cache.csr14 = TWIDDLE(p); p += 2; | 4754 | lp->cache.csr14 = get_unaligned_le16(p); p += 2; |
4756 | lp->cache.csr15 = TWIDDLE(p); p += 2; | 4755 | lp->cache.csr15 = get_unaligned_le16(p); p += 2; |
4757 | } else { | 4756 | } else { |
4758 | lp->cache.csr13 = CSR13; | 4757 | lp->cache.csr13 = CSR13; |
4759 | lp->cache.csr14 = CSR14; | 4758 | lp->cache.csr14 = CSR14; |
4760 | lp->cache.csr15 = CSR15; | 4759 | lp->cache.csr15 = CSR15; |
4761 | } | 4760 | } |
4762 | lp->cache.gepc = ((s32)(TWIDDLE(p)) << 16); p += 2; | 4761 | lp->cache.gepc = ((s32)(get_unaligned_le16(p)) << 16); p += 2; |
4763 | lp->cache.gep = ((s32)(TWIDDLE(p)) << 16); | 4762 | lp->cache.gep = ((s32)(get_unaligned_le16(p)) << 16); |
4764 | lp->infoblock_csr6 = OMR_SIA; | 4763 | lp->infoblock_csr6 = OMR_SIA; |
4765 | lp->useMII = false; | 4764 | lp->useMII = false; |
4766 | 4765 | ||
@@ -4792,10 +4791,10 @@ type3_infoblock(struct net_device *dev, u_char count, u_char *p) | |||
4792 | if (MOTO_SROM_BUG) lp->active = 0; | 4791 | if (MOTO_SROM_BUG) lp->active = 0; |
4793 | lp->phy[lp->active].gep = (*p ? p : NULL); p += (2 * (*p) + 1); | 4792 | lp->phy[lp->active].gep = (*p ? p : NULL); p += (2 * (*p) + 1); |
4794 | lp->phy[lp->active].rst = (*p ? p : NULL); p += (2 * (*p) + 1); | 4793 | lp->phy[lp->active].rst = (*p ? p : NULL); p += (2 * (*p) + 1); |
4795 | lp->phy[lp->active].mc = TWIDDLE(p); p += 2; | 4794 | lp->phy[lp->active].mc = get_unaligned_le16(p); p += 2; |
4796 | lp->phy[lp->active].ana = TWIDDLE(p); p += 2; | 4795 | lp->phy[lp->active].ana = get_unaligned_le16(p); p += 2; |
4797 | lp->phy[lp->active].fdx = TWIDDLE(p); p += 2; | 4796 | lp->phy[lp->active].fdx = get_unaligned_le16(p); p += 2; |
4798 | lp->phy[lp->active].ttm = TWIDDLE(p); p += 2; | 4797 | lp->phy[lp->active].ttm = get_unaligned_le16(p); p += 2; |
4799 | lp->phy[lp->active].mci = *p; | 4798 | lp->phy[lp->active].mci = *p; |
4800 | return 0; | 4799 | return 0; |
4801 | } else if ((lp->media == INIT) && (lp->timeout < 0)) { | 4800 | } else if ((lp->media == INIT) && (lp->timeout < 0)) { |
@@ -4835,8 +4834,8 @@ type4_infoblock(struct net_device *dev, u_char count, u_char *p) | |||
4835 | lp->cache.csr13 = CSR13; /* Hard coded defaults */ | 4834 | lp->cache.csr13 = CSR13; /* Hard coded defaults */ |
4836 | lp->cache.csr14 = CSR14; | 4835 | lp->cache.csr14 = CSR14; |
4837 | lp->cache.csr15 = CSR15; | 4836 | lp->cache.csr15 = CSR15; |
4838 | lp->cache.gepc = ((s32)(TWIDDLE(p)) << 16); p += 2; | 4837 | lp->cache.gepc = ((s32)(get_unaligned_le16(p)) << 16); p += 2; |
4839 | lp->cache.gep = ((s32)(TWIDDLE(p)) << 16); p += 2; | 4838 | lp->cache.gep = ((s32)(get_unaligned_le16(p)) << 16); p += 2; |
4840 | csr6 = *p++; | 4839 | csr6 = *p++; |
4841 | flags = *p++; | 4840 | flags = *p++; |
4842 | 4841 | ||
diff --git a/drivers/net/tulip/de4x5.h b/drivers/net/tulip/de4x5.h index 9fb8d7f07994..f5f33b3eb067 100644 --- a/drivers/net/tulip/de4x5.h +++ b/drivers/net/tulip/de4x5.h | |||
@@ -1017,4 +1017,4 @@ struct de4x5_ioctl { | |||
1017 | #define DE4X5_SET_OMR 0x0d /* Set the OMR Register contents */ | 1017 | #define DE4X5_SET_OMR 0x0d /* Set the OMR Register contents */ |
1018 | #define DE4X5_GET_REG 0x0e /* Get the DE4X5 Registers */ | 1018 | #define DE4X5_GET_REG 0x0e /* Get the DE4X5 Registers */ |
1019 | 1019 | ||
1020 | #define MOTO_SROM_BUG ((lp->active == 8) && (((le32_to_cpu(get_unaligned(((__le32 *)dev->dev_addr))))&0x00ffffff)==0x3e0008)) | 1020 | #define MOTO_SROM_BUG (lp->active == 8 && (get_unaligned_le32(dev->dev_addr) & 0x00ffffff) == 0x3e0008) |
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h index 908422f2f320..92c68a22f16b 100644 --- a/drivers/net/tulip/tulip.h +++ b/drivers/net/tulip/tulip.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
26 | #include <asm/io.h> | 26 | #include <asm/io.h> |
27 | #include <asm/irq.h> | 27 | #include <asm/irq.h> |
28 | #include <asm/unaligned.h> | ||
28 | 29 | ||
29 | 30 | ||
30 | 31 | ||
@@ -304,11 +305,7 @@ enum t21143_csr6_bits { | |||
304 | 305 | ||
305 | #define RUN_AT(x) (jiffies + (x)) | 306 | #define RUN_AT(x) (jiffies + (x)) |
306 | 307 | ||
307 | #if defined(__i386__) /* AKA get_unaligned() */ | 308 | #define get_u16(ptr) get_unaligned_le16((ptr)) |
308 | #define get_u16(ptr) (*(u16 *)(ptr)) | ||
309 | #else | ||
310 | #define get_u16(ptr) (((u8*)(ptr))[0] + (((u8*)(ptr))[1]<<8)) | ||
311 | #endif | ||
312 | 309 | ||
313 | struct medialeaf { | 310 | struct medialeaf { |
314 | u8 type; | 311 | u8 type; |
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c index fa1c1c329a2d..f9d13fa05d64 100644 --- a/drivers/net/tulip/tulip_core.c +++ b/drivers/net/tulip/tulip_core.c | |||
@@ -327,8 +327,8 @@ static void tulip_up(struct net_device *dev) | |||
327 | tp->dirty_rx = tp->dirty_tx = 0; | 327 | tp->dirty_rx = tp->dirty_tx = 0; |
328 | 328 | ||
329 | if (tp->flags & MC_HASH_ONLY) { | 329 | if (tp->flags & MC_HASH_ONLY) { |
330 | u32 addr_low = le32_to_cpu(get_unaligned((__le32 *)dev->dev_addr)); | 330 | u32 addr_low = get_unaligned_le32(dev->dev_addr); |
331 | u32 addr_high = le16_to_cpu(get_unaligned((__le16 *)(dev->dev_addr+4))); | 331 | u32 addr_high = get_unaligned_le16(dev->dev_addr + 4); |
332 | if (tp->chip_id == AX88140) { | 332 | if (tp->chip_id == AX88140) { |
333 | iowrite32(0, ioaddr + CSR13); | 333 | iowrite32(0, ioaddr + CSR13); |
334 | iowrite32(addr_low, ioaddr + CSR14); | 334 | iowrite32(addr_low, ioaddr + CSR14); |
@@ -1437,13 +1437,13 @@ static int __devinit tulip_init_one (struct pci_dev *pdev, | |||
1437 | do | 1437 | do |
1438 | value = ioread32(ioaddr + CSR9); | 1438 | value = ioread32(ioaddr + CSR9); |
1439 | while (value < 0 && --boguscnt > 0); | 1439 | while (value < 0 && --boguscnt > 0); |
1440 | put_unaligned(cpu_to_le16(value), ((__le16*)dev->dev_addr) + i); | 1440 | put_unaligned_le16(value, ((__le16 *)dev->dev_addr) + i); |
1441 | sum += value & 0xffff; | 1441 | sum += value & 0xffff; |
1442 | } | 1442 | } |
1443 | } else if (chip_idx == COMET) { | 1443 | } else if (chip_idx == COMET) { |
1444 | /* No need to read the EEPROM. */ | 1444 | /* No need to read the EEPROM. */ |
1445 | put_unaligned(cpu_to_le32(ioread32(ioaddr + 0xA4)), (__le32 *)dev->dev_addr); | 1445 | put_unaligned_le32(ioread32(ioaddr + 0xA4), dev->dev_addr); |
1446 | put_unaligned(cpu_to_le16(ioread32(ioaddr + 0xA8)), (__le16 *)(dev->dev_addr + 4)); | 1446 | put_unaligned_le16(ioread32(ioaddr + 0xA8), dev->dev_addr + 4); |
1447 | for (i = 0; i < 6; i ++) | 1447 | for (i = 0; i < 6; i ++) |
1448 | sum += dev->dev_addr[i]; | 1448 | sum += dev->dev_addr[i]; |
1449 | } else { | 1449 | } else { |
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c index 24640726f8bb..57e1f495b9fc 100644 --- a/drivers/net/yellowfin.c +++ b/drivers/net/yellowfin.c | |||
@@ -1062,7 +1062,7 @@ static int yellowfin_rx(struct net_device *dev) | |||
1062 | buf_addr = rx_skb->data; | 1062 | buf_addr = rx_skb->data; |
1063 | data_size = (le32_to_cpu(desc->dbdma_cmd) - | 1063 | data_size = (le32_to_cpu(desc->dbdma_cmd) - |
1064 | le32_to_cpu(desc->result_status)) & 0xffff; | 1064 | le32_to_cpu(desc->result_status)) & 0xffff; |
1065 | frame_status = le16_to_cpu(get_unaligned((__le16*)&(buf_addr[data_size - 2]))); | 1065 | frame_status = get_unaligned_le16(&(buf_addr[data_size - 2])); |
1066 | if (yellowfin_debug > 4) | 1066 | if (yellowfin_debug > 4) |
1067 | printk(KERN_DEBUG " yellowfin_rx() status was %4.4x.\n", | 1067 | printk(KERN_DEBUG " yellowfin_rx() status was %4.4x.\n", |
1068 | frame_status); | 1068 | frame_status); |