Skip to content

Commit

Permalink
Merge branch 'mv88e6xxx-error-patch-fixes'
Browse files Browse the repository at this point in the history
Andrew Lunn says:

====================
mv88e6xxx error patch fixes

While trying to bring up a new PHY on a board, i exercised the error
paths a bit, and discovered some bugs. The unwind for interrupt
handling deadlocks, and the MDIO code hits a BUG() when a registered
MDIO device is freed without first being unregistered.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Dec 7, 2017
2 parents e46772a + 3126aee commit c880949
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions drivers/net/dsa/mv88e6xxx/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
u16 mask;

mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
mask |= GENMASK(chip->g1_irq.nirqs, 0);
mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);

free_irq(chip->irq, chip);
Expand Down Expand Up @@ -395,7 +395,7 @@ static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
return 0;

out_disable:
mask |= GENMASK(chip->g1_irq.nirqs, 0);
mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);

out_mapping:
Expand Down Expand Up @@ -2177,6 +2177,19 @@ static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
{ },
};

static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)

{
struct mv88e6xxx_mdio_bus *mdio_bus;
struct mii_bus *bus;

list_for_each_entry(mdio_bus, &chip->mdios, list) {
bus = mdio_bus->bus;

mdiobus_unregister(bus);
}
}

static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
struct device_node *np)
{
Expand All @@ -2201,27 +2214,16 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
match = of_match_node(mv88e6xxx_mdio_external_match, child);
if (match) {
err = mv88e6xxx_mdio_register(chip, child, true);
if (err)
if (err) {
mv88e6xxx_mdios_unregister(chip);
return err;
}
}
}

return 0;
}

static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)

{
struct mv88e6xxx_mdio_bus *mdio_bus;
struct mii_bus *bus;

list_for_each_entry(mdio_bus, &chip->mdios, list) {
bus = mdio_bus->bus;

mdiobus_unregister(bus);
}
}

static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
{
struct mv88e6xxx_chip *chip = ds->priv;
Expand Down

0 comments on commit c880949

Please sign in to comment.