Skip to content

Commit

Permalink
phy: mdio-octeon: Use devm_mdiobus_alloc_size()
Browse files Browse the repository at this point in the history
Rather than use devm_kzalloc(), use the mdio helper function.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
lunn authored and davem330 committed Jan 7, 2016
1 parent 2220943 commit 35d2aea
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/net/phy/mdio-octeon.c
Expand Up @@ -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)
{
struct octeon_mdiobus *bus;
struct mii_bus *mii_bus;
struct resource *res_mem;
union cvmx_smix_en smi_en;
int err = -ENOENT;

bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL);
if (!bus)
mii_bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*bus));
if (!mii_bus)
return -ENOMEM;

res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Expand All @@ -282,6 +283,8 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
return -ENXIO;
}

bus = mii_bus->priv;
bus->mii_bus = mii_bus;
bus->mdio_phys = res_mem->start;
bus->regsize = resource_size(res_mem);

Expand All @@ -298,10 +301,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
return -ENOMEM;
}

bus->mii_bus = mdiobus_alloc();
if (!bus->mii_bus)
goto fail;

smi_en.u64 = 0;
smi_en.s.en = 1;
oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
Expand All @@ -326,7 +325,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
return 0;
fail_register:
mdiobus_free(bus->mii_bus);
fail:
smi_en.u64 = 0;
oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
return err;
Expand Down

0 comments on commit 35d2aea

Please sign in to comment.