From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables at once
Date: Tue, 25 Jul 2017 13:58:00 -0700 [thread overview]
Message-ID: <20170725205800.GA25245@dtor-ws> (raw)
When converting legacy board to use gpiod API() there migt be several
lookup tables in board file, let's provide a way to register them all at
once.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/gpio/gpiolib.c | 18 ++++++++++++++++++
include/linux/gpio/machine.h | 2 ++
2 files changed, 20 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a42a1eea5714..f8f4f8b61db8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3010,6 +3010,24 @@ 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 table of consumers to register
+ * @n: number of tables in the list
+ */
+void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables,
+ unsigned int 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..6f7ddce88fb8 100644
--- a/include/linux/gpio/machine.h
+++ b/include/linux/gpio/machine.h
@@ -58,6 +58,8 @@ 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,
+ unsigned int n);
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
#else
static inline
--
2.14.0.rc0.400.g1c36432dff-goog
--
Dmitry
next reply other threads:[~2017-07-25 20:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-25 20:58 Dmitry Torokhov [this message]
2017-07-26 10:21 ` [PATCH] gpio: add gpio_add_lookup_tables() to add several tables at once Andy Shevchenko
2017-08-01 19:24 ` Dmitry Torokhov
2017-08-02 12:06 ` Andy Shevchenko
2017-08-07 12:18 ` Linus Walleij
2017-08-02 8:38 ` Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170725205800.GA25245@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.