gpiolib: Add support for GPIO lookup by line name
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 11 May 2020 14:52:54 +0000 (16:52 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 18 May 2020 08:12:42 +0000 (10:12 +0200)
commit4c033b549912bc301c5e2adfb7b6ca007c11bf31
tree82a28f20edfb2d106fcb6062bb8114e27a9d5416
parent7b67b836625d9b8350aaec7ecd8347b0336f3f92
gpiolib: Add support for GPIO lookup by line name

Currently a GPIO lookup table can only refer to a specific GPIO by a
tuple, consisting of a GPIO controller label and a GPIO offset inside
the controller.

However, a GPIO may also carry a line name, defined by DT or ACPI.
If present, the line name is the most use-centric way to refer to a
GPIO.  Hence add support for looking up GPIOs by line name.
Note that there is no guarantee that GPIO line names are globally
unique, so this will use the first match found.

Implement this by reusing the existing gpiod_lookup infrastructure.
Rename gpiod_lookup.chip_label to gpiod_lookup.key, to make it clear
that this field can have two meanings, and update the kerneldoc and
GPIO_LOOKUP*() macros.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Reviewed-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Link: https://lore.kernel.org/r/20200511145257.22970-4-geert+renesas@glider.be
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Documentation/driver-api/gpio/board.rst
drivers/gpio/gpiolib.c
include/linux/gpio/machine.h