Commit 35d2aeac authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

phy: mdio-octeon: Use devm_mdiobus_alloc_size()

Rather than use devm_kzalloc(), use the mdio helper function.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2220943a
...@@ -268,12 +268,13 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id, ...@@ -268,12 +268,13 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
static int octeon_mdiobus_probe(struct platform_device *pdev) static int octeon_mdiobus_probe(struct platform_device *pdev)
{ {
struct octeon_mdiobus *bus; struct octeon_mdiobus *bus;
struct mii_bus *mii_bus;
struct resource *res_mem; struct resource *res_mem;
union cvmx_smix_en smi_en; union cvmx_smix_en smi_en;
int err = -ENOENT; int err = -ENOENT;
bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); mii_bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*bus));
if (!bus) if (!mii_bus)
return -ENOMEM; return -ENOMEM;
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -282,6 +283,8 @@ static int octeon_mdiobus_probe(struct platform_device *pdev) ...@@ -282,6 +283,8 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
return -ENXIO; return -ENXIO;
} }
bus = mii_bus->priv;
bus->mii_bus = mii_bus;
bus->mdio_phys = res_mem->start; bus->mdio_phys = res_mem->start;
bus->regsize = resource_size(res_mem); bus->regsize = resource_size(res_mem);
...@@ -298,10 +301,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev) ...@@ -298,10 +301,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
bus->mii_bus = mdiobus_alloc();
if (!bus->mii_bus)
goto fail;
smi_en.u64 = 0; smi_en.u64 = 0;
smi_en.s.en = 1; smi_en.s.en = 1;
oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
...@@ -326,7 +325,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev) ...@@ -326,7 +325,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
return 0; return 0;
fail_register: fail_register:
mdiobus_free(bus->mii_bus); mdiobus_free(bus->mii_bus);
fail:
smi_en.u64 = 0; smi_en.u64 = 0;
oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
return err; return err;
......
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