Commit 1d14eb15 authored by Tobias Waldekranz's avatar Tobias Waldekranz Committed by David S. Miller

net/fsl: xgmac_mdio: Use managed device resources

All of the resources used by this driver has managed interfaces, so
use them. Heed the warning in the comment before platform_get_resource
and use a bare devm_ioremap to allow for non-exclusive access to the
IO memory.
Signed-off-by: default avatarTobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15ca0518
...@@ -273,7 +273,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev) ...@@ -273,7 +273,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
bus = mdiobus_alloc_size(sizeof(struct mdio_fsl_priv)); bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(struct mdio_fsl_priv));
if (!bus) if (!bus)
return -ENOMEM; return -ENOMEM;
...@@ -284,13 +284,11 @@ static int xgmac_mdio_probe(struct platform_device *pdev) ...@@ -284,13 +284,11 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
bus->probe_capabilities = MDIOBUS_C22_C45; bus->probe_capabilities = MDIOBUS_C22_C45;
snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start); snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start);
/* Set the PHY base address */
priv = bus->priv; priv = bus->priv;
priv->mdio_base = ioremap(res->start, resource_size(res)); priv->mdio_base = devm_ioremap(&pdev->dev, res->start,
if (!priv->mdio_base) { resource_size(res));
ret = -ENOMEM; if (IS_ERR(priv->mdio_base))
goto err_ioremap; return PTR_ERR(priv->mdio_base);
}
/* For both ACPI and DT cases, endianness of MDIO controller /* For both ACPI and DT cases, endianness of MDIO controller
* needs to be specified using "little-endian" property. * needs to be specified using "little-endian" property.
...@@ -312,31 +310,11 @@ static int xgmac_mdio_probe(struct platform_device *pdev) ...@@ -312,31 +310,11 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
ret = -EINVAL; ret = -EINVAL;
if (ret) { if (ret) {
dev_err(&pdev->dev, "cannot register MDIO bus\n"); dev_err(&pdev->dev, "cannot register MDIO bus\n");
goto err_registration; return ret;
} }
platform_set_drvdata(pdev, bus); platform_set_drvdata(pdev, bus);
return 0;
err_registration:
iounmap(priv->mdio_base);
err_ioremap:
mdiobus_free(bus);
return ret;
}
static int xgmac_mdio_remove(struct platform_device *pdev)
{
struct mii_bus *bus = platform_get_drvdata(pdev);
struct mdio_fsl_priv *priv = bus->priv;
mdiobus_unregister(bus);
iounmap(priv->mdio_base);
mdiobus_free(bus);
return 0; return 0;
} }
...@@ -364,7 +342,6 @@ static struct platform_driver xgmac_mdio_driver = { ...@@ -364,7 +342,6 @@ static struct platform_driver xgmac_mdio_driver = {
.acpi_match_table = xgmac_acpi_match, .acpi_match_table = xgmac_acpi_match,
}, },
.probe = xgmac_mdio_probe, .probe = xgmac_mdio_probe,
.remove = xgmac_mdio_remove,
}; };
module_platform_driver(xgmac_mdio_driver); module_platform_driver(xgmac_mdio_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment