lkml.org 
[lkml]   [2013]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] gpio: better lookup method for platform GPIOs
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?

> And the table can be added by the board code as follows:
>
> - gpiod_add_table(gpios_table, ARRAY_SIZE(gpios_table));
> + gpiod_add_lookup_table(&gpios_table);

Remove "&" from the above.

Thanks,

--
heikki


\
 
 \ /
  Last update: 2013-11-29 13:21    [W:1.168 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site