All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 5/8] gpiolib: shrink further
Date: Wed, 10 Nov 2021 13:39:25 +0100	[thread overview]
Message-ID: <CAK8P3a2jroy_0ad7BYb59s5Dz7kOZBRbL4mqj5oJ6M-W=v_RFw@mail.gmail.com> (raw)
In-Reply-To: <CACRpkdacYt4kS2QS4-W83ZtWWtTaAETeH8Buer2wOXBOoBK=qA@mail.gmail.com>

On Tue, Nov 9, 2021 at 11:17 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Tue, Nov 9, 2021 at 12:18 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> > Ideally we should only use linux/gpio/consumer.h, which is required for
> > gpiod_set_debounce(). of_gpio.h is still needed for of_get_named_gpio()
> > and should be taken out once we change this to gpiod_get(), while
> > linux/gpio.h is still needed for gpio_is_valid()/gpio_get_value() and should
> > be removed when those are changed to the gpiod_ versions.
> >
> > We could do an intermediate patch that converts one half of the
> > interface, something like
>
> When I convert stuff I try to go all the way when I can. It can
> be a bit daring if no one is there to test changes.
>
> The patch looks good though apart from:
>
> > -               ts->gpio_pendown = pdata->gpio_pendown;
> > +               ts->gpio_pendown = gpio_to_desc(pdata->gpio_pendown);
>
> I usually even go into the defined platform data and try to convert
> the boardfile to use a descriptor table so this is never needed.
> (But, more work.)

Yes, I noticed. I had done some conversions for pxa this way, I should
look in my tree if I should resend those.

My hope would be that by making the steps smaller, it's easier to find
people that are willing and able to help out. From looking at it so far,
I would partition the problem something like:

a) Remove the (now) trivial wrappers around gpiod_*() functions
by using open-coded gpio_to_desc() calls everywhere. This doesn't
improve the code, but it can be trivially scripted and it should help
by making it less practical to put new users in.

b) one driver/subsystem at a time, replace all calls to
{devm_,}gpio_{free,request{,_one}} with a new
struct gpio_desc *gpiod_get_legacy(struct device *dev, int gpio, enum
gpiod_flags flags);
This takes the conversion only half-way, but is much more manageable
for a random contributor or reviewer, and it undoes the ugly bits
added in step a), making it a clear improvement.

c) convert the boardfile/platform_data/of_get_named_gpio side along with
the corresponding s/gpiod_get_legacy/gpiod_get/, which is now a fairly simple
change on the driver side, while the platform side can be reviewed by
the platform
maintainers.

> Examples:
> git log -p --author=Walleij arch/arm/mach-pxa/
>
> > -       pdata->gpio_pendown = of_get_named_gpio(dev->of_node,
> > "pendown-gpio", 0);
> > +       ts->gpio_pendown = gpiod_get(dev, "pendown-gpio", GPIOD_IN);
>
> Needs to be just gpiod_get(dev, "pendown", GPIOD_IN); the new
> API tries the "-gpio[s]" suffixes when going into the device tree.

Ok, got it.

        Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	 "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 5/8] gpiolib: shrink further
Date: Wed, 10 Nov 2021 13:39:25 +0100	[thread overview]
Message-ID: <CAK8P3a2jroy_0ad7BYb59s5Dz7kOZBRbL4mqj5oJ6M-W=v_RFw@mail.gmail.com> (raw)
In-Reply-To: <CACRpkdacYt4kS2QS4-W83ZtWWtTaAETeH8Buer2wOXBOoBK=qA@mail.gmail.com>

On Tue, Nov 9, 2021 at 11:17 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Tue, Nov 9, 2021 at 12:18 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> > Ideally we should only use linux/gpio/consumer.h, which is required for
> > gpiod_set_debounce(). of_gpio.h is still needed for of_get_named_gpio()
> > and should be taken out once we change this to gpiod_get(), while
> > linux/gpio.h is still needed for gpio_is_valid()/gpio_get_value() and should
> > be removed when those are changed to the gpiod_ versions.
> >
> > We could do an intermediate patch that converts one half of the
> > interface, something like
>
> When I convert stuff I try to go all the way when I can. It can
> be a bit daring if no one is there to test changes.
>
> The patch looks good though apart from:
>
> > -               ts->gpio_pendown = pdata->gpio_pendown;
> > +               ts->gpio_pendown = gpio_to_desc(pdata->gpio_pendown);
>
> I usually even go into the defined platform data and try to convert
> the boardfile to use a descriptor table so this is never needed.
> (But, more work.)

Yes, I noticed. I had done some conversions for pxa this way, I should
look in my tree if I should resend those.

My hope would be that by making the steps smaller, it's easier to find
people that are willing and able to help out. From looking at it so far,
I would partition the problem something like:

