Skip to content

Commit 43624ed

Browse files
Haibo Chenbrgl
authored andcommitted
gpio: pca953x: use the correct register address to do regcache sync
For regcache_sync_region, need to use pca953x_recalc_addr() to get the real register address. Fixes: b765743 ("gpio: pca953x: Restore registers after suspend/resume cycle") Signed-off-by: Haibo Chen <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 8a17295 commit 43624ed

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,37 +1108,40 @@ static int pca953x_regcache_sync(struct device *dev)
11081108
{
11091109
struct pca953x_chip *chip = dev_get_drvdata(dev);
11101110
int ret;
1111+
u8 regaddr;
11111112

11121113
/*
11131114
* The ordering between direction and output is important,
11141115
* sync these registers first and only then sync the rest.
11151116
*/
1116-
ret = regcache_sync_region(chip->regmap, chip->regs->direction,
1117-
chip->regs->direction + NBANK(chip));
1117+
regaddr = pca953x_recalc_addr(chip, chip->regs->direction, 0);
1118+
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip));
11181119
if (ret) {
11191120
dev_err(dev, "Failed to sync GPIO dir registers: %d\n", ret);
11201121
return ret;
11211122
}
11221123

1123-
ret = regcache_sync_region(chip->regmap, chip->regs->output,
1124-
chip->regs->output + NBANK(chip));
1124+
regaddr = pca953x_recalc_addr(chip, chip->regs->output, 0);
1125+
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip));
11251126
if (ret) {
11261127
dev_err(dev, "Failed to sync GPIO out registers: %d\n", ret);
11271128
return ret;
11281129
}
11291130

11301131
#ifdef CONFIG_GPIO_PCA953X_IRQ
11311132
if (chip->driver_data & PCA_PCAL) {
1132-
ret = regcache_sync_region(chip->regmap, PCAL953X_IN_LATCH,
1133-
PCAL953X_IN_LATCH + NBANK(chip));
1133+
regaddr = pca953x_recalc_addr(chip, PCAL953X_IN_LATCH, 0);
1134+
ret = regcache_sync_region(chip->regmap, regaddr,
1135+
regaddr + NBANK(chip));
11341136
if (ret) {
11351137
dev_err(dev, "Failed to sync INT latch registers: %d\n",
11361138
ret);
11371139
return ret;
11381140
}
11391141

1140-
ret = regcache_sync_region(chip->regmap, PCAL953X_INT_MASK,
1141-
PCAL953X_INT_MASK + NBANK(chip));
1142+
regaddr = pca953x_recalc_addr(chip, PCAL953X_INT_MASK, 0);
1143+
ret = regcache_sync_region(chip->regmap, regaddr,
1144+
regaddr + NBANK(chip));
11421145
if (ret) {
11431146
dev_err(dev, "Failed to sync INT mask registers: %d\n",
11441147
ret);

0 commit comments

Comments
 (0)