Skip to content

Commit

Permalink
net: dsa: mv88e6xxx: move call to mv88e6xxx_mdios_register()
Browse files Browse the repository at this point in the history
Call the rather expensive mv88e6xxx_mdios_register() at the beginning of
mv88e6xxx_setup(). This avoids the double call via mv88e6xxx_probe()
during boot.

For symmetry, call mv88e6xxx_mdios_unregister() at the end of
mv88e6xxx_teardown().

Link: https://lore.kernel.org/lkml/449bde236c08d5ab5e54abd73b645d8b29955894.camel@gmail.com/
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Klaus Kudielka <klaus.kudielka@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Tested-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Klaus Kudielka authored and Jakub Kicinski committed Mar 18, 2023
1 parent f1bee74 commit 2cb0658
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions drivers/net/dsa/mv88e6xxx/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -3848,9 +3848,9 @@ static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
}
}

static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
struct device_node *np)
static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip)
{
struct device_node *np = chip->dev->of_node;
struct device_node *child;
int err;

Expand Down Expand Up @@ -3885,9 +3885,12 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,

static void mv88e6xxx_teardown(struct dsa_switch *ds)
{
struct mv88e6xxx_chip *chip = ds->priv;

mv88e6xxx_teardown_devlink_params(ds);
dsa_devlink_resources_unregister(ds);
mv88e6xxx_teardown_devlink_regions_global(ds);
mv88e6xxx_mdios_unregister(chip);
}

static int mv88e6xxx_setup(struct dsa_switch *ds)
Expand All @@ -3897,6 +3900,10 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
int err;
int i;

err = mv88e6xxx_mdios_register(chip);
if (err)
return err;

chip->ds = ds;
ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);

Expand Down Expand Up @@ -4023,7 +4030,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
mv88e6xxx_reg_unlock(chip);

if (err)
return err;
goto out_mdios;

/* Have to be called without holding the register lock, since
* they take the devlink lock, and we later take the locks in
Expand All @@ -4032,7 +4039,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
*/
err = mv88e6xxx_setup_devlink_resources(ds);
if (err)
return err;
goto out_mdios;

err = mv88e6xxx_setup_devlink_params(ds);
if (err)
Expand All @@ -4048,6 +4055,8 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
mv88e6xxx_teardown_devlink_params(ds);
out_resources:
dsa_devlink_resources_unregister(ds);
out_mdios:
mv88e6xxx_mdios_unregister(chip);

return err;
}
Expand Down Expand Up @@ -7228,18 +7237,12 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
if (err)
goto out_g1_atu_prob_irq;

err = mv88e6xxx_mdios_register(chip, np);
if (err)
goto out_g1_vtu_prob_irq;

err = mv88e6xxx_register_switch(chip);
if (err)
goto out_mdio;
goto out_g1_vtu_prob_irq;

return 0;

out_mdio:
mv88e6xxx_mdios_unregister(chip);
out_g1_vtu_prob_irq:
mv88e6xxx_g1_vtu_prob_irq_free(chip);
out_g1_atu_prob_irq:
Expand Down Expand Up @@ -7276,7 +7279,6 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev)

mv88e6xxx_phy_destroy(chip);
mv88e6xxx_unregister_switch(chip);
mv88e6xxx_mdios_unregister(chip);

mv88e6xxx_g1_vtu_prob_irq_free(chip);
mv88e6xxx_g1_atu_prob_irq_free(chip);
Expand Down

0 comments on commit 2cb0658

Please sign in to comment.