Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1711833 > unrolled thread

[PATCH v2] gpio: add gpio_add_lookup_tables() to add several tables at once

Started byDmitry Torokhov <dmitry.torokhov@gmail.com>
First post2017-08-15 07:10 +0200
Last post2017-08-23 09:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] gpio: add gpio_add_lookup_tables() to add several tables  at once Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-08-15 07:10 +0200
    Re: [PATCH v2] gpio: add gpio_add_lookup_tables() to add several  tables at once Linus Walleij <linus.walleij@linaro.org> - 2017-08-23 09:20 +0200

#1711833 — [PATCH v2] gpio: add gpio_add_lookup_tables() to add several tables at once

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-08-15 07:10 +0200
Subject[PATCH v2] gpio: add gpio_add_lookup_tables() to add several tables at once
Message-ID<ueCh3-5tW-5@gated-at.bofh.it>
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 <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

V2:
- added the !CONFIG_GPIOLIB stub (Andy)
- changed size from unsigned int to size_t at Mika's suggestion
- added Reviewed-bys.

 drivers/gpio/gpiolib.c       | 17 +++++++++++++++++
 include/linux/gpio/machine.h |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a42a1eea5714..667289ca4913 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3010,6 +3010,23 @@ void gpiod_add_lookup_table(struct gpiod_lookup_table *table)
 	mutex_unlock(&gpio_lookup_lock);
 }
 
+/**
+ * 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_remove_lookup_table() - unregister GPIO device consumers
  * @table: table of consumers to unregister
diff --git a/include/linux/gpio/machine.h b/include/linux/gpio/machine.h
index f738d50cc17d..ec80fa7c0c7d 100644
--- a/include/linux/gpio/machine.h
+++ b/include/linux/gpio/machine.h
@@ -58,11 +58,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
 
-- 
2.14.0.434.g98096fd7a8-goog


-- 
Dmitry

[toc] | [next] | [standalone]


#1718096 — Re: [PATCH v2] gpio: add gpio_add_lookup_tables() to add several tables at once

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-08-23 09:20 +0200
SubjectRe: [PATCH v2] gpio: add gpio_add_lookup_tables() to add several tables at once
Message-ID<uhy7g-5VC-21@gated-at.bofh.it>
In reply to#1711833
On Tue, Aug 15, 2017 at 6:59 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> 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 <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>
> V2:
> - added the !CONFIG_GPIOLIB stub (Andy)
> - changed size from unsigned int to size_t at Mika's suggestion
> - added Reviewed-bys.

Patch applied!

Usually I don't like adding APIs with no users, but you have
a good track record so I believe you are going to put this to
good use in coming merge windows.

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web