gpio: pca953x: Fix corruption of other gpios in set_multiple.
authorPhil Reid <preid@electromag.com.au>
Tue, 8 Nov 2016 06:00:45 +0000 (14:00 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 8 Nov 2016 09:29:42 +0000 (10:29 +0100)
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

index e422568e14ad19273c277fc1565d068ab2819c53..4a8d0fe60e0c49588da5dfc4ee1c18eb55701b9e 100644 (file)
@@ -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;
                }
        }