diff options
-rw-r--r-- | drivers/net/ethernet/cirrus/cs89x0.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/drivers/net/ethernet/cirrus/cs89x0.c b/drivers/net/ethernet/cirrus/cs89x0.c index fe84fbabc0d4..9823a0ea7937 100644 --- a/drivers/net/ethernet/cirrus/cs89x0.c +++ b/drivers/net/ethernet/cirrus/cs89x0.c | |||
@@ -145,7 +145,6 @@ struct net_local { | |||
145 | int force; /* force various values; see FORCE* above. */ | 145 | int force; /* force various values; see FORCE* above. */ |
146 | spinlock_t lock; | 146 | spinlock_t lock; |
147 | void __iomem *virt_addr;/* CS89x0 virtual address. */ | 147 | void __iomem *virt_addr;/* CS89x0 virtual address. */ |
148 | unsigned long size; /* Length of CS89x0 memory region. */ | ||
149 | #if ALLOW_DMA | 148 | #if ALLOW_DMA |
150 | int use_dma; /* Flag: we're using dma */ | 149 | int use_dma; /* Flag: we're using dma */ |
151 | int dma; /* DMA channel */ | 150 | int dma; /* DMA channel */ |
@@ -1854,41 +1853,29 @@ static int __init cs89x0_platform_probe(struct platform_device *pdev) | |||
1854 | 1853 | ||
1855 | lp = netdev_priv(dev); | 1854 | lp = netdev_priv(dev); |
1856 | 1855 | ||
1857 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1858 | dev->irq = platform_get_irq(pdev, 0); | 1856 | dev->irq = platform_get_irq(pdev, 0); |
1859 | if (mem_res == NULL || dev->irq <= 0) { | 1857 | if (dev->irq <= 0) { |
1860 | dev_warn(&dev->dev, "memory/interrupt resource missing\n"); | 1858 | dev_warn(&dev->dev, "interrupt resource missing\n"); |
1861 | err = -ENXIO; | 1859 | err = -ENXIO; |
1862 | goto free; | 1860 | goto free; |
1863 | } | 1861 | } |
1864 | 1862 | ||
1865 | lp->size = resource_size(mem_res); | 1863 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1866 | if (!request_mem_region(mem_res->start, lp->size, DRV_NAME)) { | 1864 | virt_addr = devm_ioremap_resource(&pdev->dev, mem_res); |
1867 | dev_warn(&dev->dev, "request_mem_region() failed\n"); | 1865 | if (IS_ERR(virt_addr)) { |
1868 | err = -EBUSY; | 1866 | err = PTR_ERR(virt_addr); |
1869 | goto free; | 1867 | goto free; |
1870 | } | 1868 | } |
1871 | 1869 | ||
1872 | virt_addr = ioremap(mem_res->start, lp->size); | ||
1873 | if (!virt_addr) { | ||
1874 | dev_warn(&dev->dev, "ioremap() failed\n"); | ||
1875 | err = -ENOMEM; | ||
1876 | goto release; | ||
1877 | } | ||
1878 | |||
1879 | err = cs89x0_probe1(dev, virt_addr, 0); | 1870 | err = cs89x0_probe1(dev, virt_addr, 0); |
1880 | if (err) { | 1871 | if (err) { |
1881 | dev_warn(&dev->dev, "no cs8900 or cs8920 detected\n"); | 1872 | dev_warn(&dev->dev, "no cs8900 or cs8920 detected\n"); |
1882 | goto unmap; | 1873 | goto free; |
1883 | } | 1874 | } |
1884 | 1875 | ||
1885 | platform_set_drvdata(pdev, dev); | 1876 | platform_set_drvdata(pdev, dev); |
1886 | return 0; | 1877 | return 0; |
1887 | 1878 | ||
1888 | unmap: | ||
1889 | iounmap(virt_addr); | ||
1890 | release: | ||
1891 | release_mem_region(mem_res->start, lp->size); | ||
1892 | free: | 1879 | free: |
1893 | free_netdev(dev); | 1880 | free_netdev(dev); |
1894 | return err; | 1881 | return err; |
@@ -1897,17 +1884,12 @@ free: | |||
1897 | static int cs89x0_platform_remove(struct platform_device *pdev) | 1884 | static int cs89x0_platform_remove(struct platform_device *pdev) |
1898 | { | 1885 | { |
1899 | struct net_device *dev = platform_get_drvdata(pdev); | 1886 | struct net_device *dev = platform_get_drvdata(pdev); |
1900 | struct net_local *lp = netdev_priv(dev); | ||
1901 | struct resource *mem_res; | ||
1902 | 1887 | ||
1903 | /* This platform_get_resource() call will not return NULL, because | 1888 | /* This platform_get_resource() call will not return NULL, because |
1904 | * the same call in cs89x0_platform_probe() has returned a non NULL | 1889 | * the same call in cs89x0_platform_probe() has returned a non NULL |
1905 | * value. | 1890 | * value. |
1906 | */ | 1891 | */ |
1907 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1908 | unregister_netdev(dev); | 1892 | unregister_netdev(dev); |
1909 | iounmap(lp->virt_addr); | ||
1910 | release_mem_region(mem_res->start, lp->size); | ||
1911 | free_netdev(dev); | 1893 | free_netdev(dev); |
1912 | return 0; | 1894 | return 0; |
1913 | } | 1895 | } |