Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 327734
b: refs/heads/master
c: dd3b8a3
h: refs/heads/master
v: v3
  • Loading branch information
Timur Tabi authored and David S. Miller committed Aug 30, 2012
1 parent 058cbc2 commit fd53167
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: afae5ad78b342f401c28b0bb1adb3cd494cb125a
refs/heads/master: dd3b8a32e66cc3274a27338335337a5b65611ea5
42 changes: 14 additions & 28 deletions trunk/drivers/net/ethernet/freescale/fsl_pq_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct fsl_pq_mdio {
struct fsl_pq_mdio_priv {
void __iomem *map;
struct fsl_pq_mii __iomem *regs;
int irqs[PHY_MAX_ADDR];
};

/*
Expand Down Expand Up @@ -359,26 +360,21 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)

dev_dbg(&pdev->dev, "found %s compatible node\n", id->compatible);

priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
new_bus = mdiobus_alloc_size(sizeof(*priv));
if (!new_bus)
return -ENOMEM;

new_bus = mdiobus_alloc();
if (!new_bus) {
err = -ENOMEM;
goto err_free_priv;
}

priv = new_bus->priv;
new_bus->name = "Freescale PowerQUICC MII Bus",
new_bus->read = &fsl_pq_mdio_read;
new_bus->write = &fsl_pq_mdio_write;
new_bus->reset = &fsl_pq_mdio_reset;
new_bus->priv = priv;
new_bus->irq = priv->irqs;

err = of_address_to_resource(np, 0, &res);
if (err < 0) {
dev_err(&pdev->dev, "could not obtain address information\n");
goto err_free_bus;
goto error;
}

snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s@%llx", np->name,
Expand All @@ -387,7 +383,7 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
priv->map = of_iomap(np, 0);
if (!priv->map) {
err = -ENOMEM;
goto err_free_bus;
goto error;
}

/*
Expand All @@ -399,16 +395,10 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
if (data->mii_offset > resource_size(&res)) {
dev_err(&pdev->dev, "invalid register map\n");
err = -EINVAL;
goto err_unmap_regs;
goto error;
}
priv->regs = priv->map + data->mii_offset;

new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
if (NULL == new_bus->irq) {
err = -ENOMEM;
goto err_unmap_regs;
}

new_bus->parent = &pdev->dev;
dev_set_drvdata(&pdev->dev, new_bus);

Expand Down Expand Up @@ -446,19 +436,17 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
if (err) {
dev_err(&pdev->dev, "cannot register %s as MDIO bus\n",
new_bus->name);
goto err_free_irqs;
goto error;
}

return 0;

err_free_irqs:
kfree(new_bus->irq);
err_unmap_regs:
iounmap(priv->map);
err_free_bus:
error:
if (priv->map)
iounmap(priv->map);

kfree(new_bus);
err_free_priv:
kfree(priv);

return err;
}

Expand All @@ -474,9 +462,7 @@ static int fsl_pq_mdio_remove(struct platform_device *pdev)
dev_set_drvdata(device, NULL);

iounmap(priv->map);
bus->priv = NULL;
mdiobus_free(bus);
kfree(priv);

return 0;
}
Expand Down

0 comments on commit fd53167

Please sign in to comment.