net: dsa: Move devlink registration to be last devlink command
This change prevents from users to access device before devlink is fully configured. Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6f0b1edd9f
commit
bd936bd53b
@ -848,7 +848,6 @@ static int dsa_switch_setup(struct dsa_switch *ds)
|
|||||||
dl_priv = devlink_priv(ds->devlink);
|
dl_priv = devlink_priv(ds->devlink);
|
||||||
dl_priv->ds = ds;
|
dl_priv->ds = ds;
|
||||||
|
|
||||||
devlink_register(ds->devlink);
|
|
||||||
/* Setup devlink port instances now, so that the switch
|
/* Setup devlink port instances now, so that the switch
|
||||||
* setup() can register regions etc, against the ports
|
* setup() can register regions etc, against the ports
|
||||||
*/
|
*/
|
||||||
@ -874,8 +873,6 @@ static int dsa_switch_setup(struct dsa_switch *ds)
|
|||||||
if (err)
|
if (err)
|
||||||
goto teardown;
|
goto teardown;
|
||||||
|
|
||||||
devlink_params_publish(ds->devlink);
|
|
||||||
|
|
||||||
if (!ds->slave_mii_bus && ds->ops->phy_read) {
|
if (!ds->slave_mii_bus && ds->ops->phy_read) {
|
||||||
ds->slave_mii_bus = mdiobus_alloc();
|
ds->slave_mii_bus = mdiobus_alloc();
|
||||||
if (!ds->slave_mii_bus) {
|
if (!ds->slave_mii_bus) {
|
||||||
@ -891,7 +888,7 @@ static int dsa_switch_setup(struct dsa_switch *ds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ds->setup = true;
|
ds->setup = true;
|
||||||
|
devlink_register(ds->devlink);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
free_slave_mii_bus:
|
free_slave_mii_bus:
|
||||||
@ -906,7 +903,6 @@ unregister_devlink_ports:
|
|||||||
list_for_each_entry(dp, &ds->dst->ports, list)
|
list_for_each_entry(dp, &ds->dst->ports, list)
|
||||||
if (dp->ds == ds)
|
if (dp->ds == ds)
|
||||||
dsa_port_devlink_teardown(dp);
|
dsa_port_devlink_teardown(dp);
|
||||||
devlink_unregister(ds->devlink);
|
|
||||||
devlink_free(ds->devlink);
|
devlink_free(ds->devlink);
|
||||||
ds->devlink = NULL;
|
ds->devlink = NULL;
|
||||||
return err;
|
return err;
|
||||||
@ -919,6 +915,9 @@ static void dsa_switch_teardown(struct dsa_switch *ds)
|
|||||||
if (!ds->setup)
|
if (!ds->setup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ds->devlink)
|
||||||
|
devlink_unregister(ds->devlink);
|
||||||
|
|
||||||
if (ds->slave_mii_bus && ds->ops->phy_read) {
|
if (ds->slave_mii_bus && ds->ops->phy_read) {
|
||||||
mdiobus_unregister(ds->slave_mii_bus);
|
mdiobus_unregister(ds->slave_mii_bus);
|
||||||
mdiobus_free(ds->slave_mii_bus);
|
mdiobus_free(ds->slave_mii_bus);
|
||||||
@ -934,7 +933,6 @@ static void dsa_switch_teardown(struct dsa_switch *ds)
|
|||||||
list_for_each_entry(dp, &ds->dst->ports, list)
|
list_for_each_entry(dp, &ds->dst->ports, list)
|
||||||
if (dp->ds == ds)
|
if (dp->ds == ds)
|
||||||
dsa_port_devlink_teardown(dp);
|
dsa_port_devlink_teardown(dp);
|
||||||
devlink_unregister(ds->devlink);
|
|
||||||
devlink_free(ds->devlink);
|
devlink_free(ds->devlink);
|
||||||
ds->devlink = NULL;
|
ds->devlink = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user