lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAVeFu+LLR-EwiRskE_VBQwPrnXAdt-ahfcH08mOXsFuStFMJg@mail.gmail.com>
Date:	Mon, 2 Dec 2013 21:30:42 +0900
From:	Alexandre Courbot <gnurou@...il.com>
To:	Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc:	Alex Courbot <acourbot@...dia.com>,
	Linus Walleij <linus.walleij@...aro.org>,
	Rhyland Klein <rklein@...dia.com>,
	Mika Westerberg <mika.westerberg@...ux.intel.com>,
	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpio: better lookup method for platform GPIOs

On Mon, Dec 2, 2013 at 8:11 PM, Heikki Krogerus
<heikki.krogerus@...ux.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!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