aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2007-12-22 13:55:29 -0500
committerJeff Garzik <jeff@garzik.org>2007-12-22 22:53:07 -0500
commitcf96237837ec6d4fc48bc2f735c71027cc0fc5fa (patch)
tree6ef598ca69fda2cf5e713312cf6ce225864e7f48 /drivers
parent95e0918dbb6d83020ef3eb0a4276413264abd14d (diff)
rrunner: use offsetof() instead of homegrown insanity
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/rrunner.c49
-rw-r--r--drivers/net/rrunner.h2
2 files changed, 25 insertions, 26 deletions
diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c
index 73a7e6529ee0..55a590ab1e17 100644
--- a/drivers/net/rrunner.c
+++ b/drivers/net/rrunner.c
@@ -294,7 +294,6 @@ static int rr_reset(struct net_device *dev)
294{ 294{
295 struct rr_private *rrpriv; 295 struct rr_private *rrpriv;
296 struct rr_regs __iomem *regs; 296 struct rr_regs __iomem *regs;
297 struct eeprom *hw = NULL;
298 u32 start_pc; 297 u32 start_pc;
299 int i; 298 int i;
300 299
@@ -381,7 +380,8 @@ static int rr_reset(struct net_device *dev)
381 writel(RBURST_64|WBURST_64, &regs->PciState); 380 writel(RBURST_64|WBURST_64, &regs->PciState);
382 wmb(); 381 wmb();
383 382
384 start_pc = rr_read_eeprom_word(rrpriv, &hw->rncd_info.FwStart); 383 start_pc = rr_read_eeprom_word(rrpriv,
384 offsetof(struct eeprom, rncd_info.FwStart));
385 385
386#if (DEBUG > 1) 386#if (DEBUG > 1)
387 printk("%s: Executing firmware at address 0x%06x\n", 387 printk("%s: Executing firmware at address 0x%06x\n",
@@ -438,12 +438,12 @@ static unsigned int rr_read_eeprom(struct rr_private *rrpriv,
438 * it to our CPU byte-order. 438 * it to our CPU byte-order.
439 */ 439 */
440static u32 rr_read_eeprom_word(struct rr_private *rrpriv, 440static u32 rr_read_eeprom_word(struct rr_private *rrpriv,
441 void * offset) 441 size_t offset)
442{ 442{
443 u32 word; 443 __be32 word;
444 444
445 if ((rr_read_eeprom(rrpriv, (unsigned long)offset, 445 if ((rr_read_eeprom(rrpriv, offset,
446 (char *)&word, 4) == 4)) 446 (unsigned char *)&word, 4) == 4))
447 return be32_to_cpu(word); 447 return be32_to_cpu(word);
448 return 0; 448 return 0;
449} 449}
@@ -510,7 +510,6 @@ static int __devinit rr_init(struct net_device *dev)
510{ 510{
511 struct rr_private *rrpriv; 511 struct rr_private *rrpriv;
512 struct rr_regs __iomem *regs; 512 struct rr_regs __iomem *regs;
513 struct eeprom *hw = NULL;
514 u32 sram_size, rev; 513 u32 sram_size, rev;
515 DECLARE_MAC_BUF(mac); 514 DECLARE_MAC_BUF(mac);
516 515
@@ -545,14 +544,14 @@ static int __devinit rr_init(struct net_device *dev)
545 * other method I've seen. -VAL 544 * other method I've seen. -VAL
546 */ 545 */
547 546
548 *(u16 *)(dev->dev_addr) = 547 *(__be16 *)(dev->dev_addr) =
549 htons(rr_read_eeprom_word(rrpriv, &hw->manf.BoardULA)); 548 htons(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA)));
550 *(u32 *)(dev->dev_addr+2) = 549 *(__be32 *)(dev->dev_addr+2) =
551 htonl(rr_read_eeprom_word(rrpriv, &hw->manf.BoardULA[4])); 550 htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4])));
552 551
553 printk(" MAC: %s\n", print_mac(mac, dev->dev_addr)); 552 printk(" MAC: %s\n", print_mac(mac, dev->dev_addr));
554 553
555 sram_size = rr_read_eeprom_word(rrpriv, (void *)8); 554 sram_size = rr_read_eeprom_word(rrpriv, 8);
556 printk(" SRAM size 0x%06x\n", sram_size); 555 printk(" SRAM size 0x%06x\n", sram_size);
557 556
558 return 0; 557 return 0;
@@ -1477,11 +1476,10 @@ static int rr_load_firmware(struct net_device *dev)
1477{ 1476{
1478 struct rr_private *rrpriv; 1477 struct rr_private *rrpriv;
1479 struct rr_regs __iomem *regs; 1478 struct rr_regs __iomem *regs;
1480 unsigned long eptr, segptr; 1479 size_t eptr, segptr;
1481 int i, j; 1480 int i, j;
1482 u32 localctrl, sptr, len, tmp; 1481 u32 localctrl, sptr, len, tmp;
1483 u32 p2len, p2size, nr_seg, revision, io, sram_size; 1482 u32 p2len, p2size, nr_seg, revision, io, sram_size;
1484 struct eeprom *hw = NULL;
1485 1483
1486 rrpriv = netdev_priv(dev); 1484 rrpriv = netdev_priv(dev);
1487 regs = rrpriv->regs; 1485 regs = rrpriv->regs;
@@ -1509,7 +1507,7 @@ static int rr_load_firmware(struct net_device *dev)
1509 */ 1507 */
1510 io = readl(&regs->ExtIo); 1508 io = readl(&regs->ExtIo);
1511 writel(0, &regs->ExtIo); 1509 writel(0, &regs->ExtIo);
1512 sram_size = rr_read_eeprom_word(rrpriv, (void *)8); 1510 sram_size = rr_read_eeprom_word(rrpriv, 8);
1513 1511
1514 for (i = 200; i < sram_size / 4; i++){ 1512 for (i = 200; i < sram_size / 4; i++){
1515 writel(i * 4, &regs->WinBase); 1513 writel(i * 4, &regs->WinBase);
@@ -1520,13 +1518,13 @@ static int rr_load_firmware(struct net_device *dev)
1520 writel(io, &regs->ExtIo); 1518 writel(io, &regs->ExtIo);
1521 mb(); 1519 mb();
1522 1520
1523 eptr = (unsigned long)rr_read_eeprom_word(rrpriv, 1521 eptr = rr_read_eeprom_word(rrpriv,
1524 &hw->rncd_info.AddrRunCodeSegs); 1522 offsetof(struct eeprom, rncd_info.AddrRunCodeSegs));
1525 eptr = ((eptr & 0x1fffff) >> 3); 1523 eptr = ((eptr & 0x1fffff) >> 3);
1526 1524
1527 p2len = rr_read_eeprom_word(rrpriv, (void *)(0x83*4)); 1525 p2len = rr_read_eeprom_word(rrpriv, 0x83*4);
1528 p2len = (p2len << 2); 1526 p2len = (p2len << 2);
1529 p2size = rr_read_eeprom_word(rrpriv, (void *)(0x84*4)); 1527 p2size = rr_read_eeprom_word(rrpriv, 0x84*4);
1530 p2size = ((p2size & 0x1fffff) >> 3); 1528 p2size = ((p2size & 0x1fffff) >> 3);
1531 1529
1532 if ((eptr < p2size) || (eptr > (p2size + p2len))){ 1530 if ((eptr < p2size) || (eptr > (p2size + p2len))){
@@ -1534,7 +1532,8 @@ static int rr_load_firmware(struct net_device *dev)
1534 goto out; 1532 goto out;
1535 } 1533 }
1536 1534
1537 revision = rr_read_eeprom_word(rrpriv, &hw->manf.HeaderFmt); 1535 revision = rr_read_eeprom_word(rrpriv,
1536 offsetof(struct eeprom, manf.HeaderFmt));
1538 1537
1539 if (revision != 1){ 1538 if (revision != 1){
1540 printk("%s: invalid firmware format (%i)\n", 1539 printk("%s: invalid firmware format (%i)\n",
@@ -1542,18 +1541,18 @@ static int rr_load_firmware(struct net_device *dev)
1542 goto out; 1541 goto out;
1543 } 1542 }
1544 1543
1545 nr_seg = rr_read_eeprom_word(rrpriv, (void *)eptr); 1544 nr_seg = rr_read_eeprom_word(rrpriv, eptr);
1546 eptr +=4; 1545 eptr +=4;
1547#if (DEBUG > 1) 1546#if (DEBUG > 1)
1548 printk("%s: nr_seg %i\n", dev->name, nr_seg); 1547 printk("%s: nr_seg %i\n", dev->name, nr_seg);
1549#endif 1548#endif
1550 1549
1551 for (i = 0; i < nr_seg; i++){ 1550 for (i = 0; i < nr_seg; i++){
1552 sptr = rr_read_eeprom_word(rrpriv, (void *)eptr); 1551 sptr = rr_read_eeprom_word(rrpriv, eptr);
1553 eptr += 4; 1552 eptr += 4;
1554 len = rr_read_eeprom_word(rrpriv, (void *)eptr); 1553 len = rr_read_eeprom_word(rrpriv, eptr);
1555 eptr += 4; 1554 eptr += 4;
1556 segptr = (unsigned long)rr_read_eeprom_word(rrpriv, (void *)eptr); 1555 segptr = rr_read_eeprom_word(rrpriv, eptr);
1557 segptr = ((segptr & 0x1fffff) >> 3); 1556 segptr = ((segptr & 0x1fffff) >> 3);
1558 eptr += 4; 1557 eptr += 4;
1559#if (DEBUG > 1) 1558#if (DEBUG > 1)
@@ -1561,7 +1560,7 @@ static int rr_load_firmware(struct net_device *dev)
1561 dev->name, i, sptr, len, segptr); 1560 dev->name, i, sptr, len, segptr);
1562#endif 1561#endif
1563 for (j = 0; j < len; j++){ 1562 for (j = 0; j < len; j++){
1564 tmp = rr_read_eeprom_word(rrpriv, (void *)segptr); 1563 tmp = rr_read_eeprom_word(rrpriv, segptr);
1565 writel(sptr, &regs->WinBase); 1564 writel(sptr, &regs->WinBase);
1566 mb(); 1565 mb();
1567 writel(tmp, &regs->WinData); 1566 writel(tmp, &regs->WinData);
diff --git a/drivers/net/rrunner.h b/drivers/net/rrunner.h
index 6a79825bc8cf..6173f11218df 100644
--- a/drivers/net/rrunner.h
+++ b/drivers/net/rrunner.h
@@ -838,7 +838,7 @@ static unsigned int rr_read_eeprom(struct rr_private *rrpriv,
838 unsigned long offset, 838 unsigned long offset,
839 unsigned char *buf, 839 unsigned char *buf,
840 unsigned long length); 840 unsigned long length);
841static u32 rr_read_eeprom_word(struct rr_private *rrpriv, void * offset); 841static u32 rr_read_eeprom_word(struct rr_private *rrpriv, size_t offset);
842static int rr_load_firmware(struct net_device *dev); 842static int rr_load_firmware(struct net_device *dev);
843static inline void rr_raz_tx(struct rr_private *, struct net_device *); 843static inline void rr_raz_tx(struct rr_private *, struct net_device *);
844static inline void rr_raz_rx(struct rr_private *, struct net_device *); 844static inline void rr_raz_rx(struct rr_private *, struct net_device *);