Commit 3dd0ef05 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: dsa: mv88e6xxx: Fix cleanup on error for g1 interrupt setup

On error, remask the interrupts, release all maps, and remove the
domain. This cannot be done using the mv88e6xxx_g1_irq_free() because
some of these actions are not idempotent.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3460a577
...@@ -431,8 +431,8 @@ static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip) ...@@ -431,8 +431,8 @@ static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
{ {
int err, irq; int err, irq, virq;
u16 reg; u16 reg, mask;
chip->g1_irq.nirqs = chip->info->g1_irqs; chip->g1_irq.nirqs = chip->info->g1_irqs;
chip->g1_irq.domain = irq_domain_add_simple( chip->g1_irq.domain = irq_domain_add_simple(
...@@ -447,32 +447,41 @@ static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) ...@@ -447,32 +447,41 @@ static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
chip->g1_irq.chip = mv88e6xxx_g1_irq_chip; chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
chip->g1_irq.masked = ~0; chip->g1_irq.masked = ~0;
err = mv88e6xxx_g1_read(chip, GLOBAL_CONTROL, &reg); err = mv88e6xxx_g1_read(chip, GLOBAL_CONTROL, &mask);
if (err) if (err)
goto out; goto out_mapping;
reg &= ~GENMASK(chip->g1_irq.nirqs, 0); mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
err = mv88e6xxx_g1_write(chip, GLOBAL_CONTROL, reg); err = mv88e6xxx_g1_write(chip, GLOBAL_CONTROL, mask);
if (err) if (err)
goto out; goto out_disable;
/* Reading the interrupt status clears (most of) them */ /* Reading the interrupt status clears (most of) them */
err = mv88e6xxx_g1_read(chip, GLOBAL_STATUS, &reg); err = mv88e6xxx_g1_read(chip, GLOBAL_STATUS, &reg);
if (err) if (err)
goto out; goto out_disable;
err = request_threaded_irq(chip->irq, NULL, err = request_threaded_irq(chip->irq, NULL,
mv88e6xxx_g1_irq_thread_fn, mv88e6xxx_g1_irq_thread_fn,
IRQF_ONESHOT | IRQF_TRIGGER_FALLING, IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
dev_name(chip->dev), chip); dev_name(chip->dev), chip);
if (err) if (err)
goto out; goto out_disable;
return 0; return 0;
out: out_disable:
mv88e6xxx_g1_irq_free(chip); mask |= GENMASK(chip->g1_irq.nirqs, 0);
mv88e6xxx_g1_write(chip, GLOBAL_CONTROL, mask);
out_mapping:
for (irq = 0; irq < 16; irq++) {
virq = irq_find_mapping(chip->g1_irq.domain, irq);
irq_dispose_mapping(virq);
}
irq_domain_remove(chip->g1_irq.domain);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment