On Mon, Jul 23, 2018 at 5:03 PM Hans Verkuil <hverkuil@xxxxxxxxx> wrote: > Here is yet another attempt to allow drivers to disable the irq and drive > the gpio as an output. This is more like it! > This patch lets gpiolib override the irq_chip's irq_request/release_resources and > irq_en/disable hooks. > > The old hooks are stored and called by gpiolib. OK this seems reasonable. > static void gpiochip_irq_relres(struct irq_data *d) > { > struct gpio_chip *chip = irq_data_get_irq_chip_data(d); > > - gpiochip_unlock_as_irq(chip, d->hwirq); > + if (chip->irq.chip->irq_release_resources) > + chip->irq.chip->irq_release_resources(d); > module_put(chip->gpiodev->owner); > } > > +static void gpiochip_irq_enable(struct irq_data *d) > +{ > + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); > + > + WARN_ON(gpiochip_lock_as_irq(chip, d->hwirq)); > + if (chip->irq.chip->irq_enable) > + chip->irq.chip->irq_enable(d); > + else > + chip->irq.chip->irq_unmask(d); > +} > + > +static void gpiochip_irq_disable(struct irq_data *d) > +{ > + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); > + > + gpiochip_unlock_as_irq(chip, d->hwirq); > + if (chip->irq.chip->irq_disable) > + chip->irq.chip->irq_disable(d); > + else > + chip->irq.chip->irq_mask(d); > +} This does the right thing. The only problem I see is that this kind of re-implements the core semantics of the irqhchip to call disable/mask or enable/unmask. But it's fine if Marc is OK with it, it does the trick. Yours, Linus Walleij