Skip to content

Commit fb73d62

Browse files
committed
Merge branch 'dsa-lantiq_gswip-probe-fixes-and-remove-cleanup'
Johan Hovold says: ==================== net: dsa: lantiq_gswip: probe fixes and remove cleanup This series fix a few issues found through inspection when fixing up new bad uses of of_find_compatible_node() that have crept in since 4.19. Note that these have only been compile tested. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 5fb1bee + 8bb18f6 commit fb73d62

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

drivers/net/dsa/lantiq_gswip.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,24 +1069,23 @@ static int gswip_probe(struct platform_device *pdev)
10691069
version = gswip_switch_r(priv, GSWIP_VERSION);
10701070

10711071
/* bring up the mdio bus */
1072-
gphy_fw_np = of_find_compatible_node(pdev->dev.of_node, NULL,
1073-
"lantiq,gphy-fw");
1072+
gphy_fw_np = of_get_compatible_child(dev->of_node, "lantiq,gphy-fw");
10741073
if (gphy_fw_np) {
10751074
err = gswip_gphy_fw_list(priv, gphy_fw_np, version);
1075+
of_node_put(gphy_fw_np);
10761076
if (err) {
10771077
dev_err(dev, "gphy fw probe failed\n");
10781078
return err;
10791079
}
10801080
}
10811081

10821082
/* bring up the mdio bus */
1083-
mdio_np = of_find_compatible_node(pdev->dev.of_node, NULL,
1084-
"lantiq,xrx200-mdio");
1083+
mdio_np = of_get_compatible_child(dev->of_node, "lantiq,xrx200-mdio");
10851084
if (mdio_np) {
10861085
err = gswip_mdio(priv, mdio_np);
10871086
if (err) {
10881087
dev_err(dev, "mdio probe failed\n");
1089-
goto gphy_fw;
1088+
goto put_mdio_node;
10901089
}
10911090
}
10921091

@@ -1099,7 +1098,7 @@ static int gswip_probe(struct platform_device *pdev)
10991098
dev_err(dev, "wrong CPU port defined, HW only supports port: %i",
11001099
priv->hw_info->cpu_port);
11011100
err = -EINVAL;
1102-
goto mdio_bus;
1101+
goto disable_switch;
11031102
}
11041103

11051104
platform_set_drvdata(pdev, priv);
@@ -1109,10 +1108,14 @@ static int gswip_probe(struct platform_device *pdev)
11091108
(version & GSWIP_VERSION_MOD_MASK) >> GSWIP_VERSION_MOD_SHIFT);
11101109
return 0;
11111110

1111+
disable_switch:
1112+
gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB);
1113+
dsa_unregister_switch(priv->ds);
11121114
mdio_bus:
11131115
if (mdio_np)
11141116
mdiobus_unregister(priv->ds->slave_mii_bus);
1115-
gphy_fw:
1117+
put_mdio_node:
1118+
of_node_put(mdio_np);
11161119
for (i = 0; i < priv->num_gphy_fw; i++)
11171120
gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);
11181121
return err;
@@ -1123,16 +1126,15 @@ static int gswip_remove(struct platform_device *pdev)
11231126
struct gswip_priv *priv = platform_get_drvdata(pdev);
11241127
int i;
11251128

1126-
if (!priv)
1127-
return 0;
1128-
11291129
/* disable the switch */
11301130
gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB);
11311131

11321132
dsa_unregister_switch(priv->ds);
11331133

1134-
if (priv->ds->slave_mii_bus)
1134+
if (priv->ds->slave_mii_bus) {
11351135
mdiobus_unregister(priv->ds->slave_mii_bus);
1136+
of_node_put(priv->ds->slave_mii_bus->dev.of_node);
1137+
}
11361138

11371139
for (i = 0; i < priv->num_gphy_fw; i++)
11381140
gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);

0 commit comments

Comments
 (0)