linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Courbot <gnurou@gmail.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Alex Courbot <acourbot@nvidia.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Rhyland Klein <rklein@nvidia.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpio: better lookup method for platform GPIOs
Date: Mon, 2 Dec 2013 21:30:42 +0900	[thread overview]
Message-ID: <CAAVeFu+LLR-EwiRskE_VBQwPrnXAdt-ahfcH08mOXsFuStFMJg@mail.gmail.com> (raw)
In-Reply-To: <20131202111124.GG3942@xps8300>

On Mon, Dec 2, 2013 at 8:11 PM, Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
> Hi,
>
> On Mon, Dec 02, 2013 at 07:33:35PM +0900, Alex Courbot wrote:
>> On 11/29/2013 08:57 PM, Heikki Krogerus wrote:
>> >Hi,
>> >
>> >On Thu, Nov 28, 2013 at 05:46:28PM +0900, Alexandre Courbot wrote:
>> >>@@ -88,16 +89,20 @@ Note that GPIO_LOOKUP() is just a shortcut to GPIO_LOOKUP_IDX() where idx = 0.
>> >>
>> >>  A lookup table can then be defined as follows:
>> >>
>> >>-   struct gpiod_lookup gpios_table[] = {
>> >>-   GPIO_LOOKUP_IDX("gpio.0", 15, "foo.0", "led", 0, GPIO_ACTIVE_HIGH),
>> >>-   GPIO_LOOKUP_IDX("gpio.0", 16, "foo.0", "led", 1, GPIO_ACTIVE_HIGH),
>> >>-   GPIO_LOOKUP_IDX("gpio.0", 17, "foo.0", "led", 2, GPIO_ACTIVE_HIGH),
>> >>-   GPIO_LOOKUP("gpio.0", 1, "foo.0", "power", GPIO_ACTIVE_LOW),
>> >>-   };
>> >>+struct gpiod_lookup_table gpios_table = {
>> >>+   .dev_id = "foo.0",
>> >>+   .size = 4,
>> >>+   .table = {
>> >>+   GPIO_LOOKUP_IDX("gpio.0", 15, "led", 0, GPIO_ACTIVE_HIGH),
>> >>+   GPIO_LOOKUP_IDX("gpio.0", 16, "led", 1, GPIO_ACTIVE_HIGH),
>> >>+   GPIO_LOOKUP_IDX("gpio.0", 17, "led", 2, GPIO_ACTIVE_HIGH),
>> >>+   GPIO_LOOKUP("gpio.0", 1, "power", GPIO_ACTIVE_LOW),
>> >>+   },
>> >>+};
>> >
>> >Instead of using the size variable, wouldn't it be more clear to
>> >expect the array to be null terminated?
>>
>> This is a zero-length array, its entries are not pointers but
>> flattened lookup entries. Thus you cannot simply null-terminate it.
>> It would be possible to use { NULL } as a terminator, but this would
>> expand into a whole gpiod_lookup and is not very pleasant
>> esthetically-speaking. So I think the size member is maybe better
>> suited here.
>
> The gpio_loopup_table would look like this, which IMO is more nicer
> looking compared to the extra size variable:
>
> struct gpiod_lookup_table gpios_table = {
>         .dev_id = "foo.0",
>         .table = {
>                 GPIO_LOOKUP_IDX("gpio.0", 15, "led", 0, GPIO_ACTIVE_HIGH),
>                 GPIO_LOOKUP_IDX("gpio.0", 16, "led", 1, GPIO_ACTIVE_HIGH),
>                 GPIO_LOOKUP_IDX("gpio.0", 17, "led", 2, GPIO_ACTIVE_HIGH),
>                 GPIO_LOOKUP("gpio.0", 1, "power", GPIO_ACTIVE_LOW),
>                 { },
>         },
> };
>
> That would also make it more straight forward to handle in gbiolib.c:
>
> struct gpiod_lookup *p;
> ...
> for (p = table->table; p->chip_label; p++) {
> ...

Ok, you're obviously right here. Will send a v3 tomorrow morning JST.

Thanks for the review!

  reply	other threads:[~2013-12-02 12:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-28  8:46 [PATCH] gpio: better lookup method for platform GPIOs Alexandre Courbot
2013-11-28 14:45 ` Linus Walleij
2013-11-28 15:42   ` Andy Shevchenko
2013-11-28 16:59   ` Mika Westerberg
2013-11-28 15:54 ` Andy Shevchenko
2013-11-29  6:17   ` Andy Shevchenko
2013-12-02 10:50   ` Alex Courbot
2013-11-29 11:57 ` Heikki Krogerus
2013-11-29 11:59   ` Heikki Krogerus
2013-12-02 10:33   ` Alex Courbot
2013-12-02 11:11     ` Heikki Krogerus
2013-12-02 12:30       ` Alexandre Courbot [this message]
2013-12-03  3:20         ` [PATCH v3] " Alexandre Courbot
2013-12-03 11:04           ` Heikki Krogerus
2013-12-03 12:12           ` Linus Walleij
2013-12-09 13:07           ` Linus Walleij
2013-12-02 11:01 ` [PATCH v2] " Alexandre Courbot
2013-12-02 11:49   ` Andy Shevchenko
2013-12-02 12:37     ` Alexandre Courbot

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=CAAVeFu+LLR-EwiRskE_VBQwPrnXAdt-ahfcH08mOXsFuStFMJg@mail.gmail.com \
    --to=gnurou@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rklein@nvidia.com \
    /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).