Skip to content

Commit 377d66f

Browse files
dangowrtPaolo Abeni
authored andcommitted
net: dsa: lantiq_gswip: fix order in .remove operation
Russell King pointed out that disabling the switch by clearing GSWIP_MDIO_GLOB_ENABLE before calling dsa_unregister_switch() is problematic, as it violates a Golden Rule of driver development to always first unpublish userspace interfaces and then disable the hardware. Fix this, and also simplify the probe() function, by introducing a dsa_switch_ops teardown() operation which takes care of clearing the GSWIP_MDIO_GLOB_ENABLE bit. Fixes: 14fceff ("net: dsa: Add Lantiq / Intel DSA driver for vrx200") Suggested-by: "Russell King (Oracle)" <linux@armlinux.org.uk> Signed-off-by: Daniel Golle <daniel@makrotopia.org> Link: https://patch.msgid.link/4ebd72a29edc1e4059b9666a26a0bb5d906a829a.1765241054.git.daniel@makrotopia.org Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 7b07be1 commit 377d66f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

drivers/net/dsa/lantiq/lantiq_gswip.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,6 @@ static void gswip_remove(struct platform_device *pdev)
444444
if (!priv)
445445
return;
446446

447-
/* disable the switch */
448-
gswip_disable_switch(priv);
449-
450447
dsa_unregister_switch(priv->ds);
451448

452449
for (i = 0; i < priv->num_gphy_fw; i++)

drivers/net/dsa/lantiq/lantiq_gswip_common.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,13 @@ static int gswip_setup(struct dsa_switch *ds)
752752
return 0;
753753
}
754754

755+
static void gswip_teardown(struct dsa_switch *ds)
756+
{
757+
struct gswip_priv *priv = ds->priv;
758+
759+
regmap_clear_bits(priv->mdio, GSWIP_MDIO_GLOB, GSWIP_MDIO_GLOB_ENABLE);
760+
}
761+
755762
static enum dsa_tag_protocol gswip_get_tag_protocol(struct dsa_switch *ds,
756763
int port,
757764
enum dsa_tag_protocol mp)
@@ -1629,6 +1636,7 @@ static const struct phylink_mac_ops gswip_phylink_mac_ops = {
16291636
static const struct dsa_switch_ops gswip_switch_ops = {
16301637
.get_tag_protocol = gswip_get_tag_protocol,
16311638
.setup = gswip_setup,
1639+
.teardown = gswip_teardown,
16321640
.port_setup = gswip_port_setup,
16331641
.port_enable = gswip_port_enable,
16341642
.port_disable = gswip_port_disable,
@@ -1718,15 +1726,14 @@ int gswip_probe_common(struct gswip_priv *priv, u32 version)
17181726

17191727
err = gswip_validate_cpu_port(priv->ds);
17201728
if (err)
1721-
goto disable_switch;
1729+
goto unregister_switch;
17221730

17231731
dev_info(priv->dev, "probed GSWIP version %lx mod %lx\n",
17241732
GSWIP_VERSION_REV(version), GSWIP_VERSION_MOD(version));
17251733

17261734
return 0;
17271735

1728-
disable_switch:
1729-
gswip_disable_switch(priv);
1736+
unregister_switch:
17301737
dsa_unregister_switch(priv->ds);
17311738

17321739
return err;

0 commit comments

Comments
 (0)