diff mbox

[1/1] gpio: pca953x: Fix corruption of other gpios in set_multiple.

Message ID 1478584845-75666-1-git-send-email-preid@electromag.com.au
State New
Headers show

Commit Message

Phil Reid Nov. 8, 2016, 6 a.m. UTC
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.

Signed-off-by: Phil Reid <preid@electromag.com.au>
---
 drivers/gpio/gpio-pca953x.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Linus Walleij Nov. 8, 2016, 8:30 a.m. UTC | #1
On Tue, Nov 8, 2016 at 7:00 AM, Phil Reid <preid@electromag.com.au> wrote:

> 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.
>
> Signed-off-by: Phil Reid <preid@electromag.com.au>

Patch applied for fixes. Should it also be tagged for stable?
Is there a commit this fixes that we can set as Fixes:?

Yours,
Linus Walleij
--
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
Phil Reid Nov. 8, 2016, 8:53 a.m. UTC | #2
On 8/11/2016 16:30, Linus Walleij wrote:
> On Tue, Nov 8, 2016 at 7:00 AM, Phil Reid <preid@electromag.com.au> wrote:
>
>> 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.
>>
>> Signed-off-by: Phil Reid <preid@electromag.com.au>
>
> Patch applied for fixes. Should it also be tagged for stable?
> Is there a commit this fixes that we can set as Fixes:?
>
It looks like it was broken in my original implementation of the set_multiple call.
fixes commit: b4818afeacbd81821f89a89951471cffcb6a65e0

I guess it should probably go into stable.
diff mbox

Patch

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index b0eb113..fe731f0 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 (bank_mask) {
 			bank_val = bits[bank / sizeof(*bits)] >>
 				  ((bank % sizeof(*bits)) * 8);
+			bank_val &= bank_mask;
 			reg_val[bank] = (reg_val[bank] & ~bank_mask) | bank_val;
 		}
 	}