Re: [PATCH v5 2/2] gpio: add a reusable generic gpio_chip using regmap

From: Andy Shevchenko
Date: Thu May 28 2020 - 09:43:19 EST


On Thu, May 28, 2020 at 4:00 PM Michael Walle <michael@xxxxxxxx> wrote:
> Am 2020-05-28 13:45, schrieb Andy Shevchenko:
> > On Thu, May 28, 2020 at 7:04 AM Michael Walle <michael@xxxxxxxx> wrote:

> > More comments from me below.
>
> Thanks for the review.

You are welcome! Thanks for doing this actually.

(So, the not commented points I think you agreed with)

...

> >> # Device drivers. Generally keep list sorted alphabetically
> >
> > Hmm...
> >
> >> +obj-$(CONFIG_GPIO_REGMAP) += gpio-regmap.o
> >> obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
> >
> > ...is it?
>
> That's because gpio-regmap.o seems not be a driver and more of a generic
> thing (like gpio-generic.o) and gpio-generic.o has another rule two
> lines
> below and I don't want to put gpio-regmap.o in between.

OK!

...

> >> + if (gpio->reg_dir_out_base) {
> >> + base = gpio_regmap_addr(gpio->reg_dir_out_base);
> >> + invert = 0;
> >> + } else if (gpio->reg_dir_in_base) {
> >> + base = gpio_regmap_addr(gpio->reg_dir_in_base);
> >> + invert = 1;
> >> + } else {
> >
> >> + return GPIO_LINE_DIRECTION_IN;
> >
> > Hmm... Doesn't it an erroneous case and we basically shouldn't be here?
>
> yeah, I'll return -EOPNOTSUPP. Better than just ignoring, right?

Yes, that's what I meant.

...

> >> + if (!!(val & mask) ^ invert)
> >> + return GPIO_LINE_DIRECTION_OUT;
> >
> >> + else
> >
> > Redundant 'else'.
>
> IMHO, That looks really strange. like it has nothing to do with the
> if statement. I'd like to keep that one.

We have many drivers done like that, but it's minor, so, up to you and
maintainers.

--
With Best Regards,
Andy Shevchenko