From: Michael Walle <michael@walle.cc>
To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Mark Brown <broonie@kernel.org>,
Pierre-Louis Bossart <pierre-louis.bossart@intel.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Michael Walle <michael@walle.cc>
Subject: [PATCH v6 1/3] gpiolib: Introduce gpiochip_irqchip_add_domain()
Date: Thu, 28 May 2020 16:58:43 +0200 [thread overview]
Message-ID: <20200528145845.31436-2-michael@walle.cc> (raw)
In-Reply-To: <20200528145845.31436-1-michael@walle.cc>
The function connects an IRQ domain to a gpiochip and reuses
gpiochip_to_irq() which is provided by gpiolib.
gpiochip_irqchip_* and regmap_irq partially provide the same
functionality. This function will help to connect just the
minimal functionality of the gpiochip_irqchip which is needed to
work together with regmap-irq.
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/gpio/gpiolib.c | 20 ++++++++++++++++++++
include/linux/gpio/driver.h | 3 +++
2 files changed, 23 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index eaa0e209188d..d07f763c9c0b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2756,6 +2756,26 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gc,
}
EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_key);
+/**
+ * gpiochip_irqchip_add_domain() - adds an irqdomain to a gpiochip
+ * @gc: the gpiochip to add the irqchip to
+ * @domain: the irqdomain to add to the gpiochip
+ *
+ * This function adds an IRQ domain to the gpiochip.
+ */
+int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
+ struct irq_domain *domain)
+{
+ if (!domain)
+ return -EINVAL;
+
+ gc->to_irq = gpiochip_to_irq;
+ gc->irq.domain = domain;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_domain);
+
#else /* CONFIG_GPIOLIB_IRQCHIP */
static inline int gpiochip_add_irqchip(struct gpio_chip *gc,
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 8c41ae41b6bb..ee30065b6f61 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -599,6 +599,9 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gc,
bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gc,
unsigned int offset);
+int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
+ struct irq_domain *domain);
+
#ifdef CONFIG_LOCKDEP
/*
--
2.20.1
next prev parent reply other threads:[~2020-05-28 14:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-28 14:58 [PATCH v6 0/3] gpio: generic regmap implementation Michael Walle
2020-05-28 14:58 ` Michael Walle [this message]
2020-05-28 14:58 ` [PATCH v6 2/3] gpio: add a reusable generic gpio_chip using regmap Michael Walle
[not found] ` <adb4eba6-c6c4-a403-dead-1951050eec26@linux.intel.com>
2020-05-28 17:03 ` Michael Walle
2020-05-28 18:15 ` Pierre-Louis Bossart
2020-05-28 14:58 ` [PATCH v6 3/3] MAINTAINERS: Add gpio regmap section Michael Walle
2020-05-28 15:11 ` [PATCH v6 0/3] gpio: generic regmap implementation Andy Shevchenko
2020-06-03 8:50 ` Linus Walleij
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=20200528145845.31436-2-michael@walle.cc \
--to=michael@walle.cc \
--cc=andy.shevchenko@gmail.com \
--cc=bgolaszewski@baylibre.com \
--cc=broonie@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).