From: mpa@pengutronix.de (Markus Pargmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/3] gpiolib: Add GPIO initialization
Date: Thu, 24 Sep 2015 08:48:37 +0200 [thread overview]
Message-ID: <20150924064837.GT32203@pengutronix.de> (raw)
In-Reply-To: <CACRpkdZTN9_t=pUFQTWzaWoqhRBtn7XPEQjo6zUEMoJJBZmDzQ@mail.gmail.com>
Hi,
On Mon, Sep 21, 2015 at 04:42:09PM -0700, Linus Walleij wrote:
> On Sun, Aug 30, 2015 at 12:44 AM, Markus Pargmann <mpa@pengutronix.de> wrote:
>
> > This functions adds a way to initialize a GPIO without hogging it.
> >
> > Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
>
> (...)
>
> > -The GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechanism
> > -providing automatic GPIO request and configuration as part of the
> > -gpio-controller's driver probe function.
> > +The GPIO chip may contain GPIO definitions. These define properties for single
> > +GPIOs of this controller.
>
> Insert text like this:
>
> There are two types of GPIO definitions:
>
> - GPIO hogs are ...
>
> - GPIO initializers are ...
>
> This list form is easier to understand.
>
> > -Each GPIO hog definition is represented as a child node of the GPIO controller.
> > +GPIO hogging is a mechanism providing automatic GPIO request and configuration
> > +as part of the gpio-controller's driver probe function.
> > +
> > +GPIO initialization provides an automatic initialization to known save values.
> > +Instead of GPIO hogging the GPIO's value and direction can be modified by other
> > +users after it was initialized.
> > +
> > +Each GPIO definition is represented as a child node of the GPIO controller.
> > Required properties:
> > -- gpio-hog: A property specifying that this child node represent a GPIO hog.
> > - gpios: Store the GPIO information (id, flags, ...). Shall contain the
> > number of cells specified in its parent node (GPIO controller
> > node).
> > -Only one of the following properties scanned in the order shown below.
> > -This means that when multiple properties are present they will be searched
> > -in the order presented below and the first match is taken as the intended
> > -configuration.
> > +
> > +Optional properties:
> > +- line-name: The GPIO label name. If not present the node name is used.
> > + Only one of gpio-hog and gpio-initval may be specified.
>
> This is confusing. Instead write: "The two following options are
> mutually exclusive. One of them must be specified, but not both."
>
> > +- gpio-hog: A property specifying that this child node represent a GPIO hog.
> > +- gpio-initval: This GPIO should be initialized to the specified configuration.
>
> > + Only one of input, output-low and output-high may be specified:
>
> Insert "Of the following arguments, only one..." (etc)
Okay, thanks. Will change these.
>
> > - input: A property specifying to set the GPIO direction as input.
> > - output-low A property specifying to set the GPIO direction as output with
> > the value low.
> > - output-high A property specifying to set the GPIO direction as output with
> > the value high.
> >
> > -Optional properties:
> > -- line-name: The GPIO label name. If not present the node name is used.
> > -
> > Example of two SOC GPIO banks defined as gpio-controller nodes:
>
> (...)
> > --- a/drivers/gpio/gpiolib-of.c
> > +++ b/drivers/gpio/gpiolib-of.c
> > @@ -234,6 +234,15 @@ static void of_gpiochip_scan_gpios(struct gpio_chip *chip)
> >
> > if (gpiod_hog(desc, lflags, dflags))
> > continue;
> > + } else if (of_property_read_bool(np, "gpio-initval")) {
> > + if (!dflags) {
> > + dev_warn(chip->dev, "GPIO line %d (%s): no initialization state specified, bailing out\n",
> > + desc_to_gpio(desc), np->name);
> > + continue;
> > + }
> > +
> > + if (gpiod_initialize(desc, lflags, dflags))
> > + continue;
>
> We usually do not mix implementations and bindings but it's OK with me.
>
> > }
>
> You need a terminating else {} - clause to warn if neither of gpio-hog
> or gpio-initval is specified.
The idea was to have three cases:
1) Just give the gpio a name (desc->name). No hogging or initialization.
2) gpio-hog to initialize and acquire the GPIO for the whole time the
gpiochip is present.
2) gpio-initval to initialize the GPIO to a given value (as gpio-hog
does) but releasing the GPIO afterwards.
>
> > -int gpiod_hog(struct gpio_desc *desc, unsigned long lflags,
> > - enum gpiod_flags dflags)
> > +static int _gpiod_initialize(struct gpio_desc *desc, unsigned long lflags,
> > + enum gpiod_flags dflags)
>
> I don't like _underscore functions. Try to find a name that is descriptive
> and does not begin with underscore.
>
> What about just gpiod_init()?
Okay, will change.
>
> > if (status < 0) {
> > pr_err("setup of hog GPIO %s (chip %s, offset %d) failed\n",
> > - name, gpiod_to_chip(desc)->label, gpio_chip_hwgpio(desc));
> > + name, gpiod_to_chip(desc)->label,
> > + gpio_chip_hwgpio(desc));
>
> Looks like a random, unrelated code reshuffling. Don't do this.
Right, will remove that.
>
> 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 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150924/51c525a7/attachment-0001.sig>
next prev parent reply other threads:[~2015-09-24 6:48 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
2015-09-24 7:02 ` Markus Pargmann
2015-09-24 17:49 ` Linus Walleij
2015-09-27 14:32 ` Markus Pargmann
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 [this message]
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
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
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=20150924064837.GT32203@pengutronix.de \
--to=mpa@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.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).