Re: [PATCH v2 2/2] gpio: zynq: Take bank offset into account when reporting a IRQ

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

 



On Mon, Aug 18, 2014 at 2:54 AM, Lars-Peter Clausen <lars@xxxxxxxxxx> wrote:
> When looking up the IRQ the bank offset needs to be taken into account.
> Otherwise interrupts for banks other than bank 0 get incorrectly reported as
> interrupts for bank 0.
>
> Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
> ---
> Changes since v1:
>         * Use lookup table instead of switch-case.
> ---
>  drivers/gpio/gpio-zynq.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)

Yep, you saved 16 lines compared to the first version of this patch. :)

I assume overflows over this array cannot happen (otherwise a quick
check against ARRAY_SIZE(zynq_gpio_bank_offset) would do the trick),
if so:

Acked-by: Alexandre Courbot <acourbot@xxxxxxxxxx>

>
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index f440317..5db1af7 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -138,6 +138,13 @@ static inline void zynq_gpio_get_bank_pin(unsigned int pin_num,
>         }
>  }
>
> +static const unsigned int zynq_gpio_bank_offset[] = {
> +       ZYNQ_GPIO_BANK0_PIN_MIN,
> +       ZYNQ_GPIO_BANK1_PIN_MIN,
> +       ZYNQ_GPIO_BANK2_PIN_MIN,
> +       ZYNQ_GPIO_BANK3_PIN_MIN,
> +};
> +
>  /**
>   * zynq_gpio_get_value - Get the state of the specified pin of GPIO device
>   * @chip:      gpio_chip instance to be worked on
> @@ -461,6 +468,7 @@ static void zynq_gpio_handle_bank_irq(struct zynq_gpio *gpio,
>                                       unsigned int bank_num,
>                                       unsigned long pending)
>  {
> +       unsigned int bank_offset = zynq_gpio_bank_offset[bank_num];
>         struct irq_domain *irqdomain = gpio->chip.irqdomain;
>         int offset;
>
> @@ -470,7 +478,7 @@ static void zynq_gpio_handle_bank_irq(struct zynq_gpio *gpio,
>         for_each_set_bit(offset, &pending, 32) {
>                 unsigned int gpio_irq;
>
> -               gpio_irq = irq_find_mapping(irqdomain, offset);
> +               gpio_irq = irq_find_mapping(irqdomain, offset + bank_offset);
>                 generic_handle_irq(gpio_irq);
>         }
>  }
> --
> 1.8.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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