[PATCH] pcnet32: magic number cleanup

Change some magic numbers to clearer names.  A few whitespace changes.

Tested ia32 and ppc64.

Signed-off-by:  Don Fry <brazilnut@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
Don Fry 2006-09-13 10:16:07 -07:00 committed by Jeff Garzik
parent 5c99346a33
commit b368a3fbe4

View File

@ -207,7 +207,7 @@ static int homepna[MAX_UNITS];
/* The PCNET32 Rx and Tx ring descriptors. */ /* The PCNET32 Rx and Tx ring descriptors. */
struct pcnet32_rx_head { struct pcnet32_rx_head {
u32 base; u32 base;
s16 buf_length; s16 buf_length; /* two`s complement of length */
s16 status; s16 status;
u32 msg_length; u32 msg_length;
u32 reserved; u32 reserved;
@ -215,7 +215,7 @@ struct pcnet32_rx_head {
struct pcnet32_tx_head { struct pcnet32_tx_head {
u32 base; u32 base;
s16 length; s16 length; /* two`s complement of length */
s16 status; s16 status;
u32 misc; u32 misc;
u32 reserved; u32 reserved;
@ -804,7 +804,7 @@ static int pcnet32_set_ringparam(struct net_device *dev,
} }
if ((1 << i) != lp->tx_ring_size) if ((1 << i) != lp->tx_ring_size)
pcnet32_realloc_tx_ring(dev, lp, i); pcnet32_realloc_tx_ring(dev, lp, i);
size = min(ering->rx_pending, (unsigned int)RX_MAX_RING_SIZE); size = min(ering->rx_pending, (unsigned int)RX_MAX_RING_SIZE);
for (i = 2; i <= PCNET32_LOG_MAX_RX_BUFFERS; i++) { for (i = 2; i <= PCNET32_LOG_MAX_RX_BUFFERS; i++) {
if (size <= (1 << i)) if (size <= (1 << i))
@ -812,7 +812,7 @@ static int pcnet32_set_ringparam(struct net_device *dev,
} }
if ((1 << i) != lp->rx_ring_size) if ((1 << i) != lp->rx_ring_size)
pcnet32_realloc_rx_ring(dev, lp, i); pcnet32_realloc_rx_ring(dev, lp, i);
dev->weight = lp->rx_ring_size / 2; dev->weight = lp->rx_ring_size / 2;
if (netif_running(dev)) { if (netif_running(dev)) {
@ -892,7 +892,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
/* Reset the PCNET32 */ /* Reset the PCNET32 */
lp->a.reset(ioaddr); lp->a.reset(ioaddr);
lp->a.write_csr(ioaddr, CSR4, 0x0915); lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */
/* switch pcnet32 to 32bit mode */ /* switch pcnet32 to 32bit mode */
lp->a.write_bcr(ioaddr, 20, 2); lp->a.write_bcr(ioaddr, 20, 2);
@ -1602,7 +1602,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
* boards will work. * boards will work.
*/ */
/* Trigger an initialization just for the interrupt. */ /* Trigger an initialization just for the interrupt. */
a->write_csr(ioaddr, 0, 0x41); a->write_csr(ioaddr, CSR0, CSR0_INTEN | CSR0_INIT);
mdelay(1); mdelay(1);
dev->irq = probe_irq_off(irq_mask); dev->irq = probe_irq_off(irq_mask);
@ -1965,9 +1965,9 @@ static int pcnet32_open(struct net_device *dev)
#ifdef DO_DXSUFLO #ifdef DO_DXSUFLO
if (lp->dxsuflo) { /* Disable transmit stop on underflow */ if (lp->dxsuflo) { /* Disable transmit stop on underflow */
val = lp->a.read_csr(ioaddr, 3); val = lp->a.read_csr(ioaddr, CSR3);
val |= 0x40; val |= 0x40;
lp->a.write_csr(ioaddr, 3, val); lp->a.write_csr(ioaddr, CSR3, val);
} }
#endif #endif
@ -1988,8 +1988,8 @@ static int pcnet32_open(struct net_device *dev)
(lp->dma_addr + (lp->dma_addr +
offsetof(struct pcnet32_private, init_block)) >> 16); offsetof(struct pcnet32_private, init_block)) >> 16);
lp->a.write_csr(ioaddr, 4, 0x0915); lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */
lp->a.write_csr(ioaddr, 0, 0x0001); lp->a.write_csr(ioaddr, CSR0, CSR0_INIT);
netif_start_queue(dev); netif_start_queue(dev);
@ -2001,13 +2001,13 @@ static int pcnet32_open(struct net_device *dev)
i = 0; i = 0;
while (i++ < 100) while (i++ < 100)
if (lp->a.read_csr(ioaddr, 0) & 0x0100) if (lp->a.read_csr(ioaddr, CSR0) & CSR0_IDON)
break; break;
/* /*
* We used to clear the InitDone bit, 0x0100, here but Mark Stockton * We used to clear the InitDone bit, 0x0100, here but Mark Stockton
* reports that doing so triggers a bug in the '974. * reports that doing so triggers a bug in the '974.
*/ */
lp->a.write_csr(ioaddr, 0, 0x0042); lp->a.write_csr(ioaddr, CSR0, CSR0_NORMAL);
if (netif_msg_ifup(lp)) if (netif_msg_ifup(lp))
printk(KERN_DEBUG printk(KERN_DEBUG
@ -2015,7 +2015,7 @@ static int pcnet32_open(struct net_device *dev)
dev->name, i, dev->name, i,
(u32) (lp->dma_addr + (u32) (lp->dma_addr +
offsetof(struct pcnet32_private, init_block)), offsetof(struct pcnet32_private, init_block)),
lp->a.read_csr(ioaddr, 0)); lp->a.read_csr(ioaddr, CSR0));
spin_unlock_irqrestore(&lp->lock, flags); spin_unlock_irqrestore(&lp->lock, flags);
@ -2086,7 +2086,7 @@ static int pcnet32_init_ring(struct net_device *dev)
(rx_skbuff = lp->rx_skbuff[i] = (rx_skbuff = lp->rx_skbuff[i] =
dev_alloc_skb(PKT_BUF_SZ))) { dev_alloc_skb(PKT_BUF_SZ))) {
/* there is not much, we can do at this point */ /* there is not much, we can do at this point */
if (pcnet32_debug & NETIF_MSG_DRV) if (netif_msg_drv(lp))
printk(KERN_ERR printk(KERN_ERR
"%s: pcnet32_init_ring dev_alloc_skb failed.\n", "%s: pcnet32_init_ring dev_alloc_skb failed.\n",
dev->name); dev->name);
@ -2136,7 +2136,7 @@ static void pcnet32_restart(struct net_device *dev, unsigned int csr0_bits)
/* wait for stop */ /* wait for stop */
for (i = 0; i < 100; i++) for (i = 0; i < 100; i++)
if (lp->a.read_csr(ioaddr, 0) & 0x0004) if (lp->a.read_csr(ioaddr, CSR0) & CSR0_STOP)
break; break;
if (i >= 100 && netif_msg_drv(lp)) if (i >= 100 && netif_msg_drv(lp))
@ -2149,13 +2149,13 @@ static void pcnet32_restart(struct net_device *dev, unsigned int csr0_bits)
return; return;
/* ReInit Ring */ /* ReInit Ring */
lp->a.write_csr(ioaddr, 0, 1); lp->a.write_csr(ioaddr, CSR0, CSR0_INIT);
i = 0; i = 0;
while (i++ < 1000) while (i++ < 1000)
if (lp->a.read_csr(ioaddr, 0) & 0x0100) if (lp->a.read_csr(ioaddr, CSR0) & CSR0_IDON)
break; break;
lp->a.write_csr(ioaddr, 0, csr0_bits); lp->a.write_csr(ioaddr, CSR0, csr0_bits);
} }
static void pcnet32_tx_timeout(struct net_device *dev) static void pcnet32_tx_timeout(struct net_device *dev)
@ -2168,8 +2168,8 @@ static void pcnet32_tx_timeout(struct net_device *dev)
if (pcnet32_debug & NETIF_MSG_DRV) if (pcnet32_debug & NETIF_MSG_DRV)
printk(KERN_ERR printk(KERN_ERR
"%s: transmit timed out, status %4.4x, resetting.\n", "%s: transmit timed out, status %4.4x, resetting.\n",
dev->name, lp->a.read_csr(ioaddr, 0)); dev->name, lp->a.read_csr(ioaddr, CSR0));
lp->a.write_csr(ioaddr, 0, 0x0004); lp->a.write_csr(ioaddr, CSR0, CSR0_STOP);
lp->stats.tx_errors++; lp->stats.tx_errors++;
if (netif_msg_tx_err(lp)) { if (netif_msg_tx_err(lp)) {
int i; int i;
@ -2191,7 +2191,7 @@ static void pcnet32_tx_timeout(struct net_device *dev)
le16_to_cpu(lp->tx_ring[i].status)); le16_to_cpu(lp->tx_ring[i].status));
printk("\n"); printk("\n");
} }
pcnet32_restart(dev, 0x0042); pcnet32_restart(dev, CSR0_NORMAL);
dev->trans_start = jiffies; dev->trans_start = jiffies;
netif_wake_queue(dev); netif_wake_queue(dev);
@ -2212,7 +2212,7 @@ static int pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (netif_msg_tx_queued(lp)) { if (netif_msg_tx_queued(lp)) {
printk(KERN_DEBUG printk(KERN_DEBUG
"%s: pcnet32_start_xmit() called, csr0 %4.4x.\n", "%s: pcnet32_start_xmit() called, csr0 %4.4x.\n",
dev->name, lp->a.read_csr(ioaddr, 0)); dev->name, lp->a.read_csr(ioaddr, CSR0));
} }
/* Default status -- will not enable Successful-TxDone /* Default status -- will not enable Successful-TxDone
@ -2243,7 +2243,7 @@ static int pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
lp->stats.tx_bytes += skb->len; lp->stats.tx_bytes += skb->len;
/* Trigger an immediate send poll. */ /* Trigger an immediate send poll. */
lp->a.write_csr(ioaddr, 0, 0x0048); lp->a.write_csr(ioaddr, CSR0, CSR0_INTEN | CSR0_TXPOLL);
dev->trans_start = jiffies; dev->trans_start = jiffies;
@ -2425,18 +2425,18 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs *regs)
if (must_restart) { if (must_restart) {
/* reset the chip to clear the error condition, then restart */ /* reset the chip to clear the error condition, then restart */
lp->a.reset(ioaddr); lp->a.reset(ioaddr);
lp->a.write_csr(ioaddr, 4, 0x0915); lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */
pcnet32_restart(dev, 0x0002); pcnet32_restart(dev, CSR0_START);
netif_wake_queue(dev); netif_wake_queue(dev);
} }
} }
/* Set interrupt enable. */ /* Set interrupt enable. */
lp->a.write_csr(ioaddr, 0, 0x0040); lp->a.write_csr(ioaddr, CSR0, CSR0_INTEN);
if (netif_msg_intr(lp)) if (netif_msg_intr(lp))
printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n", printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n",
dev->name, lp->a.read_csr(ioaddr, 0)); dev->name, lp->a.read_csr(ioaddr, CSR0));
spin_unlock(&lp->lock); spin_unlock(&lp->lock);
@ -2616,10 +2616,10 @@ static int pcnet32_close(struct net_device *dev)
if (netif_msg_ifdown(lp)) if (netif_msg_ifdown(lp))
printk(KERN_DEBUG printk(KERN_DEBUG
"%s: Shutting down ethercard, status was %2.2x.\n", "%s: Shutting down ethercard, status was %2.2x.\n",
dev->name, lp->a.read_csr(ioaddr, 0)); dev->name, lp->a.read_csr(ioaddr, CSR0));
/* We stop the PCNET32 here -- it occasionally polls memory if we don't. */ /* We stop the PCNET32 here -- it occasionally polls memory if we don't. */
lp->a.write_csr(ioaddr, 0, 0x0004); lp->a.write_csr(ioaddr, CSR0, CSR0_STOP);
/* /*
* Switch back to 16bit mode to avoid problems with dumb * Switch back to 16bit mode to avoid problems with dumb
@ -2734,7 +2734,7 @@ static void pcnet32_set_multicast_list(struct net_device *dev)
/* clear SUSPEND (SPND) - CSR5 bit 0 */ /* clear SUSPEND (SPND) - CSR5 bit 0 */
csr5 = lp->a.read_csr(ioaddr, CSR5); csr5 = lp->a.read_csr(ioaddr, CSR5);
lp->a.write_csr(ioaddr, CSR5, csr5 & (~CSR5_SUSPEND)); lp->a.write_csr(ioaddr, CSR5, csr5 & (~CSR5_SUSPEND));
} else { } else {
lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); lp->a.write_csr(ioaddr, CSR0, CSR0_STOP);
pcnet32_restart(dev, CSR0_NORMAL); pcnet32_restart(dev, CSR0_NORMAL);
netif_wake_queue(dev); netif_wake_queue(dev);