Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: tulip: convert to devres

Works fine on my HP C3600:

[ 274.452394] tulip0: no phy info, aborting mtable build
[ 274.499041] tulip0: MII transceiver #1 config 1000 status 782d advertising 01e1
[ 274.750691] net eth0: Digital DS21142/43 Tulip rev 65 at MMIO 0xf4008000, 00:30:6e:08:7d:21, IRQ 17
[ 283.104520] net eth0: Setting full-duplex based on MII#1 link partner capability of c1e1

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Rolf Eike Beer and committed by
David S. Miller
3daebfbe 382d917b

+20 -51
+4 -3
drivers/net/ethernet/dec/tulip/eeprom.c
··· 117 117 0x00, 0x06 /* ttm bit map */ 118 118 }; 119 119 120 - tp->mtable = kmalloc(sizeof(struct mediatable) + 121 - sizeof(struct medialeaf), GFP_KERNEL); 120 + tp->mtable = devm_kmalloc(&tp->pdev->pdev, sizeof(struct mediatable) + 121 + sizeof(struct medialeaf), GFP_KERNEL); 122 122 123 123 if (tp->mtable == NULL) 124 124 return; /* Horrible, impossible failure. */ ··· 224 224 return; 225 225 } 226 226 227 - mtable = kmalloc(struct_size(mtable, mleaf, count), GFP_KERNEL); 227 + mtable = devm_kmalloc(&tp->pdev->dev, struct_size(mtable, mleaf, count), 228 + GFP_KERNEL); 228 229 if (mtable == NULL) 229 230 return; /* Horrible, impossible failure. */ 230 231 last_mediatable = tp->mtable = mtable;
+16 -48
drivers/net/ethernet/dec/tulip/tulip_core.c
··· 1389 1389 * And back to business 1390 1390 */ 1391 1391 1392 - i = pci_enable_device(pdev); 1392 + i = pcim_enable_device(pdev); 1393 1393 if (i) { 1394 1394 pr_err("Cannot enable tulip board #%d, aborting\n", board_idx); 1395 1395 return i; ··· 1398 1398 irq = pdev->irq; 1399 1399 1400 1400 /* alloc_etherdev ensures aligned and zeroed private structures */ 1401 - dev = alloc_etherdev (sizeof (*tp)); 1402 - if (!dev) { 1403 - pci_disable_device(pdev); 1401 + dev = devm_alloc_etherdev(&pdev->dev, sizeof(*tp)); 1402 + if (!dev) 1404 1403 return -ENOMEM; 1405 - } 1406 1404 1407 1405 SET_NETDEV_DEV(dev, &pdev->dev); 1408 1406 if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) { ··· 1408 1410 pci_name(pdev), 1409 1411 (unsigned long long)pci_resource_len (pdev, 0), 1410 1412 (unsigned long long)pci_resource_start (pdev, 0)); 1411 - goto err_out_free_netdev; 1413 + return -ENODEV; 1412 1414 } 1413 1415 1414 1416 /* grab all resources from both PIO and MMIO regions, as we 1415 1417 * don't want anyone else messing around with our hardware */ 1416 - if (pci_request_regions (pdev, DRV_NAME)) 1417 - goto err_out_free_netdev; 1418 + if (pci_request_regions(pdev, DRV_NAME)) 1419 + return -ENODEV; 1418 1420 1419 - ioaddr = pci_iomap(pdev, TULIP_BAR, tulip_tbl[chip_idx].io_size); 1421 + ioaddr = pcim_iomap(pdev, TULIP_BAR, tulip_tbl[chip_idx].io_size); 1420 1422 1421 1423 if (!ioaddr) 1422 - goto err_out_free_res; 1424 + return -ENODEV; 1423 1425 1424 1426 /* 1425 1427 * initialize private data structure 'tp' ··· 1428 1430 tp = netdev_priv(dev); 1429 1431 tp->dev = dev; 1430 1432 1431 - tp->rx_ring = dma_alloc_coherent(&pdev->dev, 1432 - sizeof(struct tulip_rx_desc) * RX_RING_SIZE + 1433 - sizeof(struct tulip_tx_desc) * TX_RING_SIZE, 1434 - &tp->rx_ring_dma, GFP_KERNEL); 1433 + tp->rx_ring = dmam_alloc_coherent(&pdev->dev, 1434 + sizeof(struct tulip_rx_desc) * RX_RING_SIZE + 1435 + sizeof(struct tulip_tx_desc) * TX_RING_SIZE, 1436 + &tp->rx_ring_dma, GFP_KERNEL); 1435 1437 if (!tp->rx_ring) 1436 - goto err_out_mtable; 1438 + return -ENODEV; 1437 1439 tp->tx_ring = (struct tulip_tx_desc *)(tp->rx_ring + RX_RING_SIZE); 1438 1440 tp->tx_ring_dma = tp->rx_ring_dma + sizeof(struct tulip_rx_desc) * RX_RING_SIZE; 1439 1441 ··· 1693 1695 #endif 1694 1696 dev->ethtool_ops = &ops; 1695 1697 1696 - if (register_netdev(dev)) 1697 - goto err_out_free_ring; 1698 + i = register_netdev(dev); 1699 + if (i) 1700 + return i; 1698 1701 1699 1702 pci_set_drvdata(pdev, dev); 1700 1703 ··· 1770 1771 tulip_set_power_state (tp, 0, 1); 1771 1772 1772 1773 return 0; 1773 - 1774 - err_out_free_ring: 1775 - dma_free_coherent(&pdev->dev, 1776 - sizeof(struct tulip_rx_desc) * RX_RING_SIZE + 1777 - sizeof(struct tulip_tx_desc) * TX_RING_SIZE, 1778 - tp->rx_ring, tp->rx_ring_dma); 1779 - 1780 - err_out_mtable: 1781 - kfree (tp->mtable); 1782 - pci_iounmap(pdev, ioaddr); 1783 - 1784 - err_out_free_res: 1785 - pci_release_regions (pdev); 1786 - 1787 - err_out_free_netdev: 1788 - free_netdev (dev); 1789 - pci_disable_device(pdev); 1790 - return -ENODEV; 1791 1774 } 1792 1775 1793 1776 ··· 1869 1888 static void tulip_remove_one(struct pci_dev *pdev) 1870 1889 { 1871 1890 struct net_device *dev = pci_get_drvdata (pdev); 1872 - struct tulip_private *tp; 1873 1891 1874 1892 if (!dev) 1875 1893 return; 1876 1894 1877 - tp = netdev_priv(dev); 1878 1895 unregister_netdev(dev); 1879 - dma_free_coherent(&pdev->dev, 1880 - sizeof(struct tulip_rx_desc) * RX_RING_SIZE + 1881 - sizeof(struct tulip_tx_desc) * TX_RING_SIZE, 1882 - tp->rx_ring, tp->rx_ring_dma); 1883 - kfree (tp->mtable); 1884 - pci_iounmap(pdev, tp->base_addr); 1885 - free_netdev (dev); 1886 - pci_release_regions (pdev); 1887 - pci_disable_device(pdev); 1888 - 1889 - /* pci_power_off (pdev, -1); */ 1890 1896 } 1891 1897 1892 1898 #ifdef CONFIG_NET_POLL_CONTROLLER