Skip to content

Commit 2abc17a

Browse files
Haibo Chenbrgl
authored andcommitted
gpio: pca953x: use the correct range when do regmap sync
regmap will sync a range of registers, here use the correct range to make sure the sync do not touch other unexpected registers. Find on pca9557pw on imx8qxp/dxl evk board, this device support 8 pin, so only need one register(8 bits) to cover all the 8 pins's property setting. But when sync the output, we find it actually update two registers, output register and the following register. Fixes: b765743 ("gpio: pca953x: Restore registers after suspend/resume cycle") Fixes: ec82d1e ("gpio: pca953x: Zap ad-hoc reg_output cache") Fixes: 0f25fda ("gpio: pca953x: Zap ad-hoc reg_direction cache") Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
1 parent db8edaa commit 2abc17a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -912,12 +912,12 @@ static int device_pca95xx_init(struct pca953x_chip *chip, u32 invert)
912912
int ret;
913913

914914
ret = regcache_sync_region(chip->regmap, chip->regs->output,
915-
chip->regs->output + NBANK(chip));
915+
chip->regs->output + NBANK(chip) - 1);
916916
if (ret)
917917
goto out;
918918

919919
ret = regcache_sync_region(chip->regmap, chip->regs->direction,
920-
chip->regs->direction + NBANK(chip));
920+
chip->regs->direction + NBANK(chip) - 1);
921921
if (ret)
922922
goto out;
923923

@@ -1130,14 +1130,14 @@ static int pca953x_regcache_sync(struct device *dev)
11301130
* sync these registers first and only then sync the rest.
11311131
*/
11321132
regaddr = pca953x_recalc_addr(chip, chip->regs->direction, 0);
1133-
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip));
1133+
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip) - 1);
11341134
if (ret) {
11351135
dev_err(dev, "Failed to sync GPIO dir registers: %d\n", ret);
11361136
return ret;
11371137
}
11381138

11391139
regaddr = pca953x_recalc_addr(chip, chip->regs->output, 0);
1140-
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip));
1140+
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip) - 1);
11411141
if (ret) {
11421142
dev_err(dev, "Failed to sync GPIO out registers: %d\n", ret);
11431143
return ret;
@@ -1147,7 +1147,7 @@ static int pca953x_regcache_sync(struct device *dev)
11471147
if (chip->driver_data & PCA_PCAL) {
11481148
regaddr = pca953x_recalc_addr(chip, PCAL953X_IN_LATCH, 0);
11491149
ret = regcache_sync_region(chip->regmap, regaddr,
1150-
regaddr + NBANK(chip));
1150+
regaddr + NBANK(chip) - 1);
11511151
if (ret) {
11521152
dev_err(dev, "Failed to sync INT latch registers: %d\n",
11531153
ret);
@@ -1156,7 +1156,7 @@ static int pca953x_regcache_sync(struct device *dev)
11561156

11571157
regaddr = pca953x_recalc_addr(chip, PCAL953X_INT_MASK, 0);
11581158
ret = regcache_sync_region(chip->regmap, regaddr,
1159-
regaddr + NBANK(chip));
1159+
regaddr + NBANK(chip) - 1);
11601160
if (ret) {
11611161
dev_err(dev, "Failed to sync INT mask registers: %d\n",
11621162
ret);

0 commit comments

Comments
 (0)