Commit 43624eda authored by Haibo Chen's avatar Haibo Chen Committed by Bartosz Golaszewski

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: b7657430 ("gpio: pca953x: Restore registers after suspend/resume cycle")
Signed-off-by: default avatarHaibo Chen <haibo.chen@nxp.com>
Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
parent 8a172952
...@@ -1108,20 +1108,21 @@ static int pca953x_regcache_sync(struct device *dev) ...@@ -1108,20 +1108,21 @@ static int pca953x_regcache_sync(struct device *dev)
{ {
struct pca953x_chip *chip = dev_get_drvdata(dev); struct pca953x_chip *chip = dev_get_drvdata(dev);
int ret; int ret;
u8 regaddr;
/* /*
* The ordering between direction and output is important, * The ordering between direction and output is important,
* sync these registers first and only then sync the rest. * sync these registers first and only then sync the rest.
*/ */
ret = regcache_sync_region(chip->regmap, chip->regs->direction, regaddr = pca953x_recalc_addr(chip, chip->regs->direction, 0);
chip->regs->direction + NBANK(chip)); ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip));
if (ret) { if (ret) {
dev_err(dev, "Failed to sync GPIO dir registers: %d\n", ret); dev_err(dev, "Failed to sync GPIO dir registers: %d\n", ret);
return ret; return ret;
} }
ret = regcache_sync_region(chip->regmap, chip->regs->output, regaddr = pca953x_recalc_addr(chip, chip->regs->output, 0);
chip->regs->output + NBANK(chip)); ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip));
if (ret) { if (ret) {
dev_err(dev, "Failed to sync GPIO out registers: %d\n", ret); dev_err(dev, "Failed to sync GPIO out registers: %d\n", ret);
return ret; return ret;
...@@ -1129,16 +1130,18 @@ static int pca953x_regcache_sync(struct device *dev) ...@@ -1129,16 +1130,18 @@ static int pca953x_regcache_sync(struct device *dev)
#ifdef CONFIG_GPIO_PCA953X_IRQ #ifdef CONFIG_GPIO_PCA953X_IRQ
if (chip->driver_data & PCA_PCAL) { if (chip->driver_data & PCA_PCAL) {
ret = regcache_sync_region(chip->regmap, PCAL953X_IN_LATCH, regaddr = pca953x_recalc_addr(chip, PCAL953X_IN_LATCH, 0);
PCAL953X_IN_LATCH + NBANK(chip)); ret = regcache_sync_region(chip->regmap, regaddr,
regaddr + NBANK(chip));
if (ret) { if (ret) {
dev_err(dev, "Failed to sync INT latch registers: %d\n", dev_err(dev, "Failed to sync INT latch registers: %d\n",
ret); ret);
return ret; return ret;
} }
ret = regcache_sync_region(chip->regmap, PCAL953X_INT_MASK, regaddr = pca953x_recalc_addr(chip, PCAL953X_INT_MASK, 0);
PCAL953X_INT_MASK + NBANK(chip)); ret = regcache_sync_region(chip->regmap, regaddr,
regaddr + NBANK(chip));
if (ret) { if (ret) {
dev_err(dev, "Failed to sync INT mask registers: %d\n", dev_err(dev, "Failed to sync INT mask registers: %d\n",
ret); ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment