aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2005-11-06 19:50:46 -0500
committerJeff Garzik <jgarzik@pobox.com>2005-11-07 03:37:05 -0500
commit874a6214bc1477004a0dd6f881b078d0d6b1eae9 (patch)
treebf01333dce3b5ee11d1d9187efd7317fffb18ac5
parentc719369350bc566d2643067421fbf05f4b90e70b (diff)
[PATCH] b44: miscellaneous cleanup
- remove unneeded forward declarations - s/kmalloc + memset/kzalloc/ - whitespace readjustement can't hurt - wrong comment: b44_init_rings _is_ called with a spinlock held in b44_{open/set_ringparam/set_pauseparam/etc}. Actually, it does not need to be able to sleep - b44_remove_one() can not be issued with a NULL device in its private member: remove the test. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r--drivers/net/b44.c67
1 files changed, 28 insertions, 39 deletions
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index b334cc310bc1..3b6428f004f6 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -102,10 +102,6 @@ MODULE_DEVICE_TABLE(pci, b44_pci_tbl);
102static void b44_halt(struct b44 *); 102static void b44_halt(struct b44 *);
103static void b44_init_rings(struct b44 *); 103static void b44_init_rings(struct b44 *);
104static void b44_init_hw(struct b44 *); 104static void b44_init_hw(struct b44 *);
105static int b44_poll(struct net_device *dev, int *budget);
106#ifdef CONFIG_NET_POLL_CONTROLLER
107static void b44_poll_controller(struct net_device *dev);
108#endif
109 105
110static int dma_desc_align_mask; 106static int dma_desc_align_mask;
111static int dma_desc_sync_size; 107static int dma_desc_sync_size;
@@ -653,7 +649,7 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
653 649
654 /* Hardware bug work-around, the chip is unable to do PCI DMA 650 /* Hardware bug work-around, the chip is unable to do PCI DMA
655 to/from anything above 1GB :-( */ 651 to/from anything above 1GB :-( */
656 if(mapping+RX_PKT_BUF_SZ > B44_DMA_MASK) { 652 if (mapping + RX_PKT_BUF_SZ > B44_DMA_MASK) {
657 /* Sigh... */ 653 /* Sigh... */
658 pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE); 654 pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE);
659 dev_kfree_skb_any(skb); 655 dev_kfree_skb_any(skb);
@@ -663,7 +659,7 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
663 mapping = pci_map_single(bp->pdev, skb->data, 659 mapping = pci_map_single(bp->pdev, skb->data,
664 RX_PKT_BUF_SZ, 660 RX_PKT_BUF_SZ,
665 PCI_DMA_FROMDEVICE); 661 PCI_DMA_FROMDEVICE);
666 if(mapping+RX_PKT_BUF_SZ > B44_DMA_MASK) { 662 if (mapping + RX_PKT_BUF_SZ > B44_DMA_MASK) {
667 pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE); 663 pci_unmap_single(bp->pdev, mapping, RX_PKT_BUF_SZ,PCI_DMA_FROMDEVICE);
668 dev_kfree_skb_any(skb); 664 dev_kfree_skb_any(skb);
669 return -ENOMEM; 665 return -ENOMEM;
@@ -964,7 +960,7 @@ static int b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
964 } 960 }
965 961
966 mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE); 962 mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE);
967 if(mapping+len > B44_DMA_MASK) { 963 if (mapping + len > B44_DMA_MASK) {
968 /* Chip can't handle DMA to/from >1GB, use bounce buffer */ 964 /* Chip can't handle DMA to/from >1GB, use bounce buffer */
969 pci_unmap_single(bp->pdev, mapping, len, PCI_DMA_TODEVICE); 965 pci_unmap_single(bp->pdev, mapping, len, PCI_DMA_TODEVICE);
970 966
@@ -975,7 +971,7 @@ static int b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
975 971
976 mapping = pci_map_single(bp->pdev, bounce_skb->data, 972 mapping = pci_map_single(bp->pdev, bounce_skb->data,
977 len, PCI_DMA_TODEVICE); 973 len, PCI_DMA_TODEVICE);
978 if(mapping+len > B44_DMA_MASK) { 974 if (mapping + len > B44_DMA_MASK) {
979 pci_unmap_single(bp->pdev, mapping, 975 pci_unmap_single(bp->pdev, mapping,
980 len, PCI_DMA_TODEVICE); 976 len, PCI_DMA_TODEVICE);
981 dev_kfree_skb_any(bounce_skb); 977 dev_kfree_skb_any(bounce_skb);
@@ -1102,8 +1098,7 @@ static void b44_free_rings(struct b44 *bp)
1102 * 1098 *
1103 * The chip has been shut down and the driver detached from 1099 * The chip has been shut down and the driver detached from
1104 * the networking, so no interrupts or new tx packets will 1100 * the networking, so no interrupts or new tx packets will
1105 * end up in the driver. bp->lock is not held and we are not 1101 * end up in the driver.
1106 * in an interrupt context and thus may sleep.
1107 */ 1102 */
1108static void b44_init_rings(struct b44 *bp) 1103static void b44_init_rings(struct b44 *bp)
1109{ 1104{
@@ -1175,16 +1170,14 @@ static int b44_alloc_consistent(struct b44 *bp)
1175 int size; 1170 int size;
1176 1171
1177 size = B44_RX_RING_SIZE * sizeof(struct ring_info); 1172 size = B44_RX_RING_SIZE * sizeof(struct ring_info);
1178 bp->rx_buffers = kmalloc(size, GFP_KERNEL); 1173 bp->rx_buffers = kzalloc(size, GFP_KERNEL);
1179 if (!bp->rx_buffers) 1174 if (!bp->rx_buffers)
1180 goto out_err; 1175 goto out_err;
1181 memset(bp->rx_buffers, 0, size);
1182 1176
1183 size = B44_TX_RING_SIZE * sizeof(struct ring_info); 1177 size = B44_TX_RING_SIZE * sizeof(struct ring_info);
1184 bp->tx_buffers = kmalloc(size, GFP_KERNEL); 1178 bp->tx_buffers = kzalloc(size, GFP_KERNEL);
1185 if (!bp->tx_buffers) 1179 if (!bp->tx_buffers)
1186 goto out_err; 1180 goto out_err;
1187 memset(bp->tx_buffers, 0, size);
1188 1181
1189 size = DMA_TABLE_BYTES; 1182 size = DMA_TABLE_BYTES;
1190 bp->rx_ring = pci_alloc_consistent(bp->pdev, size, &bp->rx_ring_dma); 1183 bp->rx_ring = pci_alloc_consistent(bp->pdev, size, &bp->rx_ring_dma);
@@ -1195,10 +1188,10 @@ static int b44_alloc_consistent(struct b44 *bp)
1195 struct dma_desc *rx_ring; 1188 struct dma_desc *rx_ring;
1196 dma_addr_t rx_ring_dma; 1189 dma_addr_t rx_ring_dma;
1197 1190
1198 if (!(rx_ring = (struct dma_desc *)kmalloc(size, GFP_KERNEL))) 1191 rx_ring = kzalloc(size, GFP_KERNEL);
1192 if (!rx_ring)
1199 goto out_err; 1193 goto out_err;
1200 1194
1201 memset(rx_ring, 0, size);
1202 rx_ring_dma = dma_map_single(&bp->pdev->dev, rx_ring, 1195 rx_ring_dma = dma_map_single(&bp->pdev->dev, rx_ring,
1203 DMA_TABLE_BYTES, 1196 DMA_TABLE_BYTES,
1204 DMA_BIDIRECTIONAL); 1197 DMA_BIDIRECTIONAL);
@@ -1221,10 +1214,10 @@ static int b44_alloc_consistent(struct b44 *bp)
1221 struct dma_desc *tx_ring; 1214 struct dma_desc *tx_ring;
1222 dma_addr_t tx_ring_dma; 1215 dma_addr_t tx_ring_dma;
1223 1216
1224 if (!(tx_ring = (struct dma_desc *)kmalloc(size, GFP_KERNEL))) 1217 tx_ring = kzalloc(size, GFP_KERNEL);
1218 if (!tx_ring)
1225 goto out_err; 1219 goto out_err;
1226 1220
1227 memset(tx_ring, 0, size);
1228 tx_ring_dma = dma_map_single(&bp->pdev->dev, tx_ring, 1221 tx_ring_dma = dma_map_single(&bp->pdev->dev, tx_ring,
1229 DMA_TABLE_BYTES, 1222 DMA_TABLE_BYTES,
1230 DMA_TO_DEVICE); 1223 DMA_TO_DEVICE);
@@ -1530,8 +1523,6 @@ static void __b44_set_rx_mode(struct net_device *dev)
1530{ 1523{
1531 struct b44 *bp = netdev_priv(dev); 1524 struct b44 *bp = netdev_priv(dev);
1532 u32 val; 1525 u32 val;
1533 int i=0;
1534 unsigned char zero[6] = {0,0,0,0,0,0};
1535 1526
1536 val = br32(bp, B44_RXCONFIG); 1527 val = br32(bp, B44_RXCONFIG);
1537 val &= ~(RXCONFIG_PROMISC | RXCONFIG_ALLMULTI); 1528 val &= ~(RXCONFIG_PROMISC | RXCONFIG_ALLMULTI);
@@ -1539,14 +1530,17 @@ static void __b44_set_rx_mode(struct net_device *dev)
1539 val |= RXCONFIG_PROMISC; 1530 val |= RXCONFIG_PROMISC;
1540 bw32(bp, B44_RXCONFIG, val); 1531 bw32(bp, B44_RXCONFIG, val);
1541 } else { 1532 } else {
1533 unsigned char zero[6] = {0, 0, 0, 0, 0, 0};
1534 int i = 0;
1535
1542 __b44_set_mac_addr(bp); 1536 __b44_set_mac_addr(bp);
1543 1537
1544 if (dev->flags & IFF_ALLMULTI) 1538 if (dev->flags & IFF_ALLMULTI)
1545 val |= RXCONFIG_ALLMULTI; 1539 val |= RXCONFIG_ALLMULTI;
1546 else 1540 else
1547 i=__b44_load_mcast(bp, dev); 1541 i = __b44_load_mcast(bp, dev);
1548 1542
1549 for(;i<64;i++) { 1543 for (; i < 64; i++) {
1550 __b44_cam_write(bp, zero, i); 1544 __b44_cam_write(bp, zero, i);
1551 } 1545 }
1552 bw32(bp, B44_RXCONFIG, val); 1546 bw32(bp, B44_RXCONFIG, val);
@@ -1898,9 +1892,9 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
1898 1892
1899 err = pci_set_consistent_dma_mask(pdev, (u64) B44_DMA_MASK); 1893 err = pci_set_consistent_dma_mask(pdev, (u64) B44_DMA_MASK);
1900 if (err) { 1894 if (err) {
1901 printk(KERN_ERR PFX "No usable DMA configuration, " 1895 printk(KERN_ERR PFX "No usable DMA configuration, "
1902 "aborting.\n"); 1896 "aborting.\n");
1903 goto err_out_free_res; 1897 goto err_out_free_res;
1904 } 1898 }
1905 1899
1906 b44reg_base = pci_resource_start(pdev, 0); 1900 b44reg_base = pci_resource_start(pdev, 0);
@@ -1922,10 +1916,8 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
1922 bp = netdev_priv(dev); 1916 bp = netdev_priv(dev);
1923 bp->pdev = pdev; 1917 bp->pdev = pdev;
1924 bp->dev = dev; 1918 bp->dev = dev;
1925 if (b44_debug >= 0) 1919
1926 bp->msg_enable = (1 << b44_debug) - 1; 1920 bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE);
1927 else
1928 bp->msg_enable = B44_DEF_MSG_ENABLE;
1929 1921
1930 spin_lock_init(&bp->lock); 1922 spin_lock_init(&bp->lock);
1931 1923
@@ -2015,17 +2007,14 @@ err_out_disable_pdev:
2015static void __devexit b44_remove_one(struct pci_dev *pdev) 2007static void __devexit b44_remove_one(struct pci_dev *pdev)
2016{ 2008{
2017 struct net_device *dev = pci_get_drvdata(pdev); 2009 struct net_device *dev = pci_get_drvdata(pdev);
2010 struct b44 *bp = netdev_priv(dev);
2018 2011
2019 if (dev) { 2012 unregister_netdev(dev);
2020 struct b44 *bp = netdev_priv(dev); 2013 iounmap(bp->regs);
2021 2014 free_netdev(dev);
2022 unregister_netdev(dev); 2015 pci_release_regions(pdev);
2023 iounmap(bp->regs); 2016 pci_disable_device(pdev);
2024 free_netdev(dev); 2017 pci_set_drvdata(pdev, NULL);
2025 pci_release_regions(pdev);
2026 pci_disable_device(pdev);
2027 pci_set_drvdata(pdev, NULL);
2028 }
2029} 2018}
2030 2019
2031static int b44_suspend(struct pci_dev *pdev, pm_message_t state) 2020static int b44_suspend(struct pci_dev *pdev, pm_message_t state)