October 2017
Intermediate to advanced
586 pages
14h 8m
English
You can use either gpiog_get() or gpiod_get_index() to allocate a GPIO descriptor:
struct gpio_desc *gpiod_get_index(struct device *dev,
const char *con_id,
unsigned int idx,
enum gpiod_flags flags)
struct gpio_desc *gpiod_get(struct device *dev,
const char *con_id,
enum gpiod_flags flags)
On error, these functions will return -ENOENT if no GPIO with the given function is assigned, or another error on which you can use the IS_ERR() macro. The first function returns the GPIO descriptor structure that corresponds to the GPIO at a given index, whereas the second function returns the GPIO at index 0 (useful for one-GPIO mapping). dev is the device to which the GPIO descriptor will belong. It is your device. con_id