From: Markus Pargmann <mpa@pengutronix.de>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
Alexandre Courbot <acourbot@nvidia.com>,
Johan Hovold <johan@kernel.org>,
Michael Welling <mwelling@ieee.org>,
Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>,
Grant Likely <grant.likely@linaro.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 4/4] gpio: Add parsing of DT GPIO line-names
Date: Wed, 24 Feb 2016 08:03:09 +0100 [thread overview]
Message-ID: <4005432.tnZmp1QKdV@adelgunde> (raw)
In-Reply-To: <CACRpkdb3gEZt5-25mi5pPvDePzLzNHfFRpjKMOW_-WfcBBLtUQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3857 bytes --]
On Tuesday, February 23, 2016 02:36:42 PM Linus Walleij wrote:
> On Tue, Feb 23, 2016 at 8:54 AM, Markus Pargmann <mpa@pengutronix.de> wrote:
>
> > This patch reuses the DT bindings that are already in place for the
> > gpio-hogging mechanism. These bindings define line-name properties for
> > GPIOs inside the gpio-chip device node.
> >
> > of_parse_own_gpio() now sets the gpio descriptor name using the newly
> > introduced gpiod_set_name(). It checks for name collisions within a GPIO
> > chip to avoid GPIOs with the same name that are exported over the same
> > GPIO character device.
> >
> > The GPIO flags that describe the GPIO state are not required anymore in
> > general but are checked if the gpio-hog property was found.
> >
> > This can be used to use the line names from the schematic. Example of lsgpio on
> > a modified i.MX6s Riotboard:
> >
> > GPIO chip: gpiochip0, "209c000.gpio", 32 GPIO lines
> > line 0: unnamed unlabeled
> > line 1: unnamed unlabeled
> > line 2: SD2_WP "wp" [kernel output open-drain]
> > line 3: GPIO_3_CLK unlabeled
> > line 4: SD2_CD "cd" [kernel output open-drain]
> > ...
> >
> > The modified DT:
> > &gpio1 {
> > sd2_wp {
> > gpios = <2 0>;
> > line-name = "SD2_WP";
> > };
> >
> > gpio_3_clk {
> > gpios = <3 0>;
> > line-name = "GPIO_3_CLK";
> > };
> >
> > sd2_cd {
> > gpios = <4 0>;
> > line-name = "SD2_CD";
> > };
> > };
> >
> > Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
>
> NICE! And this is what I want too.
>
> We need to remove some rough edges:
>
> > +static struct gpio_desc *gpiodev_find_gpiod_by_name(struct gpio_device *gdev,
> > + const char *name)
> > +{
> > + int i;
> > +
> > + for (i = 0; i != gdev->ngpio; ++i) {
> > + struct gpio_desc *desc = &gdev->descs[i];
> > +
> > + if (desc->name && !strcmp(desc->name, name))
> > + return desc;
> > + }
> > +
> > + return NULL;
> > +}
>
> We already have gpio_name_to_desc() which does something
> similar but across all chips.
>
> Can we break out one gpiodev_name_to_desc() like
> yours, and refactor gpio_name_to_desc() to just call
> that for each chip?
Yes, that sounds good.
Thanks,
Markus
>
> > +/**
> > + * gpid_set_name() - sets the name of a gpio descriptor
>
> Missing "o" in gpid_
>
> > + * @desc: the gpio descriptor
> > + * @name: the name pointer that is assigned. It is internally not copied.
> > + *
> > + * This function sets a new name for the GPIO. It checks for collisions with
> > + * other GPIOs with the same name within the gpio chip. It returns 0 on success
> > + * or -EEXIST if the name is already used within the GPIO chip.
> > + */
> > +int gpiod_set_name(struct gpio_desc *desc, const char *name)
> > +{
> > + struct gpio_desc *coll = gpiodev_find_gpiod_by_name(desc->gdev, name);
> > +
> > + if (coll)
> > + return -EEXIST;
> > +
> > + desc->name = name;
> > +
> > + return 0;
> > +}
>
> Otherwise I'm OK with this.
>
> 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: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-02-24 7:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-23 7:54 [PATCH 1/4] tools: gpio: Small updates for output format Markus Pargmann
2016-02-23 7:54 ` [PATCH 2/4] tools: gpio: Add necessary include paths Markus Pargmann
2016-02-23 13:26 ` Linus Walleij
2016-02-24 6:39 ` Markus Pargmann
2016-02-23 7:54 ` [PATCH 3/4] gpio: dt-bindings: Declare gpio-hog optional for GPIO subnodes Markus Pargmann
2016-02-23 13:37 ` Linus Walleij
2016-02-23 23:25 ` Rob Herring
2016-02-24 7:01 ` Markus Pargmann
2016-03-02 15:41 ` Rob Herring
2016-03-09 4:07 ` Linus Walleij
2016-03-09 3:53 ` Linus Walleij
2016-03-09 4:27 ` Rob Herring
2016-03-09 5:56 ` Linus Walleij
2016-02-23 7:54 ` [PATCH 4/4] gpio: Add parsing of DT GPIO line-names Markus Pargmann
2016-02-23 13:36 ` Linus Walleij
2016-02-24 7:03 ` Markus Pargmann [this message]
2016-03-15 8:41 ` Linus Walleij
2016-02-23 13:21 ` [PATCH 1/4] tools: gpio: Small updates for output format Linus Walleij
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=4005432.tnZmp1QKdV@adelgunde \
--to=mpa@pengutronix.de \
--cc=acourbot@nvidia.com \
--cc=bamvor.zhangjian@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=johan@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mwelling@ieee.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