linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction
@ 2019-08-27  6:46 David Jander
  2019-08-27  6:46 ` [PATCH 2/2] gpio: pca953x.c: Use pca953x_read_regs instead of regmap_bulk_read David Jander
  2019-08-28  8:38 ` [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction Bartosz Golaszewski
  0 siblings, 2 replies; 7+ messages in thread
From: David Jander @ 2019-08-27  6:46 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, David Jander

The type of reg_direction needs to match the type of the regmap, which is
u8.

Signed-off-by: David Jander <david@protonic.nl>
---
 drivers/gpio/gpio-pca953x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 378b206d2dc9..30072a570bc2 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -604,7 +604,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
 	u8 new_irqs;
 	int level, i;
 	u8 invert_irq_mask[MAX_BANK];
-	int reg_direction[MAX_BANK];
+	u8 reg_direction[MAX_BANK];
 
 	regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
 			 NBANK(chip));
@@ -679,7 +679,7 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
 	bool pending_seen = false;
 	bool trigger_seen = false;
 	u8 trigger[MAX_BANK];
-	int reg_direction[MAX_BANK];
+	u8 reg_direction[MAX_BANK];
 	int ret, i;
 
 	if (chip->driver_data & PCA_PCAL) {
@@ -768,7 +768,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 {
 	struct i2c_client *client = chip->client;
 	struct irq_chip *irq_chip = &chip->irq_chip;
-	int reg_direction[MAX_BANK];
+	u8 reg_direction[MAX_BANK];
 	int ret, i;
 
 	if (!client->irq)
-- 
2.19.1


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

* [PATCH 2/2] gpio: pca953x.c: Use pca953x_read_regs instead of regmap_bulk_read
  2019-08-27  6:46 [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction David Jander
@ 2019-08-27  6:46 ` David Jander
  2019-08-28  8:42   ` Bartosz Golaszewski
  2019-08-28  8:38 ` [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction Bartosz Golaszewski
  1 sibling, 1 reply; 7+ messages in thread
From: David Jander @ 2019-08-27  6:46 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, David Jander

The register number needs to be translated for chips with more than 8
ports. This patch fixes a bug causing all chips with more than 8 GPIO pins
to not work correctly.

Signed-off-by: David Jander <david@protonic.nl>
---
 drivers/gpio/gpio-pca953x.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 30072a570bc2..48fea4c68e8d 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -606,8 +606,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
 	u8 invert_irq_mask[MAX_BANK];
 	u8 reg_direction[MAX_BANK];
 
-	regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
-			 NBANK(chip));
+	pca953x_read_regs(chip, chip->regs->direction, reg_direction);
 
 	if (chip->driver_data & PCA_PCAL) {
 		/* Enable latch on interrupt-enabled inputs */
@@ -710,8 +709,7 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
 		return false;
 
 	/* Remove output pins from the equation */
-	regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
-			 NBANK(chip));
+	pca953x_read_regs(chip, chip->regs->direction, reg_direction);
 	for (i = 0; i < NBANK(chip); i++)
 		cur_stat[i] &= reg_direction[i];
 
@@ -789,8 +787,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 	 * interrupt.  We have to rely on the previous read for
 	 * this purpose.
 	 */
-	regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
-			 NBANK(chip));
+	pca953x_read_regs(chip, chip->regs->direction, reg_direction);
 	for (i = 0; i < NBANK(chip); i++)
 		chip->irq_stat[i] &= reg_direction[i];
 	mutex_init(&chip->irq_lock);
-- 
2.19.1


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

* Re: [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction
  2019-08-27  6:46 [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction David Jander
  2019-08-27  6:46 ` [PATCH 2/2] gpio: pca953x.c: Use pca953x_read_regs instead of regmap_bulk_read David Jander
@ 2019-08-28  8:38 ` Bartosz Golaszewski
  2019-08-28 10:56   ` Bartosz Golaszewski
  1 sibling, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2019-08-28  8:38 UTC (permalink / raw)
  To: David Jander; +Cc: Linus Walleij, linux-gpio, LKML

wt., 27 sie 2019 o 08:46 David Jander <david@protonic.nl> napisał(a):
>
> The type of reg_direction needs to match the type of the regmap, which is
> u8.
>
> Signed-off-by: David Jander <david@protonic.nl>
> ---
>  drivers/gpio/gpio-pca953x.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 378b206d2dc9..30072a570bc2 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -604,7 +604,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
>         u8 new_irqs;
>         int level, i;
>         u8 invert_irq_mask[MAX_BANK];
> -       int reg_direction[MAX_BANK];
> +       u8 reg_direction[MAX_BANK];
>
>         regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
>                          NBANK(chip));
> @@ -679,7 +679,7 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
>         bool pending_seen = false;
>         bool trigger_seen = false;
>         u8 trigger[MAX_BANK];
> -       int reg_direction[MAX_BANK];
> +       u8 reg_direction[MAX_BANK];
>         int ret, i;
>
>         if (chip->driver_data & PCA_PCAL) {
> @@ -768,7 +768,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
>  {
>         struct i2c_client *client = chip->client;
>         struct irq_chip *irq_chip = &chip->irq_chip;
> -       int reg_direction[MAX_BANK];
> +       u8 reg_direction[MAX_BANK];
>         int ret, i;
>
>         if (!client->irq)
> --
> 2.19.1
>

Applied for v5.4.

Thanks!
Bart

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

* Re: [PATCH 2/2] gpio: pca953x.c: Use pca953x_read_regs instead of regmap_bulk_read
  2019-08-27  6:46 ` [PATCH 2/2] gpio: pca953x.c: Use pca953x_read_regs instead of regmap_bulk_read David Jander
@ 2019-08-28  8:42   ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2019-08-28  8:42 UTC (permalink / raw)
  To: David Jander; +Cc: Linus Walleij, linux-gpio, LKML

wt., 27 sie 2019 o 08:47 David Jander <david@protonic.nl> napisał(a):
>
> The register number needs to be translated for chips with more than 8
> ports. This patch fixes a bug causing all chips with more than 8 GPIO pins
> to not work correctly.
>
> Signed-off-by: David Jander <david@protonic.nl>
> ---
>  drivers/gpio/gpio-pca953x.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 30072a570bc2..48fea4c68e8d 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -606,8 +606,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
>         u8 invert_irq_mask[MAX_BANK];
>         u8 reg_direction[MAX_BANK];
>
> -       regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
> -                        NBANK(chip));
> +       pca953x_read_regs(chip, chip->regs->direction, reg_direction);
>
>         if (chip->driver_data & PCA_PCAL) {
>                 /* Enable latch on interrupt-enabled inputs */
> @@ -710,8 +709,7 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
>                 return false;
>
>         /* Remove output pins from the equation */
> -       regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
> -                        NBANK(chip));
> +       pca953x_read_regs(chip, chip->regs->direction, reg_direction);
>         for (i = 0; i < NBANK(chip); i++)
>                 cur_stat[i] &= reg_direction[i];
>
> @@ -789,8 +787,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
>          * interrupt.  We have to rely on the previous read for
>          * this purpose.
>          */
> -       regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
> -                        NBANK(chip));
> +       pca953x_read_regs(chip, chip->regs->direction, reg_direction);
>         for (i = 0; i < NBANK(chip); i++)
>                 chip->irq_stat[i] &= reg_direction[i];
>         mutex_init(&chip->irq_lock);
> --
> 2.19.1
>

Applied to fixes. Thanks!

Bart

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

* Re: [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction
  2019-08-28  8:38 ` [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction Bartosz Golaszewski
@ 2019-08-28 10:56   ` Bartosz Golaszewski
  2019-08-28 11:13     ` David Jander
  0 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2019-08-28 10:56 UTC (permalink / raw)
  To: David Jander; +Cc: Linus Walleij, linux-gpio, LKML

śr., 28 sie 2019 o 10:38 Bartosz Golaszewski
<bgolaszewski@baylibre.com> napisał(a):
>
> wt., 27 sie 2019 o 08:46 David Jander <david@protonic.nl> napisał(a):
> >
> > The type of reg_direction needs to match the type of the regmap, which is
> > u8.
> >
> > Signed-off-by: David Jander <david@protonic.nl>
> > ---
> >  drivers/gpio/gpio-pca953x.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> > index 378b206d2dc9..30072a570bc2 100644
> > --- a/drivers/gpio/gpio-pca953x.c
> > +++ b/drivers/gpio/gpio-pca953x.c
> > @@ -604,7 +604,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
> >         u8 new_irqs;
> >         int level, i;
> >         u8 invert_irq_mask[MAX_BANK];
> > -       int reg_direction[MAX_BANK];
> > +       u8 reg_direction[MAX_BANK];
> >
> >         regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
> >                          NBANK(chip));
> > @@ -679,7 +679,7 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
> >         bool pending_seen = false;
> >         bool trigger_seen = false;
> >         u8 trigger[MAX_BANK];
> > -       int reg_direction[MAX_BANK];
> > +       u8 reg_direction[MAX_BANK];
> >         int ret, i;
> >
> >         if (chip->driver_data & PCA_PCAL) {
> > @@ -768,7 +768,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
> >  {
> >         struct i2c_client *client = chip->client;
> >         struct irq_chip *irq_chip = &chip->irq_chip;
> > -       int reg_direction[MAX_BANK];
> > +       u8 reg_direction[MAX_BANK];
> >         int ret, i;
> >
> >         if (!client->irq)
> > --
> > 2.19.1
> >
>
> Applied for v5.4.

Actually the second patch depends on the first one, so moved it over to fixes.

Bart

>
> Thanks!
> Bart

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

* Re: [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction
  2019-08-28 10:56   ` Bartosz Golaszewski
@ 2019-08-28 11:13     ` David Jander
  2019-08-28 12:16       ` Bartosz Golaszewski
  0 siblings, 1 reply; 7+ messages in thread
From: David Jander @ 2019-08-28 11:13 UTC (permalink / raw)
  To: Bartosz Golaszewski; +Cc: Linus Walleij, linux-gpio, LKML

On Wed, 28 Aug 2019 12:56:28 +0200
Bartosz Golaszewski <bgolaszewski@baylibre.com> wrote:

> śr., 28 sie 2019 o 10:38 Bartosz Golaszewski
> <bgolaszewski@baylibre.com> napisał(a):
> >
> > wt., 27 sie 2019 o 08:46 David Jander <david@protonic.nl> napisał(a):  
> > >
> > > The type of reg_direction needs to match the type of the regmap, which is
> > > u8.
> > >
> > > Signed-off-by: David Jander <david@protonic.nl>
> > > ---
> > >  drivers/gpio/gpio-pca953x.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> > > index 378b206d2dc9..30072a570bc2 100644
> > > --- a/drivers/gpio/gpio-pca953x.c
> > > +++ b/drivers/gpio/gpio-pca953x.c
> > > @@ -604,7 +604,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
> > >         u8 new_irqs;
> > >         int level, i;
> > >         u8 invert_irq_mask[MAX_BANK];
> > > -       int reg_direction[MAX_BANK];
> > > +       u8 reg_direction[MAX_BANK];
> > >
> > >         regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
> > >                          NBANK(chip));
> > > @@ -679,7 +679,7 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
> > >         bool pending_seen = false;
> > >         bool trigger_seen = false;
> > >         u8 trigger[MAX_BANK];
> > > -       int reg_direction[MAX_BANK];
> > > +       u8 reg_direction[MAX_BANK];
> > >         int ret, i;
> > >
> > >         if (chip->driver_data & PCA_PCAL) {
> > > @@ -768,7 +768,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
> > >  {
> > >         struct i2c_client *client = chip->client;
> > >         struct irq_chip *irq_chip = &chip->irq_chip;
> > > -       int reg_direction[MAX_BANK];
> > > +       u8 reg_direction[MAX_BANK];
> > >         int ret, i;
> > >
> > >         if (!client->irq)
> > > --
> > > 2.19.1
> > >  
> >
> > Applied for v5.4.  
> 
> Actually the second patch depends on the first one, so moved it over to fixes.

Btw, they are both bugfixes, IMHO it would be valuable to have them in 5.3rc
if possible... there is some severe breakage there right now.

Best regards,

-- 
David Jander


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

* Re: [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction
  2019-08-28 11:13     ` David Jander
@ 2019-08-28 12:16       ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2019-08-28 12:16 UTC (permalink / raw)
  To: David Jander; +Cc: Linus Walleij, linux-gpio, LKML

śr., 28 sie 2019 o 13:13 David Jander <david@protonic.nl> napisał(a):
>
> On Wed, 28 Aug 2019 12:56:28 +0200
> Bartosz Golaszewski <bgolaszewski@baylibre.com> wrote:
>
> > śr., 28 sie 2019 o 10:38 Bartosz Golaszewski
> > <bgolaszewski@baylibre.com> napisał(a):
> > >
> > > wt., 27 sie 2019 o 08:46 David Jander <david@protonic.nl> napisał(a):
> > > >
> > > > The type of reg_direction needs to match the type of the regmap, which is
> > > > u8.
> > > >
> > > > Signed-off-by: David Jander <david@protonic.nl>
> > > > ---
> > > >  drivers/gpio/gpio-pca953x.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> > > > index 378b206d2dc9..30072a570bc2 100644
> > > > --- a/drivers/gpio/gpio-pca953x.c
> > > > +++ b/drivers/gpio/gpio-pca953x.c
> > > > @@ -604,7 +604,7 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
> > > >         u8 new_irqs;
> > > >         int level, i;
> > > >         u8 invert_irq_mask[MAX_BANK];
> > > > -       int reg_direction[MAX_BANK];
> > > > +       u8 reg_direction[MAX_BANK];
> > > >
> > > >         regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
> > > >                          NBANK(chip));
> > > > @@ -679,7 +679,7 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
> > > >         bool pending_seen = false;
> > > >         bool trigger_seen = false;
> > > >         u8 trigger[MAX_BANK];
> > > > -       int reg_direction[MAX_BANK];
> > > > +       u8 reg_direction[MAX_BANK];
> > > >         int ret, i;
> > > >
> > > >         if (chip->driver_data & PCA_PCAL) {
> > > > @@ -768,7 +768,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
> > > >  {
> > > >         struct i2c_client *client = chip->client;
> > > >         struct irq_chip *irq_chip = &chip->irq_chip;
> > > > -       int reg_direction[MAX_BANK];
> > > > +       u8 reg_direction[MAX_BANK];
> > > >         int ret, i;
> > > >
> > > >         if (!client->irq)
> > > > --
> > > > 2.19.1
> > > >
> > >
> > > Applied for v5.4.
> >
> > Actually the second patch depends on the first one, so moved it over to fixes.
>
> Btw, they are both bugfixes, IMHO it would be valuable to have them in 5.3rc
> if possible... there is some severe breakage there right now.
>
> Best regards,
>
> --
> David Jander
>

Yes, that's why I said I moved it to fixes.

Bart

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

end of thread, other threads:[~2019-08-28 12:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27  6:46 [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction David Jander
2019-08-27  6:46 ` [PATCH 2/2] gpio: pca953x.c: Use pca953x_read_regs instead of regmap_bulk_read David Jander
2019-08-28  8:42   ` Bartosz Golaszewski
2019-08-28  8:38 ` [PATCH 1/2] gpio: gpio-pca953x.c: Correct type of reg_direction Bartosz Golaszewski
2019-08-28 10:56   ` Bartosz Golaszewski
2019-08-28 11:13     ` David Jander
2019-08-28 12:16       ` 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).