aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/pcnet32.c62
1 files changed, 41 insertions, 21 deletions
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 70fe81a89df9..31e6dd049859 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -22,8 +22,8 @@
22 *************************************************************************/ 22 *************************************************************************/
23 23
24#define DRV_NAME "pcnet32" 24#define DRV_NAME "pcnet32"
25#define DRV_VERSION "1.31a" 25#define DRV_VERSION "1.31b"
26#define DRV_RELDATE "12.Sep.2005" 26#define DRV_RELDATE "06.Oct.2005"
27#define PFX DRV_NAME ": " 27#define PFX DRV_NAME ": "
28 28
29static const char *version = 29static const char *version =
@@ -260,6 +260,8 @@ static int homepna[MAX_UNITS];
260 * v1.31 02 Sep 2005 Hubert WS Lin <wslin@tw.ibm.c0m> added set_ringparam(). 260 * v1.31 02 Sep 2005 Hubert WS Lin <wslin@tw.ibm.c0m> added set_ringparam().
261 * v1.31a 12 Sep 2005 Hubert WS Lin <wslin@tw.ibm.c0m> set min ring size to 4 261 * v1.31a 12 Sep 2005 Hubert WS Lin <wslin@tw.ibm.c0m> set min ring size to 4
262 * to allow loopback test to work unchanged. 262 * to allow loopback test to work unchanged.
263 * v1.31b 06 Oct 2005 Don Fry changed alloc_ring to show name of device
264 * if allocation fails
263 */ 265 */
264 266
265 267
@@ -408,7 +410,7 @@ static int pcnet32_get_regs_len(struct net_device *dev);
408static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs, 410static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs,
409 void *ptr); 411 void *ptr);
410static void pcnet32_purge_tx_ring(struct net_device *dev); 412static void pcnet32_purge_tx_ring(struct net_device *dev);
411static int pcnet32_alloc_ring(struct net_device *dev); 413static int pcnet32_alloc_ring(struct net_device *dev, char *name);
412static void pcnet32_free_ring(struct net_device *dev); 414static void pcnet32_free_ring(struct net_device *dev);
413 415
414 416
@@ -669,15 +671,17 @@ static int pcnet32_set_ringparam(struct net_device *dev, struct ethtool_ringpara
669 lp->rx_mod_mask = lp->rx_ring_size - 1; 671 lp->rx_mod_mask = lp->rx_ring_size - 1;
670 lp->rx_len_bits = (i << 4); 672 lp->rx_len_bits = (i << 4);
671 673
672 if (pcnet32_alloc_ring(dev)) { 674 if (pcnet32_alloc_ring(dev, dev->name)) {
673 pcnet32_free_ring(dev); 675 pcnet32_free_ring(dev);
676 spin_unlock_irqrestore(&lp->lock, flags);
674 return -ENOMEM; 677 return -ENOMEM;
675 } 678 }
676 679
677 spin_unlock_irqrestore(&lp->lock, flags); 680 spin_unlock_irqrestore(&lp->lock, flags);
678 681
679 if (pcnet32_debug & NETIF_MSG_DRV) 682 if (pcnet32_debug & NETIF_MSG_DRV)
680 printk(KERN_INFO PFX "Ring Param Settings: RX: %d, TX: %d\n", lp->rx_ring_size, lp->tx_ring_size); 683 printk(KERN_INFO PFX "%s: Ring Param Settings: RX: %d, TX: %d\n",
684 dev->name, lp->rx_ring_size, lp->tx_ring_size);
681 685
682 if (netif_running(dev)) 686 if (netif_running(dev))
683 pcnet32_open(dev); 687 pcnet32_open(dev);
@@ -1340,7 +1344,8 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1340 } 1344 }
1341 lp->a = *a; 1345 lp->a = *a;
1342 1346
1343 if (pcnet32_alloc_ring(dev)) { 1347 /* prior to register_netdev, dev->name is not yet correct */
1348 if (pcnet32_alloc_ring(dev, pci_name(lp->pci_dev))) {
1344 ret = -ENOMEM; 1349 ret = -ENOMEM;
1345 goto err_free_ring; 1350 goto err_free_ring;
1346 } 1351 }
@@ -1448,48 +1453,63 @@ err_release_region:
1448} 1453}
1449 1454
1450 1455
1451static int pcnet32_alloc_ring(struct net_device *dev) 1456/* if any allocation fails, caller must also call pcnet32_free_ring */
1457static int pcnet32_alloc_ring(struct net_device *dev, char *name)
1452{ 1458{
1453 struct pcnet32_private *lp = dev->priv; 1459 struct pcnet32_private *lp = dev->priv;
1454 1460
1455 if ((lp->tx_ring = pci_alloc_consistent(lp->pci_dev, sizeof(struct pcnet32_tx_head) * lp->tx_ring_size, 1461 lp->tx_ring = pci_alloc_consistent(lp->pci_dev,
1456 &lp->tx_ring_dma_addr)) == NULL) { 1462 sizeof(struct pcnet32_tx_head) * lp->tx_ring_size,
1463 &lp->tx_ring_dma_addr);
1464 if (lp->tx_ring == NULL) {
1457 if (pcnet32_debug & NETIF_MSG_DRV) 1465 if (pcnet32_debug & NETIF_MSG_DRV)
1458 printk(KERN_ERR PFX "Consistent memory allocation failed.\n"); 1466 printk("\n" KERN_ERR PFX "%s: Consistent memory allocation failed.\n",
1467 name);
1459 return -ENOMEM; 1468 return -ENOMEM;
1460 } 1469 }
1461 1470
1462 if ((lp->rx_ring = pci_alloc_consistent(lp->pci_dev, sizeof(struct pcnet32_rx_head) * lp->rx_ring_size, 1471 lp->rx_ring = pci_alloc_consistent(lp->pci_dev,
1463 &lp->rx_ring_dma_addr)) == NULL) { 1472 sizeof(struct pcnet32_rx_head) * lp->rx_ring_size,
1473 &lp->rx_ring_dma_addr);
1474 if (lp->rx_ring == NULL) {
1464 if (pcnet32_debug & NETIF_MSG_DRV) 1475 if (pcnet32_debug & NETIF_MSG_DRV)
1465 printk(KERN_ERR PFX "Consistent memory allocation failed.\n"); 1476 printk("\n" KERN_ERR PFX "%s: Consistent memory allocation failed.\n",
1477 name);
1466 return -ENOMEM; 1478 return -ENOMEM;
1467 } 1479 }
1468 1480
1469 if (!(lp->tx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->tx_ring_size, GFP_ATOMIC))) { 1481 lp->tx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->tx_ring_size,
1482 GFP_ATOMIC);
1483 if (!lp->tx_dma_addr) {
1470 if (pcnet32_debug & NETIF_MSG_DRV) 1484 if (pcnet32_debug & NETIF_MSG_DRV)
1471 printk(KERN_ERR PFX "Memory allocation failed.\n"); 1485 printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
1472 return -ENOMEM; 1486 return -ENOMEM;
1473 } 1487 }
1474 memset(lp->tx_dma_addr, 0, sizeof(dma_addr_t) * lp->tx_ring_size); 1488 memset(lp->tx_dma_addr, 0, sizeof(dma_addr_t) * lp->tx_ring_size);
1475 1489
1476 if (!(lp->rx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->rx_ring_size, GFP_ATOMIC))) { 1490 lp->rx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->rx_ring_size,
1491 GFP_ATOMIC);
1492 if (!lp->rx_dma_addr) {
1477 if (pcnet32_debug & NETIF_MSG_DRV) 1493 if (pcnet32_debug & NETIF_MSG_DRV)
1478 printk(KERN_ERR PFX "Memory allocation failed.\n"); 1494 printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
1479 return -ENOMEM; 1495 return -ENOMEM;
1480 } 1496 }
1481 memset(lp->rx_dma_addr, 0, sizeof(dma_addr_t) * lp->rx_ring_size); 1497 memset(lp->rx_dma_addr, 0, sizeof(dma_addr_t) * lp->rx_ring_size);
1482 1498
1483 if (!(lp->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->tx_ring_size, GFP_ATOMIC))) { 1499 lp->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->tx_ring_size,
1500 GFP_ATOMIC);
1501 if (!lp->tx_skbuff) {
1484 if (pcnet32_debug & NETIF_MSG_DRV) 1502 if (pcnet32_debug & NETIF_MSG_DRV)
1485 printk(KERN_ERR PFX "Memory allocation failed.\n"); 1503 printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
1486 return -ENOMEM; 1504 return -ENOMEM;
1487 } 1505 }
1488 memset(lp->tx_skbuff, 0, sizeof(struct sk_buff *) * lp->tx_ring_size); 1506 memset(lp->tx_skbuff, 0, sizeof(struct sk_buff *) * lp->tx_ring_size);
1489 1507
1490 if (!(lp->rx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->rx_ring_size, GFP_ATOMIC))) { 1508 lp->rx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->rx_ring_size,
1509 GFP_ATOMIC);
1510 if (!lp->rx_skbuff) {
1491 if (pcnet32_debug & NETIF_MSG_DRV) 1511 if (pcnet32_debug & NETIF_MSG_DRV)
1492 printk(KERN_ERR PFX "Memory allocation failed.\n"); 1512 printk("\n" KERN_ERR PFX "%s: Memory allocation failed.\n", name);
1493 return -ENOMEM; 1513 return -ENOMEM;
1494 } 1514 }
1495 memset(lp->rx_skbuff, 0, sizeof(struct sk_buff *) * lp->rx_ring_size); 1515 memset(lp->rx_skbuff, 0, sizeof(struct sk_buff *) * lp->rx_ring_size);