Commit 626a5aaa authored by Colin Foster's avatar Colin Foster Committed by Jakub Kicinski

net: mdio: mscc-miim: add local dev variable to cleanup probe function

Create a local device *dev in order to not dereference the platform_device
several times throughout the probe function.
Signed-off-by: default avatarColin Foster <colin.foster@in-advantage.com>
Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 34ba23b4
...@@ -272,6 +272,7 @@ static int mscc_miim_probe(struct platform_device *pdev) ...@@ -272,6 +272,7 @@ static int mscc_miim_probe(struct platform_device *pdev)
{ {
struct regmap *mii_regmap, *phy_regmap = NULL; struct regmap *mii_regmap, *phy_regmap = NULL;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
void __iomem *regs, *phy_regs; void __iomem *regs, *phy_regs;
struct mscc_miim_dev *miim; struct mscc_miim_dev *miim;
struct resource *res; struct resource *res;
...@@ -280,57 +281,55 @@ static int mscc_miim_probe(struct platform_device *pdev) ...@@ -280,57 +281,55 @@ static int mscc_miim_probe(struct platform_device *pdev)
regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(regs)) { if (IS_ERR(regs)) {
dev_err(&pdev->dev, "Unable to map MIIM registers\n"); dev_err(dev, "Unable to map MIIM registers\n");
return PTR_ERR(regs); return PTR_ERR(regs);
} }
mii_regmap = devm_regmap_init_mmio(&pdev->dev, regs, mii_regmap = devm_regmap_init_mmio(dev, regs, &mscc_miim_regmap_config);
&mscc_miim_regmap_config);
if (IS_ERR(mii_regmap)) { if (IS_ERR(mii_regmap)) {
dev_err(&pdev->dev, "Unable to create MIIM regmap\n"); dev_err(dev, "Unable to create MIIM regmap\n");
return PTR_ERR(mii_regmap); return PTR_ERR(mii_regmap);
} }
/* This resource is optional */ /* This resource is optional */
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res) { if (res) {
phy_regs = devm_ioremap_resource(&pdev->dev, res); phy_regs = devm_ioremap_resource(dev, res);
if (IS_ERR(phy_regs)) { if (IS_ERR(phy_regs)) {
dev_err(&pdev->dev, "Unable to map internal phy registers\n"); dev_err(dev, "Unable to map internal phy registers\n");
return PTR_ERR(phy_regs); return PTR_ERR(phy_regs);
} }
phy_regmap = devm_regmap_init_mmio(&pdev->dev, phy_regs, phy_regmap = devm_regmap_init_mmio(dev, phy_regs,
&mscc_miim_phy_regmap_config); &mscc_miim_phy_regmap_config);
if (IS_ERR(phy_regmap)) { if (IS_ERR(phy_regmap)) {
dev_err(&pdev->dev, "Unable to create phy register regmap\n"); dev_err(dev, "Unable to create phy register regmap\n");
return PTR_ERR(phy_regmap); return PTR_ERR(phy_regmap);
} }
} }
ret = mscc_miim_setup(&pdev->dev, &bus, "mscc_miim", mii_regmap, 0); ret = mscc_miim_setup(dev, &bus, "mscc_miim", mii_regmap, 0);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Unable to setup the MDIO bus\n"); dev_err(dev, "Unable to setup the MDIO bus\n");
return ret; return ret;
} }
miim = bus->priv; miim = bus->priv;
miim->phy_regs = phy_regmap; miim->phy_regs = phy_regmap;
miim->info = device_get_match_data(&pdev->dev); miim->info = device_get_match_data(dev);
if (!miim->info) if (!miim->info)
return -EINVAL; return -EINVAL;
miim->clk = devm_clk_get_optional(&pdev->dev, NULL); miim->clk = devm_clk_get_optional(dev, NULL);
if (IS_ERR(miim->clk)) if (IS_ERR(miim->clk))
return PTR_ERR(miim->clk); return PTR_ERR(miim->clk);
of_property_read_u32(np, "clock-frequency", &miim->bus_freq); of_property_read_u32(np, "clock-frequency", &miim->bus_freq);
if (miim->bus_freq && !miim->clk) { if (miim->bus_freq && !miim->clk) {
dev_err(&pdev->dev, dev_err(dev, "cannot use clock-frequency without a clock\n");
"cannot use clock-frequency without a clock\n");
return -EINVAL; return -EINVAL;
} }
...@@ -344,7 +343,7 @@ static int mscc_miim_probe(struct platform_device *pdev) ...@@ -344,7 +343,7 @@ static int mscc_miim_probe(struct platform_device *pdev)
ret = of_mdiobus_register(bus, np); ret = of_mdiobus_register(bus, np);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret); dev_err(dev, "Cannot register MDIO bus (%d)\n", ret);
goto out_disable_clk; goto out_disable_clk;
} }
......
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