From: Markus Pargmann <mpa-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: "Alexandre Courbot"
<gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"Arun Bharadwaj" <arun-EiDWdcs9+yZBDgjK7y7TUQ@public.gmane.org>,
"Uwe Kleine-König"
<u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
"Johan Hovold" <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Chris R" <chrisrfq-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Sascha Hauer" <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Subject: Re: [PATCH v2 1/3] gpio: Use __gpiod_request directly
Date: Sun, 27 Sep 2015 16:32:09 +0200 [thread overview]
Message-ID: <20150927143209.GE19121@pengutronix.de> (raw)
In-Reply-To: <CACRpkdaBxAhWKnJ3vsd+K6xMgaym7D9M0zTEMu_=fmiUNpxTEA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 3539 bytes --]
Hi,
On Thu, Sep 24, 2015 at 10:49:57AM -0700, Linus Walleij wrote:
> On Tue, Sep 22, 2015 at 9:25 PM, Alexandre Courbot <gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > On Sun, Aug 30, 2015 at 4:44 PM, Markus Pargmann <mpa-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> wrote:
> >> There is no reason to find out chip and hwnum to use to request a gpio
> >> and get another gpio descriptor. We already have the descriptor we want
> >> to use so we can directly use it.
> >>
> >> Signed-off-by: Markus Pargmann <mpa-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> >> ---
> >> drivers/gpio/gpiolib.c | 17 ++++++-----------
> >> 1 file changed, 6 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> >> index 79a0b41ce57b..872fdd3617c1 100644
> >> --- a/drivers/gpio/gpiolib.c
> >> +++ b/drivers/gpio/gpiolib.c
> >> @@ -2189,25 +2189,20 @@ EXPORT_SYMBOL_GPL(__gpiod_get_index_optional);
> >> int gpiod_hog(struct gpio_desc *desc, const char *name,
> >> unsigned long lflags, enum gpiod_flags dflags)
> >> {
> >> - struct gpio_chip *chip;
> >> - struct gpio_desc *local_desc;
> >> - int hwnum;
> >> int status;
> >>
> >> - chip = gpiod_to_chip(desc);
> >> - hwnum = gpio_chip_hwgpio(desc);
> >> -
> >> - local_desc = gpiochip_request_own_desc(chip, hwnum, name);
> >> - if (IS_ERR(local_desc)) {
> >> + status = __gpiod_request(desc, name);
> >> + if (status) {
> >> pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n",
> >> - name, chip->label, hwnum);
> >> - return PTR_ERR(local_desc);
> >> + name, gpiod_to_chip(desc)->label,
> >> + gpio_chip_hwgpio(desc));
> >> + return status;
> >> }
> >>
> >> status = gpiod_configure_flags(desc, name, lflags, dflags);
> >> if (status < 0) {
> >> pr_err("setup of hog GPIO %s (chip %s, offset %d) failed\n",
> >> - name, chip->label, hwnum);
> >> + name, gpiod_to_chip(desc)->label, gpio_chip_hwgpio(desc));
> >> gpiochip_free_own_desc(desc);
> >
> > Mmm I should have reviewed this patch earlier, but what bothers me a
> > bit is that it breaks the symetry that we had by calling
> > request_own_desc() and free_own_desc() in the failing case (as well as
> > in gpiochip_free_hogs). And in the end you still need to call
> > gpiod_to_chip() so I am not sure what the benefit is.
> >
> > Sure, the code is less verbose, but at the same time it has become
> > slightly harder to understand. Semantically speaking
> > "request_own_desc()" is exactly the action we want to convey.
> > __gpiod_request() is more ambiguous.
> >
> > Note that this is not a reject, I just wanted to stress that "less
> > code" is not necessarily the same as "easier to read".
>
> OK I dropped this patch for now.
>
> Markus can you live without this patch for 2/3 and 3/3?
Yes, that's fine. I will remove it and rebase the others.
Best Regards,
Markus
>
> Yours,
> Linus Walleij
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-09-27 14:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-30 7:44 [PATCH v2 0/3] gpiolib: Initializing GPIOs using DT property gpio-initval Markus Pargmann
2015-08-30 7:44 ` [PATCH v2 1/3] gpio: Use __gpiod_request directly Markus Pargmann
2015-09-21 21:41 ` Linus Walleij
2015-09-23 4:25 ` Alexandre Courbot
[not found] ` <CAAVeFuJPzjJ6td9UZ993sbfOyEOo=7WVu-Y2KnFgXewyt_8knA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-24 7:02 ` Markus Pargmann
2015-09-24 17:49 ` Linus Walleij
[not found] ` <CACRpkdaBxAhWKnJ3vsd+K6xMgaym7D9M0zTEMu_=fmiUNpxTEA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-27 14:32 ` Markus Pargmann [this message]
[not found] ` <1440920686-6892-1-git-send-email-mpa-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-08-30 7:44 ` [PATCH v2 2/3] gpiolib: gpiod_hog remove separate name argument Markus Pargmann
2015-09-21 23:28 ` Linus Walleij
2015-09-24 6:39 ` Markus Pargmann
2015-09-24 17:52 ` Linus Walleij
2015-09-27 14:34 ` Markus Pargmann
2015-08-30 7:44 ` [PATCH v2 3/3] gpiolib: Add GPIO initialization Markus Pargmann
2015-09-21 11:01 ` Markus Pargmann
2015-09-21 23:42 ` Linus Walleij
2015-09-24 6:48 ` Markus Pargmann
2017-02-07 11:09 ` Uwe Kleine-König
2017-02-07 13:30 ` Lothar Waßmann
2017-02-07 14:57 ` Uwe Kleine-König
[not found] ` <20170207110950.zy5pzo2hq6hrvmr5-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-05-06 20:32 ` Uwe Kleine-König
2017-05-07 7:30 ` Linus Walleij
2017-05-07 9:45 ` Uwe Kleine-König
2017-05-11 14:29 ` Linus Walleij
[not found] ` <CACRpkdZPwH3vPjdCgCjYW4Q5OvbE5O0RLJ4bV-QLR2nVLy4kAQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-11 20:18 ` Uwe Kleine-König
2017-05-07 10:22 ` Russell King - ARM Linux
2017-05-07 12:38 ` Uwe Kleine-König
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=20150927143209.GE19121@pengutronix.de \
--to=mpa-bicnvbalz9megne8c9+irq@public.gmane.org \
--cc=arun-EiDWdcs9+yZBDgjK7y7TUQ@public.gmane.org \
--cc=chrisrfq-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).