summaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2022-11-21 14:55:42 +0100
committerJakub Kicinski <kuba@kernel.org>2022-11-23 05:41:47 +0100
commitd95fa75061fbd09a7ae78a76bc8902a84b8538a5 (patch)
tree510c07d1482deffcf85ee3bba843daf54414c5fc /net/dsa
parentnet: dsa: move bulk of devlink code to devlink.{c,h} (diff)
downloadlinux-d95fa75061fbd09a7ae78a76bc8902a84b8538a5.tar.xz
linux-d95fa75061fbd09a7ae78a76bc8902a84b8538a5.zip
net: dsa: if ds->setup is true, ds->devlink is always non-NULL
Simplify dsa_switch_teardown() to remove the NULL checking for ds->devlink. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa2.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 05e682c25590..f890dfcbf412 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -682,8 +682,9 @@ static int dsa_switch_setup(struct dsa_switch *ds)
goto free_slave_mii_bus;
}
- ds->setup = true;
devlink_register(ds->devlink);
+
+ ds->setup = true;
return 0;
free_slave_mii_bus:
@@ -705,8 +706,7 @@ static void dsa_switch_teardown(struct dsa_switch *ds)
if (!ds->setup)
return;
- if (ds->devlink)
- devlink_unregister(ds->devlink);
+ devlink_unregister(ds->devlink);
if (ds->slave_mii_bus && ds->ops->phy_read) {
mdiobus_unregister(ds->slave_mii_bus);
@@ -721,10 +721,8 @@ static void dsa_switch_teardown(struct dsa_switch *ds)
dsa_switch_unregister_notifier(ds);
- if (ds->devlink) {
- devlink_free(ds->devlink);
- ds->devlink = NULL;
- }
+ devlink_free(ds->devlink);
+ ds->devlink = NULL;
ds->setup = false;
}