[v3,3/6] gpio: add irq domain activate/deactivate functions

Message ID 20190110011258.17227-4-masneyb@onstation.org
State New
Headers show
Series
  • qcom: spmi: add support for hierarchical IRQ chip
Related show

Commit Message

Brian Masney Jan. 10, 2019, 1:12 a.m.
This adds the two new functions gpiochip_irq_domain_activate and
gpiochip_irq_domain_deactivate that can be used as the activate and
deactivate functions in the struct irq_domain_ops. This is for
situations where only gpiochip_{lock,unlock}_as_irq needs to be called.
SPMI and SSBI GPIO are two users that will initially use these
functions.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
Stephen: Reply if you want a Suggested-by tag for this.

 drivers/gpio/gpiolib.c      | 37 +++++++++++++++++++++++++++++++++++++
 include/linux/gpio/driver.h |  5 +++++
 2 files changed, 42 insertions(+)

Comments

Stephen Boyd Jan. 11, 2019, 10:05 p.m. | #1
Quoting Brian Masney (2019-01-09 17:12:55)
> This adds the two new functions gpiochip_irq_domain_activate and
> gpiochip_irq_domain_deactivate that can be used as the activate and
> deactivate functions in the struct irq_domain_ops. This is for
> situations where only gpiochip_{lock,unlock}_as_irq needs to be called.
> SPMI and SSBI GPIO are two users that will initially use these
> functions.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
> ---
> Stephen: Reply if you want a Suggested-by tag for this.

Sure. Add it please.

Suggested-by: Stephen Boyd <sboyd@kernel.org>

Minor question but otherwise

Reviewed-by: Stephen Boyd <sboyd@kernel.org>

> +/**
> + * gpiochip_irq_domain_deactivate() - Unlock a GPIO used as an IRQ
> + * @domain: The IRQ domain used by this IRQ chip
> + * @data: Outermost irq_data associated with the IRQ
> + *
> + * This function is a wrapper that will call &gpiochip_unlock_as_irq and is to

Is this kernel-doc notation to refer to functions and structures with
ampersand only? According to the docs[1] we should put () after
functions and '&struct' before structures.

> + * be used as the deactivate function for the struct &irq_domain_ops. The
> + * host_data for the IRQ domain must be the struct &gpiochip.
> + */
> +void gpiochip_irq_domain_deactivate(struct irq_domain *domain,
> +                                   struct irq_data *data)
> +{
> +       struct gpio_chip *chip = domain->host_data;
> +

[1] https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html?highlight=cross%20references#highlights-and-cross-references

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 1651d7f0a303..1589f34d5c9b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1775,6 +1775,43 @@  static const struct irq_domain_ops gpiochip_domain_ops = {
 	.xlate	= irq_domain_xlate_twocell,
 };
 
+/**
+ * gpiochip_irq_domain_activate() - Lock a GPIO to be used as an IRQ
+ * @domain: The IRQ domain used by this IRQ chip
+ * @data: Outermost irq_data associated with the IRQ
+ * @reserve: If set, only reserve an interrupt vector instead of assigning one
+ *
+ * This function is a wrapper that calls &gpiochip_lock_as_irq and is to be
+ * used as the activate function for the struct &irq_domain_ops. The host_data
+ * for the IRQ domain must be the struct &gpiochip.
+ */
+int gpiochip_irq_domain_activate(struct irq_domain *domain,
+				 struct irq_data *data, bool reserve)
+{
+	struct gpio_chip *chip = domain->host_data;
+
+	return gpiochip_lock_as_irq(chip, data->hwirq);
+}
+EXPORT_SYMBOL_GPL(gpiochip_irq_domain_activate);
+
+/**
+ * gpiochip_irq_domain_deactivate() - Unlock a GPIO used as an IRQ
+ * @domain: The IRQ domain used by this IRQ chip
+ * @data: Outermost irq_data associated with the IRQ
+ *
+ * This function is a wrapper that will call &gpiochip_unlock_as_irq and is to
+ * be used as the deactivate function for the struct &irq_domain_ops. The
+ * host_data for the IRQ domain must be the struct &gpiochip.
+ */
+void gpiochip_irq_domain_deactivate(struct irq_domain *domain,
+				    struct irq_data *data)
+{
+	struct gpio_chip *chip = domain->host_data;
+
+	return gpiochip_unlock_as_irq(chip, data->hwirq);
+}
+EXPORT_SYMBOL_GPL(gpiochip_irq_domain_deactivate);
+
 static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset)
 {
 	if (!gpiochip_irqchip_irq_valid(chip, offset))
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 07cddbf45186..01497910f023 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -472,6 +472,11 @@  int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
 		     irq_hw_number_t hwirq);
 void gpiochip_irq_unmap(struct irq_domain *d, unsigned int irq);
 
+int gpiochip_irq_domain_activate(struct irq_domain *domain,
+				 struct irq_data *data, bool reserve);
+void gpiochip_irq_domain_deactivate(struct irq_domain *domain,
+				    struct irq_data *data);
+
 void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip,
 		struct irq_chip *irqchip,
 		unsigned int parent_irq,