[v2] gpio: gpio-pca953x: no interrupts with 4-bit devices
diff mbox

Message ID emabcbfc80-7a10-4494-be09-92de321c5d0e@t410-5a
State New
Headers show

Commit Message

mrpace2@gmail.com March 10, 2016, 10:15 a.m. UTC
The NBANK macro can be extended in order to avoid the underflow:

#define NBANK(chip) (chip->gpio_chip.ngpio == 0 ? 0 : \
     ((chip->gpio_chip.ngpio + (BANK_SZ - 1)) / BANK_SZ))
Resending a modified patch.

Signed-off-by: Frank Edelhaeuser <mrpace2 <at> gmail.com>
---

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Grygorii Strashko March 10, 2016, 6:02 p.m. UTC | #1
On 03/10/2016 05:15 PM, mrpace2@gmail.com wrote:
> The NBANK macro can be extended in order to avoid the underflow:
>
> #define NBANK(chip) (chip->gpio_chip.ngpio == 0 ? 0 : \
>      ((chip->gpio_chip.ngpio + (BANK_SZ - 1)) / BANK_SZ))
> Resending a modified patch.
>
> Signed-off-by: Frank Edelhaeuser <mrpace2 <at> gmail.com>
> ---
> diff -Nur a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> --- a/drivers/gpio/gpio-pca953x.c 2016-03-10 02:34:56.012345678 +0000
> +++ b/drivers/gpio/gpio-pca953x.c 2016-03-10 02:34:56.012345678 +0000
> @@ -86,7 +86,8 @@
>   #define MAX_BANK 5
>   #define BANK_SZ 8
>
> -#define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ)
> +#define NBANK(chip) (chip->gpio_chip.ngpio == 0 ? 0 : \
> +    ((chip->gpio_chip.ngpio + (BANK_SZ - 1)) / BANK_SZ))
>

And finally this DIV_ROUND_UP:) Right?

Patch
diff mbox

diff -Nur a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
--- a/drivers/gpio/gpio-pca953x.c 2016-03-10 02:34:56.012345678 +0000
+++ b/drivers/gpio/gpio-pca953x.c 2016-03-10 02:34:56.012345678 +0000
@@ -86,7 +86,8 @@ 
  #define MAX_BANK 5
  #define BANK_SZ 8

-#define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ)
+#define NBANK(chip) (chip->gpio_chip.ngpio == 0 ? 0 : \
+    ((chip->gpio_chip.ngpio + (BANK_SZ - 1)) / BANK_SZ))

  struct pca953x_chip {
   unsigned gpio_start;