- useless initialization (korina_ope / korina_restart)
- use a single variable for the status code in korina_probe
and propagate the error status code from below
- useless checks in korina_remove : the variables are
necessarily set when korina_probe succeeds
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
static int korina_restart(struct net_device *dev)
{
struct korina_private *lp = netdev_priv(dev);
static int korina_restart(struct net_device *dev)
{
struct korina_private *lp = netdev_priv(dev);
static int korina_open(struct net_device *dev)
{
struct korina_private *lp = netdev_priv(dev);
static int korina_open(struct net_device *dev)
{
struct korina_private *lp = netdev_priv(dev);
/* Initialize */
ret = korina_init(dev);
/* Initialize */
ret = korina_init(dev);
struct korina_private *lp;
struct net_device *dev;
struct resource *r;
struct korina_private *lp;
struct net_device *dev;
struct resource *r;
dev = alloc_etherdev(sizeof(struct korina_private));
if (!dev) {
dev = alloc_etherdev(sizeof(struct korina_private));
if (!dev) {
lp->eth_regs = ioremap_nocache(r->start, r->end - r->start);
if (!lp->eth_regs) {
printk(KERN_ERR DRV_NAME "cannot remap registers\n");
lp->eth_regs = ioremap_nocache(r->start, r->end - r->start);
if (!lp->eth_regs) {
printk(KERN_ERR DRV_NAME "cannot remap registers\n");
lp->rx_dma_regs = ioremap_nocache(r->start, r->end - r->start);
if (!lp->rx_dma_regs) {
printk(KERN_ERR DRV_NAME "cannot remap Rx DMA registers\n");
lp->rx_dma_regs = ioremap_nocache(r->start, r->end - r->start);
if (!lp->rx_dma_regs) {
printk(KERN_ERR DRV_NAME "cannot remap Rx DMA registers\n");
lp->tx_dma_regs = ioremap_nocache(r->start, r->end - r->start);
if (!lp->tx_dma_regs) {
printk(KERN_ERR DRV_NAME "cannot remap Tx DMA registers\n");
lp->tx_dma_regs = ioremap_nocache(r->start, r->end - r->start);
if (!lp->tx_dma_regs) {
printk(KERN_ERR DRV_NAME "cannot remap Tx DMA registers\n");
goto probe_err_dma_tx;
}
lp->td_ring = kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL);
if (!lp->td_ring) {
printk(KERN_ERR DRV_NAME "cannot allocate descriptors\n");
goto probe_err_dma_tx;
}
lp->td_ring = kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL);
if (!lp->td_ring) {
printk(KERN_ERR DRV_NAME "cannot allocate descriptors\n");
goto probe_err_td_ring;
}
goto probe_err_td_ring;
}
lp->mii_if.phy_id_mask = 0x1f;
lp->mii_if.reg_num_mask = 0x1f;
lp->mii_if.phy_id_mask = 0x1f;
lp->mii_if.reg_num_mask = 0x1f;
- err = register_netdev(dev);
- if (err) {
+ rc = register_netdev(dev);
+ if (rc < 0) {
- ": cannot register net device %d\n", err);
- retval = -EINVAL;
+ ": cannot register net device %d\n", rc);
goto probe_err_register;
}
goto probe_err_register;
}
probe_err_register:
kfree(lp->td_ring);
probe_err_register:
kfree(lp->td_ring);
iounmap(lp->eth_regs);
probe_err_out:
free_netdev(dev);
iounmap(lp->eth_regs);
probe_err_out:
free_netdev(dev);
}
static int korina_remove(struct platform_device *pdev)
}
static int korina_remove(struct platform_device *pdev)
struct korina_device *bif = platform_get_drvdata(pdev);
struct korina_private *lp = netdev_priv(bif->dev);
struct korina_device *bif = platform_get_drvdata(pdev);
struct korina_private *lp = netdev_priv(bif->dev);
- if (lp->eth_regs)
- iounmap(lp->eth_regs);
- if (lp->rx_dma_regs)
- iounmap(lp->rx_dma_regs);
- if (lp->tx_dma_regs)
- iounmap(lp->tx_dma_regs);
+ iounmap(lp->eth_regs);
+ iounmap(lp->rx_dma_regs);
+ iounmap(lp->tx_dma_regs);
platform_set_drvdata(pdev, NULL);
unregister_netdev(bif->dev);
platform_set_drvdata(pdev, NULL);
unregister_netdev(bif->dev);