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>
This commit is contained in:
Vladimir Oltean 2022-11-21 15:55:42 +02:00 committed by Jakub Kicinski
parent 5cf2c75b5b
commit d95fa75061
1 changed files with 5 additions and 7 deletions

View File

@ -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;
}