a) Remove the (now) trivial wrappers around gpiod_*() functions
by using open-coded gpio_to_desc() calls everywhere. This doesn't
improve the code, but it can be trivially scripted and it should help
by making it less practical to put new users in.

b) one driver/subsystem at a time, replace all calls to
{devm_,}gpio_{free,request{,_one}} with a new
struct gpio_desc *gpiod_get_legacy(struct device *dev, int gpio, enum
gpiod_flags flags);
This takes the conversion only half-way, but is much more manageable
for a random contributor or reviewer, and it undoes the ugly bits
added in step a), making it a clear improvement.

c) convert the boardfile/platform_data/of_get_named_gpio side along with
the corresponding s/gpiod_get_legacy/gpiod_get/, which is now a fairly simple
change on the driver side, while the platform side can be reviewed by
the platform
maintainers.

> Examples:
> git log -p --author=Walleij arch/arm/mach-pxa/
>
> > -       pdata->gpio_pendown = of_get_named_gpio(dev->of_node,
> > "pendown-gpio", 0);
> > +       ts->gpio_pendown = gpiod_get(dev, "pendown-gpio", GPIOD_IN);
>
> Needs to be just gpiod_get(dev, "pendown", GPIOD_IN); the new
> API tries the "-gpio[s]" suffixes when going into the device tree.

Ok, got it.

        Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-11-10 12:39 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 10:01 [PATCH v2 0/8] gpiolib header cleanup Arnd Bergmann
2021-11-09 10:01 ` Arnd Bergmann
2021-11-09 10:02 ` [PATCH v2 1/8] gpiolib: remove irq_to_gpio() definition Arnd Bergmann
2021-11-09 10:02   ` Arnd Bergmann
2021-11-09 10:02 ` [PATCH v2 2/8] gpiolib: remove empty asm/gpio.h files Arnd Bergmann
2021-11-09 10:02   ` Arnd Bergmann
2021-11-09 10:02 ` [PATCH v2 3/8] gpiolib: coldfire: remove custom asm/gpio.h Arnd Bergmann
2021-11-09 10:02   ` Arnd Bergmann
2021-11-09 10:02 ` [PATCH v2 4/8] gpiolib: remove asm-generic/gpio.h Arnd Bergmann
2021-11-09 10:02   ` Arnd Bergmann
2021-11-09 10:19   ` Andy Shevchenko
2021-11-09 10:19     ` Andy Shevchenko
2021-11-09 10:02 ` [PATCH v2 5/8] gpiolib: shrink further Arnd Bergmann
2021-11-09 10:02   ` Arnd Bergmann
2021-11-09 10:24   ` Andy Shevchenko
2021-11-09 10:24     ` Andy Shevchenko
2021-11-09 11:18     ` Arnd Bergmann
2021-11-09 11:18       ` Arnd Bergmann
2021-11-09 22:17       ` Linus Walleij
2021-11-09 22:17         ` Linus Walleij
2021-11-10 12:39         ` Arnd Bergmann [this message]
2021-11-10 12:39           ` Arnd Bergmann
2021-11-09 10:02 ` [PATCH v2 6/8] gpiolib: remove legacy gpio_export Arnd Bergmann
2021-11-09 10:02   ` Arnd Bergmann
2021-11-09 10:30   ` Andy Shevchenko
2021-11-09 10:30     ` Andy Shevchenko
2021-11-09 10:50     ` Arnd Bergmann
2021-11-09 10:50       ` Arnd Bergmann
2021-11-09 20:42       ` Linus Walleij
2021-11-09 20:42         ` Linus Walleij
2021-11-09 22:46         ` Arnd Bergmann
2021-11-09 22:46           ` Arnd Bergmann
2021-11-10  0:03           ` Linus Walleij
2021-11-10  0:03             ` Linus Walleij
2021-11-09 20:33     ` Linus Walleij
2021-11-09 20:33       ` Linus Walleij
2021-11-09 10:02 ` [PATCH v2 7/8] gpiolib: remove gpio_to_chip Arnd Bergmann
2021-11-09 10:02   ` Arnd Bergmann
2021-11-09 10:32   ` Andy Shevchenko
2021-11-09 10:32     ` Andy Shevchenko
2021-11-09 10:54     ` Arnd Bergmann
2021-11-09 10:54       ` Arnd Bergmann
2021-11-09 10:02 ` [PATCH v2 8/8] gpiolib: split linux/gpio/driver.h out of linux/gpio.h Arnd Bergmann
2021-11-09 10:02   ` Arnd Bergmann
2021-11-09 10:34   ` Andy Shevchenko
2021-11-09 10:34     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK8P3a2jroy_0ad7BYb59s5Dz7kOZBRbL4mqj5oJ6M-W=v_RFw@mail.gmail.com' \
    --to=arnd@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=brgl@bgdev.pl \
    --cc=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.