aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcnet32.c
diff options
context:
space:
mode:
authorDon Fry <brazilnut@us.ibm.com>2006-09-13 13:16:07 -0400
committerJeff Garzik <jeff@garzik.org>2006-09-13 13:23:52 -0400
commitb368a3fbe41c44e4c7eb628002bbd8891defa7e0 (patch)
treed0836b4797a29732182009b28084144eb79a323f /drivers/net/pcnet32.c
parent5c99346a3358a9c3c3fcf38669c05ac5f06832c9 (diff)
[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>
Diffstat (limited to 'drivers/net/pcnet32.c')
-rw-r--r--drivers/net/pcnet32.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 98b7ab281622..468c8bacb0d8 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -207,7 +207,7 @@ static int homepna[MAX_UNITS];
207/* The PCNET32 Rx and Tx ring descriptors. */ 207/* The PCNET32 Rx and Tx ring descriptors. */
208struct pcnet32_rx_head { 208struct pcnet32_rx_head {
209 u32 base; 209 u32 base;
210 s16 buf_length; 210 s16 buf_length; /* two`s complement of length */
211 s16 status; 211 s16 status;
212 u32 msg_length; 212 u32 msg_length;
213 u32 reserved; 213 u32 reserved;
@@ -215,7 +215,7 @@ struct pcnet32_rx_head {
215 215
216struct pcnet32_tx_head { 216struct pcnet32_tx_head {
217 u32 base; 217 u32 base;
218 s16 length; 218 s16 length; /* two`s complement of length */
219 s16 status; 219 s16 status;
220 u32 misc; 220 u32 misc;
221 u32 reserved; 221 u32 reserved;
@@ -804,7 +804,7 @@ static int pcnet32_set_ringparam(struct net_device *dev,
804 } 804 }
805 if ((1 << i) != lp->tx_ring_size) 805 if ((1 << i) != lp->tx_ring_size)
806 pcnet32_realloc_tx_ring(dev, lp, i); 806 pcnet32_realloc_tx_ring(dev, lp, i);
807 807
808 size = min(ering->rx_pending, (unsigned int)RX_MAX_RING_SIZE); 808 size = min(ering->rx_pending, (unsigned int)RX_MAX_RING_SIZE);
809 for (i = 2; i <= PCNET32_LOG_MAX_RX_BUFFERS; i++) { 809 for (i = 2; i <= PCNET32_LOG_MAX_RX_BUFFERS; i++) {
810 if (size <= (1 << i)) 810 if (size <= (1 << i))
@@ -812,7 +812,7 @@ static int pcnet32_set_ringparam(struct net_device *dev,
812 } 812 }
813 if ((1 << i) != lp->rx_ring_size) 813 if ((1 << i) != lp->rx_ring_size)
814 pcnet32_realloc_rx_ring(dev, lp, i); 814 pcnet32_realloc_rx_ring(dev, lp, i);
815 815
816 dev->weight = lp->rx_ring_size / 2; 816 dev->weight = lp->rx_ring_size / 2;
817 817
818 if (netif_running(dev)) { 818 if (netif_running(dev)) {
@@ -892,7 +892,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
892 892
893 /* Reset the PCNET32 */ 893 /* Reset the PCNET32 */
894 lp->a.reset(ioaddr); 894 lp->a.reset(ioaddr);
895 lp->a.write_csr(ioaddr, CSR4, 0x0915); 895 lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */
896 896
897 /* switch pcnet32 to 32bit mode */ 897 /* switch pcnet32 to 32bit mode */
898 lp->a.write_bcr(ioaddr, 20, 2); 898 lp->a.write_bcr(ioaddr, 20, 2);
@@ -1602,7 +1602,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1602 * boards will work. 1602 * boards will work.
1603 */ 1603 */
1604 /* Trigger an initialization just for the interrupt. */ 1604 /* Trigger an initialization just for the interrupt. */
1605 a->write_csr(ioaddr, 0, 0x41); 1605 a->write_csr(ioaddr, CSR0, CSR0_INTEN | CSR0_INIT);
1606 mdelay(1); 1606 mdelay(1);
1607 1607
1608 dev->irq = probe_irq_off(irq_mask); 1608 dev->irq = probe_irq_off(irq_mask);
@@ -1965,9 +1965,9 @@ static int pcnet32_open(struct net_device *dev)
1965 1965
1966#ifdef DO_DXSUFLO 1966#ifdef DO_DXSUFLO
1967 if (lp->dxsuflo) { /* Disable transmit stop on underflow */ 1967 if (lp->dxsuflo) { /* Disable transmit stop on underflow */
1968 val = lp->a.read_csr(ioaddr, 3); 1968 val = lp->a.read_csr(ioaddr, CSR3);
1969 val |= 0x40; 1969 val |= 0x40;
1970 lp->a.write_csr(ioaddr, 3, val); 1970 lp->a.write_csr(ioaddr, CSR3, val);
1971 } 1971 }
1972#endif 1972#endif
1973 1973
@@ -1988,8 +1988,8 @@ static int pcnet32_open(struct net_device *dev)
1988 (lp->dma_addr + 1988 (lp->dma_addr +
1989 offsetof(struct pcnet32_private, init_block)) >> 16); 1989 offsetof(struct pcnet32_private, init_block)) >> 16);
1990 1990
1991 lp->a.write_csr(ioaddr, 4, 0x0915); 1991 lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */
1992 lp->a.write_csr(ioaddr, 0, 0x0001); 1992 lp->a.write_csr(ioaddr, CSR0, CSR0_INIT);
1993 1993
1994 netif_start_queue(dev); 1994 netif_start_queue(dev);
1995 1995
@@ -2001,13 +2001,13 @@ static int pcnet32_open(struct net_device *dev)
2001 2001
2002 i = 0; 2002 i = 0;
2003 while (i++ < 100) 2003 while (i++ < 100)
2004 if (lp->a.read_csr(ioaddr, 0) & 0x0100) 2004 if (lp->a.read_csr(ioaddr, CSR0) & CSR0_IDON)
2005 break; 2005 break;
2006 /* 2006 /*
2007 * We used to clear the InitDone bit, 0x0100, here but Mark Stockton 2007 * We used to clear the InitDone bit, 0x0100, here but Mark Stockton
2008 * reports that doing so triggers a bug in the '974. 2008 * reports that doing so triggers a bug in the '974.
2009 */ 2009 */
2010 lp->a.write_csr(ioaddr, 0, 0x0042); 2010 lp->a.write_csr(ioaddr, CSR0, CSR0_NORMAL);
2011 2011
2012 if (netif_msg_ifup(lp)) 2012 if (netif_msg_ifup(lp))
2013 printk(KERN_DEBUG 2013 printk(KERN_DEBUG
@@ -2015,7 +2015,7 @@ static int pcnet32_open(struct net_device *dev)
2015 dev->name, i, 2015 dev->name, i,
2016 (u32) (lp->dma_addr + 2016 (u32) (lp->dma_addr +
2017 offsetof(struct pcnet32_private, init_block)), 2017 offsetof(struct pcnet32_private, init_block)),
2018 lp->a.read_csr(ioaddr, 0)); 2018 lp->a.read_csr(ioaddr, CSR0));
2019 2019
2020 spin_unlock_irqrestore(&lp->lock, flags); 2020 spin_unlock_irqrestore(&lp->lock, flags);
2021 2021
@@ -2086,7 +2086,7 @@ static int pcnet32_init_ring(struct net_device *dev)
2086 (rx_skbuff = lp->rx_skbuff[i] = 2086 (rx_skbuff = lp->rx_skbuff[i] =
2087 dev_alloc_skb(PKT_BUF_SZ))) { 2087 dev_alloc_skb(PKT_BUF_SZ))) {
2088 /* there is not much, we can do at this point */ 2088 /* there is not much, we can do at this point */
2089 if (pcnet32_debug & NETIF_MSG_DRV) 2089 if (netif_msg_drv(lp))
2090 printk(KERN_ERR 2090 printk(KERN_ERR
2091 "%s: pcnet32_init_ring dev_alloc_skb failed.\n", 2091 "%s: pcnet32_init_ring dev_alloc_skb failed.\n",
2092 dev->name); 2092 dev->name);
@@ -2136,7 +2136,7 @@ static void pcnet32_restart(struct net_device *dev, unsigned int csr0_bits)
2136 2136
2137 /* wait for stop */ 2137 /* wait for stop */
2138 for (i = 0; i < 100; i++) 2138 for (i = 0; i < 100; i++)
2139 if (lp->a.read_csr(ioaddr, 0) & 0x0004) 2139 if (lp->a.read_csr(ioaddr, CSR0) & CSR0_STOP)
2140 break; 2140 break;
2141 2141
2142 if (i >= 100 && netif_msg_drv(lp)) 2142 if (i >= 100 && netif_msg_drv(lp))
@@ -2149,13 +2149,13 @@ static void pcnet32_restart(struct net_device *dev, unsigned int csr0_bits)
2149 return; 2149 return;
2150 2150
2151 /* ReInit Ring */ 2151 /* ReInit Ring */
2152 lp->a.write_csr(ioaddr, 0, 1); 2152 lp->a.write_csr(ioaddr, CSR0, CSR0_INIT);
2153 i = 0; 2153 i = 0;
2154 while (i++ < 1000) 2154 while (i++ < 1000)
2155 if (lp->a.read_csr(ioaddr, 0) & 0x0100) 2155 if (lp->a.read_csr(ioaddr, CSR0) & CSR0_IDON)
2156 break; 2156 break;
2157 2157
2158 lp->a.write_csr(ioaddr, 0, csr0_bits); 2158 lp->a.write_csr(ioaddr, CSR0, csr0_bits);
2159} 2159}
2160 2160
2161static void pcnet32_tx_timeout(struct net_device *dev) 2161static void pcnet32_tx_timeout(struct net_device *dev)
@@ -2168,8 +2168,8 @@ static void pcnet32_tx_timeout(struct net_device *dev)
2168 if (pcnet32_debug & NETIF_MSG_DRV) 2168 if (pcnet32_debug & NETIF_MSG_DRV)
2169 printk(KERN_ERR 2169 printk(KERN_ERR
2170 "%s: transmit timed out, status %4.4x, resetting.\n", 2170 "%s: transmit timed out, status %4.4x, resetting.\n",
2171 dev->name, lp->a.read_csr(ioaddr, 0)); 2171 dev->name, lp->a.read_csr(ioaddr, CSR0));
2172 lp->a.write_csr(ioaddr, 0, 0x0004); 2172 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP);
2173 lp->stats.tx_errors++; 2173 lp->stats.tx_errors++;
2174 if (netif_msg_tx_err(lp)) { 2174 if (netif_msg_tx_err(lp)) {
2175 int i; 2175 int i;
@@ -2191,7 +2191,7 @@ static void pcnet32_tx_timeout(struct net_device *dev)
2191 le16_to_cpu(lp->tx_ring[i].status)); 2191 le16_to_cpu(lp->tx_ring[i].status));
2192 printk("\n"); 2192 printk("\n");
2193 } 2193 }
2194 pcnet32_restart(dev, 0x0042); 2194 pcnet32_restart(dev, CSR0_NORMAL);
2195 2195
2196 dev->trans_start = jiffies; 2196 dev->trans_start = jiffies;
2197 netif_wake_queue(dev); 2197 netif_wake_queue(dev);
@@ -2212,7 +2212,7 @@ static int pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
2212 if (netif_msg_tx_queued(lp)) { 2212 if (netif_msg_tx_queued(lp)) {
2213 printk(KERN_DEBUG 2213 printk(KERN_DEBUG
2214 "%s: pcnet32_start_xmit() called, csr0 %4.4x.\n", 2214 "%s: pcnet32_start_xmit() called, csr0 %4.4x.\n",
2215 dev->name, lp->a.read_csr(ioaddr, 0)); 2215 dev->name, lp->a.read_csr(ioaddr, CSR0));
2216 } 2216 }
2217 2217
2218 /* Default status -- will not enable Successful-TxDone 2218 /* Default status -- will not enable Successful-TxDone
@@ -2243,7 +2243,7 @@ static int pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
2243 lp->stats.tx_bytes += skb->len; 2243 lp->stats.tx_bytes += skb->len;
2244 2244
2245 /* Trigger an immediate send poll. */ 2245 /* Trigger an immediate send poll. */
2246 lp->a.write_csr(ioaddr, 0, 0x0048); 2246 lp->a.write_csr(ioaddr, CSR0, CSR0_INTEN | CSR0_TXPOLL);
2247 2247
2248 dev->trans_start = jiffies; 2248 dev->trans_start = jiffies;
2249 2249
@@ -2425,18 +2425,18 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2425 if (must_restart) { 2425 if (must_restart) {
2426 /* reset the chip to clear the error condition, then restart */ 2426 /* reset the chip to clear the error condition, then restart */
2427 lp->a.reset(ioaddr); 2427 lp->a.reset(ioaddr);
2428 lp->a.write_csr(ioaddr, 4, 0x0915); 2428 lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */
2429 pcnet32_restart(dev, 0x0002); 2429 pcnet32_restart(dev, CSR0_START);
2430 netif_wake_queue(dev); 2430 netif_wake_queue(dev);
2431 } 2431 }
2432 } 2432 }
2433 2433
2434 /* Set interrupt enable. */ 2434 /* Set interrupt enable. */
2435 lp->a.write_csr(ioaddr, 0, 0x0040); 2435 lp->a.write_csr(ioaddr, CSR0, CSR0_INTEN);
2436 2436
2437 if (netif_msg_intr(lp)) 2437 if (netif_msg_intr(lp))
2438 printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n", 2438 printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n",
2439 dev->name, lp->a.read_csr(ioaddr, 0)); 2439 dev->name, lp->a.read_csr(ioaddr, CSR0));
2440 2440
2441 spin_unlock(&lp->lock); 2441 spin_unlock(&lp->lock);
2442 2442
@@ -2616,10 +2616,10 @@ static int pcnet32_close(struct net_device *dev)
2616 if (netif_msg_ifdown(lp)) 2616 if (netif_msg_ifdown(lp))
2617 printk(KERN_DEBUG 2617 printk(KERN_DEBUG
2618 "%s: Shutting down ethercard, status was %2.2x.\n", 2618 "%s: Shutting down ethercard, status was %2.2x.\n",
2619 dev->name, lp->a.read_csr(ioaddr, 0)); 2619 dev->name, lp->a.read_csr(ioaddr, CSR0));
2620 2620
2621 /* We stop the PCNET32 here -- it occasionally polls memory if we don't. */ 2621 /* We stop the PCNET32 here -- it occasionally polls memory if we don't. */
2622 lp->a.write_csr(ioaddr, 0, 0x0004); 2622 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP);
2623 2623
2624 /* 2624 /*
2625 * Switch back to 16bit mode to avoid problems with dumb 2625 * Switch back to 16bit mode to avoid problems with dumb
@@ -2734,7 +2734,7 @@ static void pcnet32_set_multicast_list(struct net_device *dev)
2734 /* clear SUSPEND (SPND) - CSR5 bit 0 */ 2734 /* clear SUSPEND (SPND) - CSR5 bit 0 */
2735 csr5 = lp->a.read_csr(ioaddr, CSR5); 2735 csr5 = lp->a.read_csr(ioaddr, CSR5);
2736 lp->a.write_csr(ioaddr, CSR5, csr5 & (~CSR5_SUSPEND)); 2736 lp->a.write_csr(ioaddr, CSR5, csr5 & (~CSR5_SUSPEND));
2737 } else { 2737 } else {
2738 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); 2738 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP);
2739 pcnet32_restart(dev, CSR0_NORMAL); 2739 pcnet32_restart(dev, CSR0_NORMAL);
2740 netif_wake_queue(dev); 2740 netif_wake_queue(dev);