Re: [RFC PATCH] gpiolib: chain irq_request/release_resources() and irq_dis/enable()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux