]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gpio: pca953x: Move memcpy into mutex lock for set multiple
authorPhil Reid <preid@electromag.com.au>
Tue, 8 Nov 2016 05:18:11 +0000 (13:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2016 08:56:59 +0000 (09:56 +0100)
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.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpio/gpio-pca953x.c

index 02f2a5621bb0fd132a3a7dd131c865b8d24b107a..5fae629c241e6f012e86a81881fb56bcb23f46a8 100644 (file)
@@ -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);