Skip to content

Commit

Permalink
gpio: add gpio_add_lookup_tables() to add several tables at once
Browse files Browse the repository at this point in the history
When converting legacy board to use gpiod API() there might be several
lookup tables in board file, let's provide a way to register them all at
once.

Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Mika Westerberg <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
dtor authored and linusw committed Aug 23, 2017
1 parent 33f5dc8 commit 3946d18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3010,6 +3010,23 @@ void gpiod_set_raw_array_value_cansleep(unsigned int array_size,
}
EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value_cansleep);

/**
* gpiod_add_lookup_tables() - register GPIO device consumers
* @tables: list of tables of consumers to register
* @n: number of tables in the list
*/
void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n)
{
unsigned int i;

mutex_lock(&gpio_lookup_lock);

for (i = 0; i < n; i++)
list_add_tail(&tables[i]->list, &gpio_lookup_list);

mutex_unlock(&gpio_lookup_lock);
}

/**
* gpiod_set_array_value_cansleep() - assign values to an array of GPIOs
* @array_size: number of elements in the descriptor / value arrays
Expand Down
3 changes: 3 additions & 0 deletions include/linux/gpio/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ struct gpiod_lookup_table {

#ifdef CONFIG_GPIOLIB
void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n);
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
#else
static inline
void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}
static inline
void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {}
static inline
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}
#endif

Expand Down

0 comments on commit 3946d18

Please sign in to comment.