* [PATCH 0/2] gpio: pca953x: Backported patches for 4.8
@ 2016-11-22 2:34 Phil Reid
2016-11-22 2:34 ` [PATCH 1/2] gpio: pca953x: Move memcpy into mutex lock for set multiple Phil Reid
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Phil Reid @ 2016-11-22 2:34 UTC (permalink / raw)
To: linus.walleij, preid, stable, gregkh
The following two patches should apply to the 4.8 branch.
checkpatch complained about the commit reference format but looking at other
patches in the 4.8 history I see some like this with the full id.
So I'm not exactly sure if I've done this correctly.
Phil Reid (2):
gpio: pca953x: Move memcpy into mutex lock for set multiple
gpio: pca953x: Fix corruption of other gpios in set_multiple.
drivers/gpio/gpio-pca953x.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] gpio: pca953x: Move memcpy into mutex lock for set multiple
2016-11-22 2:34 [PATCH 0/2] gpio: pca953x: Backported patches for 4.8 Phil Reid
@ 2016-11-22 2:34 ` Phil Reid
2016-11-22 2:34 ` [PATCH 2/2] gpio: pca953x: Fix corruption of other gpios in set_multiple Phil Reid
2016-11-22 8:02 ` [PATCH 0/2] gpio: pca953x: Backported patches for 4.8 Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Phil Reid @ 2016-11-22 2:34 UTC (permalink / raw)
To: linus.walleij, preid, stable, gregkh
commit 386377b5473043c09b2de40bfe5abfb0fc87e1b4 upstream.
Need to ensure that reg_output is not updated while setting multiple
bits. This makes the mutex locking behaviour for the set_multiple call
consistent with that of the set_value call.
Cc: stable@vger.kernel.org
Fixes: b4818afeacbd ("gpio: pca953x: Add set_multiple to allow multiple")
Signed-off-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-pca953x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 02f2a56..5fae629 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -372,8 +372,8 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
break;
}
- memcpy(reg_val, chip->reg_output, NBANK(chip));
mutex_lock(&chip->i2c_lock);
+ memcpy(reg_val, chip->reg_output, NBANK(chip));
for(bank=0; bank<NBANK(chip); bank++) {
unsigned bankmask = mask[bank / sizeof(*mask)] >>
((bank % sizeof(*mask)) * 8);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] gpio: pca953x: Fix corruption of other gpios in set_multiple.
2016-11-22 2:34 [PATCH 0/2] gpio: pca953x: Backported patches for 4.8 Phil Reid
2016-11-22 2:34 ` [PATCH 1/2] gpio: pca953x: Move memcpy into mutex lock for set multiple Phil Reid
@ 2016-11-22 2:34 ` Phil Reid
2016-11-22 8:02 ` [PATCH 0/2] gpio: pca953x: Backported patches for 4.8 Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Phil Reid @ 2016-11-22 2:34 UTC (permalink / raw)
To: linus.walleij, preid, stable, gregkh
commit 53f8d322234649b4d6f1515b20c127a577efd164 upstream.
gpiod_set_array_value_complex does not clear the bits field.
Therefore when the drivers set_multiple funciton is called bits outside
the mask are undefined and can be either set or not. So bank_val needs
to be masked with bank_mask before or with the reg_val cache.
Cc: stable@vger.kernel.org
Fixes: b4818afeacbd ("gpio: pca953x: Add set_multiple to allow multiple")
Signed-off-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-pca953x.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 5fae629..47d08b9 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -380,6 +380,7 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
if(bankmask) {
unsigned bankval = bits[bank / sizeof(*bits)] >>
((bank % sizeof(*bits)) * 8);
+ bankval &= bankmask;
reg_val[bank] = (reg_val[bank] & ~bankmask) | bankval;
}
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] gpio: pca953x: Backported patches for 4.8
2016-11-22 2:34 [PATCH 0/2] gpio: pca953x: Backported patches for 4.8 Phil Reid
2016-11-22 2:34 ` [PATCH 1/2] gpio: pca953x: Move memcpy into mutex lock for set multiple Phil Reid
2016-11-22 2:34 ` [PATCH 2/2] gpio: pca953x: Fix corruption of other gpios in set_multiple Phil Reid
@ 2016-11-22 8:02 ` Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2016-11-22 8:02 UTC (permalink / raw)
To: Phil Reid; +Cc: linus.walleij, stable
On Tue, Nov 22, 2016 at 10:34:44AM +0800, Phil Reid wrote:
> The following two patches should apply to the 4.8 branch.
>
> checkpatch complained about the commit reference format but looking at other
> patches in the 4.8 history I see some like this with the full id.
> So I'm not exactly sure if I've done this correctly.
Looks great to me, thanks for doing this.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-22 8:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-22 2:34 [PATCH 0/2] gpio: pca953x: Backported patches for 4.8 Phil Reid
2016-11-22 2:34 ` [PATCH 1/2] gpio: pca953x: Move memcpy into mutex lock for set multiple Phil Reid
2016-11-22 2:34 ` [PATCH 2/2] gpio: pca953x: Fix corruption of other gpios in set_multiple Phil Reid
2016-11-22 8:02 ` [PATCH 0/2] gpio: pca953x: Backported patches for 4.8 Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.