ethoc: use devres resource management
The point of using the devres resource management routines is that they simplify the driver by taking care of releasing resources on failure and release. A recent commit added a bunch of error handling that is unnecessary in this context. This patch removes this redundant error handling, as well as using dmam_alloc_coherent in place of dma_alloc_coherent in order to use this framework consistenly throughout the driver. Signed-off-by: Jonas Bonn <jonas@southpole.se> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
b46773db64
commit
a71fba9729
@@ -964,7 +964,7 @@ static int ethoc_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Allocate buffer memory */
|
/* Allocate buffer memory */
|
||||||
priv->membase = dma_alloc_coherent(NULL,
|
priv->membase = dmam_alloc_coherent(&pdev->dev,
|
||||||
buffer_size, (void *)&netdev->mem_start,
|
buffer_size, (void *)&netdev->mem_start,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!priv->membase) {
|
if (!priv->membase) {
|
||||||
@@ -1074,21 +1074,6 @@ free_mdio:
|
|||||||
kfree(priv->mdio->irq);
|
kfree(priv->mdio->irq);
|
||||||
mdiobus_free(priv->mdio);
|
mdiobus_free(priv->mdio);
|
||||||
free:
|
free:
|
||||||
if (priv) {
|
|
||||||
if (priv->dma_alloc)
|
|
||||||
dma_free_coherent(NULL, priv->dma_alloc, priv->membase,
|
|
||||||
netdev->mem_start);
|
|
||||||
else if (priv->membase)
|
|
||||||
devm_iounmap(&pdev->dev, priv->membase);
|
|
||||||
if (priv->iobase)
|
|
||||||
devm_iounmap(&pdev->dev, priv->iobase);
|
|
||||||
}
|
|
||||||
if (mem)
|
|
||||||
devm_release_mem_region(&pdev->dev, mem->start,
|
|
||||||
mem->end - mem->start + 1);
|
|
||||||
if (mmio)
|
|
||||||
devm_release_mem_region(&pdev->dev, mmio->start,
|
|
||||||
mmio->end - mmio->start + 1);
|
|
||||||
free_netdev(netdev);
|
free_netdev(netdev);
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1115,17 +1100,6 @@ static int ethoc_remove(struct platform_device *pdev)
|
|||||||
kfree(priv->mdio->irq);
|
kfree(priv->mdio->irq);
|
||||||
mdiobus_free(priv->mdio);
|
mdiobus_free(priv->mdio);
|
||||||
}
|
}
|
||||||
if (priv->dma_alloc)
|
|
||||||
dma_free_coherent(NULL, priv->dma_alloc, priv->membase,
|
|
||||||
netdev->mem_start);
|
|
||||||
else {
|
|
||||||
devm_iounmap(&pdev->dev, priv->membase);
|
|
||||||
devm_release_mem_region(&pdev->dev, netdev->mem_start,
|
|
||||||
netdev->mem_end - netdev->mem_start + 1);
|
|
||||||
}
|
|
||||||
devm_iounmap(&pdev->dev, priv->iobase);
|
|
||||||
devm_release_mem_region(&pdev->dev, netdev->base_addr,
|
|
||||||
priv->io_region_size);
|
|
||||||
unregister_netdev(netdev);
|
unregister_netdev(netdev);
|
||||||
free_netdev(netdev);
|
free_netdev(netdev);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user