gpiolib: Introduce gpiochip_irqchip_add_domain()
authorMichael Walle <michael@walle.cc>
Thu, 28 May 2020 14:58:43 +0000 (16:58 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 3 Jun 2020 08:48:37 +0000 (10:48 +0200)
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>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200528145845.31436-2-michael@walle.cc
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c
include/linux/gpio/driver.h

index 1678606..0a54a75 100644 (file)
@@ -2779,6 +2779,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,
index c8bcaf3..c4f272a 100644 (file)
@@ -612,6 +612,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
 
 /*