Re: [PATCH 2/2] x86: pcengines apuv2 gpio/leds/keys platform driver

From: Linus Walleij
Date: Wed Feb 13 2019 - 04:35:29 EST


On Mon, Feb 11, 2019 at 11:39 AM Enrico Weigelt, metux IT consult
<lkml@xxxxxxxxx> wrote:

> struct gpiod_lookup_table gpios_led_table[] = {
> .dev_id = "leds-gpio.0",
> .table = {
> GPIO_LOOKUP_IDX("gpio.0", 0, "led", 0, GPIO_ACTIVE_LOW),
> GPIO_LOOKUP_IDX("gpio.0", 1, "led", 1, GPIO_ACTIVE_LOW),
> GPIO_LOOKUP_IDX("gpio.0", 2, "led", 2, GPIO_ACTIVE_LOW),
> }
> };
>
> But unsure now to determine the correct names for dev_id (the
> leds-gpio instance ?) and the gpio chip. In the example, these
> seem to be autogenerated - how can I retrieve them from my
> actual devices ?

It is a bit tricky.

For the dev_id you need to be aware of the following from
<linux/platform_device.h>:
#define PLATFORM_DEVID_NONE (-1)
#define PLATFORM_DEVID_AUTO (-2)

If the platform device has .id set to -1 it will be just "leds-gpio",
if it is -2 it will be whatever, take a chance on .0 or ideally fix
it up. Any positive number like .id = 4 becomes "leds-gpio.4".

So figure out the .id field on the platform device.

Yours,
Linus Walleij