That said, if the Convention are supported on their platform, drivers should
Use it when possible. Platforms must declare GENERIC_GPIO support in their
Kconfig (Boolean True), and provide an <asm/gpio.h> file. Drivers that can ' t
Work without standard GPIO calls should has Kconfig entries which depend
On Generic_gpio. The GPIO calls is available, either as "real code" or as
Optimized-away stubs, when drivers use the Include file:
#include <linux/gpio.h>
Identifying GPIOs
-----------------
GPIOs is identified by unsigned integers in the range 0..max_int.
Reserves "negative" numbers for other purposes like marking signals as
"Not available on this board", or indicating faults. Code that doesn ' t
Touch the underlying hardware treats these integers as opaque cookies.
If you want to initialize a structure with the invalid GPIO number, use
Some negative number (perhaps "-einval"); That'll never be valid. To
Test if such number from such a structure could reference a GPIO, you
May use this predicate:
int gpio_is_valid (int number);
A number that's not valid'll be rejected by calls which request
or free GPIOs (see below). Other numbers may also is rejected; For
Example, a number might is valid but temporarily unused on a given board.
Linux GPIO Interfaces