Message ID | 1658133103-23394-3-git-send-email-haibo.chen@nxp.com |
---|---|
State | New |
Headers | show |
Series | [1/3] gpio: pca953x: only use single read/write for No AI mode | expand |
On Mon, Jul 18, 2022 at 10:56 AM <haibo.chen@nxp.com> wrote: > > From: Haibo Chen <haibo.chen@nxp.com> > > For regcache_sync_region, need to use pca953x_recalc_addr() to get we need > the real register address. A couple of comments, here, otherwise you can add Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> to _all_three_ patches. > Fixes: ec82d1eba346 ("gpio: pca953x: Zap ad-hoc reg_output cache") > Fixes: 0f25fda840a9 ("gpio: pca953x: Zap ad-hoc reg_direction cache") > Signed-off-by: Haibo Chen <haibo.chen@nxp.com> > --- > drivers/gpio/gpio-pca953x.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c > index 18888ec24d04..1747b6a9d5bf 100644 > --- a/drivers/gpio/gpio-pca953x.c > +++ b/drivers/gpio/gpio-pca953x.c > @@ -910,14 +910,17 @@ static int device_pca95xx_init(struct pca953x_chip *chip, u32 invert) > { > DECLARE_BITMAP(val, MAX_LINE); > int ret; > + u8 regaddr; Please, keep it on "longest line first" order. > - 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;
On Mon, Jul 18, 2022 at 2:00 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > > On Mon, Jul 18, 2022 at 10:56 AM <haibo.chen@nxp.com> wrote: > > > > From: Haibo Chen <haibo.chen@nxp.com> > > > > For regcache_sync_region, need to use pca953x_recalc_addr() to get > > we need > > > the real register address. > > A couple of comments, here, otherwise you can add > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> > to _all_three_ patches. > > > Fixes: ec82d1eba346 ("gpio: pca953x: Zap ad-hoc reg_output cache") > > Fixes: 0f25fda840a9 ("gpio: pca953x: Zap ad-hoc reg_direction cache") > > Signed-off-by: Haibo Chen <haibo.chen@nxp.com> > > --- > > drivers/gpio/gpio-pca953x.c | 11 +++++++---- > > 1 file changed, 7 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c > > index 18888ec24d04..1747b6a9d5bf 100644 > > --- a/drivers/gpio/gpio-pca953x.c > > +++ b/drivers/gpio/gpio-pca953x.c > > @@ -910,14 +910,17 @@ static int device_pca95xx_init(struct pca953x_chip *chip, u32 invert) > > { > > DECLARE_BITMAP(val, MAX_LINE); > > int ret; > > + u8 regaddr; > > Please, keep it on "longest line first" order. > > > - 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; > > -- > With Best Regards, > Andy Shevchenko I fixed those up locally and applied all three. Bart
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 18888ec24d04..1747b6a9d5bf 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -910,14 +910,17 @@ static int device_pca95xx_init(struct pca953x_chip *chip, u32 invert) { DECLARE_BITMAP(val, MAX_LINE); int ret; + u8 regaddr; - 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;