Skip to content

Commit c448c89

Browse files
HoratiuVulturdavem330
authored andcommitted
net: mdio: mscc-miim: Set back the optional resource.
In the blamed commit, the second memory resource was not considered anymore as optional. On some platforms like sparx5 the second resource is optional. So add it back as optional and restore the comment that says so. Fixes: a27a762 ("net: mdio: mscc-miim: convert to a regmap implementation") Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 94dd016 commit c448c89

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

drivers/net/mdio/mdio-mscc-miim.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,10 @@ EXPORT_SYMBOL(mscc_miim_setup);
219219

220220
static int mscc_miim_probe(struct platform_device *pdev)
221221
{
222-
struct regmap *mii_regmap, *phy_regmap;
222+
struct regmap *mii_regmap, *phy_regmap = NULL;
223223
void __iomem *regs, *phy_regs;
224224
struct mscc_miim_dev *miim;
225+
struct resource *res;
225226
struct mii_bus *bus;
226227
int ret;
227228

@@ -239,17 +240,21 @@ static int mscc_miim_probe(struct platform_device *pdev)
239240
return PTR_ERR(mii_regmap);
240241
}
241242

242-
phy_regs = devm_platform_ioremap_resource(pdev, 1);
243-
if (IS_ERR(phy_regs)) {
244-
dev_err(&pdev->dev, "Unable to map internal phy registers\n");
245-
return PTR_ERR(phy_regs);
246-
}
243+
/* This resource is optional */
244+
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
245+
if (res) {
246+
phy_regs = devm_ioremap_resource(&pdev->dev, res);
247+
if (IS_ERR(phy_regs)) {
248+
dev_err(&pdev->dev, "Unable to map internal phy registers\n");
249+
return PTR_ERR(phy_regs);
250+
}
247251

248-
phy_regmap = devm_regmap_init_mmio(&pdev->dev, phy_regs,
249-
&mscc_miim_regmap_config);
250-
if (IS_ERR(phy_regmap)) {
251-
dev_err(&pdev->dev, "Unable to create phy register regmap\n");
252-
return PTR_ERR(phy_regmap);
252+
phy_regmap = devm_regmap_init_mmio(&pdev->dev, phy_regs,
253+
&mscc_miim_regmap_config);
254+
if (IS_ERR(phy_regmap)) {
255+
dev_err(&pdev->dev, "Unable to create phy register regmap\n");
256+
return PTR_ERR(phy_regmap);
257+
}
253258
}
254259

255260
ret = mscc_miim_setup(&pdev->dev, &bus, "mscc_miim", mii_regmap, 0);

0 commit comments

Comments
 (0)