linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] gpio: pca953x: Switch to bitops in IRQ callbacks
@ 2019-12-09 12:35 Andy Shevchenko
  2019-12-09 12:35 ` [PATCH v1 2/2] gpio: pca953x: Remove redundant forward declaration Andy Shevchenko
  2019-12-11  9:49 ` [PATCH v1 1/2] gpio: pca953x: Switch to bitops in IRQ callbacks Bartosz Golaszewski
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2019-12-09 12:35 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio; +Cc: Andy Shevchenko

Since we have driver converted to use bitmap API we must use
traditional bit operations (set_bit(), clear_bit(), etc.)
against it.

Currently IRQ callbacks are missed in the conversion and
thus broken.

Let's fix it right here right now.

Fixes: 35d13d94893f ("gpio: pca953x: convert to use bitmap API")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 6652bee01966..9853547e7276 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -568,16 +568,18 @@ static void pca953x_irq_mask(struct irq_data *d)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
 	struct pca953x_chip *chip = gpiochip_get_data(gc);
+	irq_hw_number_t hwirq = irqd_to_hwirq(d);
 
-	chip->irq_mask[d->hwirq / BANK_SZ] &= ~BIT(d->hwirq % BANK_SZ);
+	clear_bit(hwirq, chip->irq_mask);
 }
 
 static void pca953x_irq_unmask(struct irq_data *d)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
 	struct pca953x_chip *chip = gpiochip_get_data(gc);
+	irq_hw_number_t hwirq = irqd_to_hwirq(d);
 
-	chip->irq_mask[d->hwirq / BANK_SZ] |= BIT(d->hwirq % BANK_SZ);
+	set_bit(hwirq, chip->irq_mask);
 }
 
 static int pca953x_irq_set_wake(struct irq_data *d, unsigned int on)
@@ -635,8 +637,7 @@ static int pca953x_irq_set_type(struct irq_data *d, unsigned int type)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
 	struct pca953x_chip *chip = gpiochip_get_data(gc);
-	int bank_nb = d->hwirq / BANK_SZ;
-	u8 mask = BIT(d->hwirq % BANK_SZ);
+	irq_hw_number_t hwirq = irqd_to_hwirq(d);
 
 	if (!(type & IRQ_TYPE_EDGE_BOTH)) {
 		dev_err(&chip->client->dev, "irq %d: unsupported type %d\n",
@@ -644,15 +645,8 @@ static int pca953x_irq_set_type(struct irq_data *d, unsigned int type)
 		return -EINVAL;
 	}
 
-	if (type & IRQ_TYPE_EDGE_FALLING)
-		chip->irq_trig_fall[bank_nb] |= mask;
-	else
-		chip->irq_trig_fall[bank_nb] &= ~mask;
-
-	if (type & IRQ_TYPE_EDGE_RISING)
-		chip->irq_trig_raise[bank_nb] |= mask;
-	else
-		chip->irq_trig_raise[bank_nb] &= ~mask;
+	assign_bit(hwirq, chip->irq_trig_fall, type & IRQ_TYPE_EDGE_FALLING);
+	assign_bit(hwirq, chip->irq_trig_raise, type & IRQ_TYPE_EDGE_RISING);
 
 	return 0;
 }
@@ -661,10 +655,10 @@ static void pca953x_irq_shutdown(struct irq_data *d)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
 	struct pca953x_chip *chip = gpiochip_get_data(gc);
-	u8 mask = BIT(d->hwirq % BANK_SZ);
+	irq_hw_number_t hwirq = irqd_to_hwirq(d);
 
-	chip->irq_trig_raise[d->hwirq / BANK_SZ] &= ~mask;
-	chip->irq_trig_fall[d->hwirq / BANK_SZ] &= ~mask;
+	clear_bit(hwirq, chip->irq_trig_raise);
+	clear_bit(hwirq, chip->irq_trig_fall);
 }
 
 static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pending)
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1 2/2] gpio: pca953x: Remove redundant forward declaration
  2019-12-09 12:35 [PATCH v1 1/2] gpio: pca953x: Switch to bitops in IRQ callbacks Andy Shevchenko
@ 2019-12-09 12:35 ` Andy Shevchenko
  2019-12-11  9:50   ` Bartosz Golaszewski
  2019-12-11  9:49 ` [PATCH v1 1/2] gpio: pca953x: Switch to bitops in IRQ callbacks Bartosz Golaszewski
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2019-12-09 12:35 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio; +Cc: Andy Shevchenko

There is no need to have a forward declaration for pca953x_dt_ids[].

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 9853547e7276..2f8f5eb28ec5 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -855,8 +855,6 @@ static int device_pca957x_init(struct pca953x_chip *chip, u32 invert)
 	return ret;
 }
 
-static const struct of_device_id pca953x_dt_ids[];
-
 static int pca953x_probe(struct i2c_client *client,
 			 const struct i2c_device_id *i2c_id)
 {
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/2] gpio: pca953x: Switch to bitops in IRQ callbacks
  2019-12-09 12:35 [PATCH v1 1/2] gpio: pca953x: Switch to bitops in IRQ callbacks Andy Shevchenko
  2019-12-09 12:35 ` [PATCH v1 2/2] gpio: pca953x: Remove redundant forward declaration Andy Shevchenko
@ 2019-12-11  9:49 ` Bartosz Golaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-12-11  9:49 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linus Walleij, linux-gpio

pon., 9 gru 2019 o 13:35 Andy Shevchenko
<andriy.shevchenko@linux.intel.com> napisał(a):
>
> Since we have driver converted to use bitmap API we must use
> traditional bit operations (set_bit(), clear_bit(), etc.)
> against it.
>
> Currently IRQ callbacks are missed in the conversion and
> thus broken.
>
> Let's fix it right here right now.
>
> Fixes: 35d13d94893f ("gpio: pca953x: convert to use bitmap API")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-pca953x.c | 26 ++++++++++----------------
>  1 file changed, 10 insertions(+), 16 deletions(-)
>

Applied for fixes.

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 2/2] gpio: pca953x: Remove redundant forward declaration
  2019-12-09 12:35 ` [PATCH v1 2/2] gpio: pca953x: Remove redundant forward declaration Andy Shevchenko
@ 2019-12-11  9:50   ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-12-11  9:50 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linus Walleij, linux-gpio

pon., 9 gru 2019 o 13:35 Andy Shevchenko
<andriy.shevchenko@linux.intel.com> napisał(a):
>
> There is no need to have a forward declaration for pca953x_dt_ids[].
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-pca953x.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 9853547e7276..2f8f5eb28ec5 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -855,8 +855,6 @@ static int device_pca957x_init(struct pca953x_chip *chip, u32 invert)
>         return ret;
>  }
>
> -static const struct of_device_id pca953x_dt_ids[];
> -
>  static int pca953x_probe(struct i2c_client *client,
>                          const struct i2c_device_id *i2c_id)
>  {
> --
> 2.24.0
>

Applied for next.

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-11  9:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09 12:35 [PATCH v1 1/2] gpio: pca953x: Switch to bitops in IRQ callbacks Andy Shevchenko
2019-12-09 12:35 ` [PATCH v1 2/2] gpio: pca953x: Remove redundant forward declaration Andy Shevchenko
2019-12-11  9:50   ` Bartosz Golaszewski
2019-12-11  9:49 ` [PATCH v1 1/2] gpio: pca953x: Switch to bitops in IRQ callbacks Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).