]> git.baikalelectronics.ru Git - kernel.git/commitdiff
gpio: pca953x: use the correct register address when regcache sync during init
authorHaibo Chen <haibo.chen@nxp.com>
Mon, 18 Jul 2022 08:31:43 +0000 (16:31 +0800)
committerBartosz Golaszewski <brgl@bgdev.pl>
Tue, 19 Jul 2022 09:20:41 +0000 (11:20 +0200)
For regcache_sync_region, we need to use pca953x_recalc_addr() to get
the real register address.

Fixes: 32978bafc5b7 ("gpio: pca953x: Zap ad-hoc reg_output cache")
Fixes: 34c05ffac073 ("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>
drivers/gpio/gpio-pca953x.c

index 18888ec24d0458190e401d41e445a13f8e8ee3ca..ecd7d169470b068ddbbc9685ae33a1f0a860cd32 100644 (file)
@@ -909,15 +909,18 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 static int device_pca95xx_init(struct pca953x_chip *chip, u32 invert)
 {
        DECLARE_BITMAP(val, MAX_LINE);
+       u8 regaddr;
        int ret;
 
-       ret = regcache_sync_region(chip->regmap, chip->regs->output,
-                                  chip->regs->output + NBANK(chip) - 1);
+       regaddr = pca953x_recalc_addr(chip, chip->regs->output, 0);
+       ret = regcache_sync_region(chip->regmap, regaddr,
+                                  regaddr + NBANK(chip) - 1);
        if (ret)
                goto out;
 
-       ret = regcache_sync_region(chip->regmap, chip->regs->direction,
-                                  chip->regs->direction + NBANK(chip) - 1);
+       regaddr = pca953x_recalc_addr(chip, chip->regs->direction, 0);
+       ret = regcache_sync_region(chip->regmap, regaddr,
+                                  regaddr + NBANK(chip) - 1);
        if (ret)
                goto out;