Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 386377b5 authored by Phil Reid's avatar Phil Reid Committed by Linus Walleij
Browse files

gpio: pca953x: Move memcpy into mutex lock for set multiple



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: b4818afe ("gpio: pca953x: Add set_multiple to allow multiple")
Signed-off-by: default avatarPhil Reid <preid@electromag.com.au>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 53f8d322
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -372,8 +372,8 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc,


	bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ);
	bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ);


	memcpy(reg_val, chip->reg_output, NBANK(chip));
	mutex_lock(&chip->i2c_lock);
	mutex_lock(&chip->i2c_lock);
	memcpy(reg_val, chip->reg_output, NBANK(chip));
	for (bank = 0; bank < NBANK(chip); bank++) {
	for (bank = 0; bank < NBANK(chip); bank++) {
		bank_mask = mask[bank / sizeof(*mask)] >>
		bank_mask = mask[bank / sizeof(*mask)] >>
			   ((bank % sizeof(*mask)) * 8);
			   ((bank % sizeof(*mask)) * 8);
@@ -608,7 +608,6 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,


	if (client->irq && irq_base != -1
	if (client->irq && irq_base != -1
			&& (chip->driver_data & PCA_INT)) {
			&& (chip->driver_data & PCA_INT)) {

		ret = pca953x_read_regs(chip,
		ret = pca953x_read_regs(chip,
					chip->regs->input, chip->irq_stat);
					chip->regs->input, chip->irq_stat);
		if (ret)
		if (ret)