Skip to content

Commit

Permalink
gpio: Move irqchip into struct gpio_irq_chip
Browse files Browse the repository at this point in the history
In order to consolidate the multiple ways to associate an IRQ chip with
a GPIO chip, move more fields into the new struct gpio_irq_chip.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Thierry Reding authored and Linus Walleij committed Nov 8, 2017
1 parent c44eafd commit da80ff8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
14 changes: 7 additions & 7 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ static int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
* category than their parents, so it won't report false recursion.
*/
irq_set_lockdep_class(irq, chip->lock_key);
irq_set_chip_and_handler(irq, chip->irqchip, chip->irq_handler);
irq_set_chip_and_handler(irq, chip->irq.chip, chip->irq_handler);
/* Chips that use nested thread handlers have them marked */
if (chip->irq_nested)
irq_set_nested_thread(irq, 1);
Expand Down Expand Up @@ -1739,10 +1739,10 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
irq_domain_remove(gpiochip->irqdomain);
}

if (gpiochip->irqchip) {
gpiochip->irqchip->irq_request_resources = NULL;
gpiochip->irqchip->irq_release_resources = NULL;
gpiochip->irqchip = NULL;
if (gpiochip->irq.chip) {
gpiochip->irq.chip->irq_request_resources = NULL;
gpiochip->irq.chip->irq_release_resources = NULL;
gpiochip->irq.chip = NULL;
}

gpiochip_irqchip_free_valid_mask(gpiochip);
Expand Down Expand Up @@ -1817,7 +1817,7 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip,
type = IRQ_TYPE_NONE;
}

gpiochip->irqchip = irqchip;
gpiochip->irq.chip = irqchip;
gpiochip->irq_handler = handler;
gpiochip->irq_default_type = type;
gpiochip->to_irq = gpiochip_to_irq;
Expand All @@ -1826,7 +1826,7 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip,
gpiochip->ngpio, first_irq,
&gpiochip_domain_ops, gpiochip);
if (!gpiochip->irqdomain) {
gpiochip->irqchip = NULL;
gpiochip->irq.chip = NULL;
return -EINVAL;
}

Expand Down
14 changes: 12 additions & 2 deletions include/linux/gpio/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ struct module;
* struct gpio_irq_chip - GPIO interrupt controller
*/
struct gpio_irq_chip {
/**
* @chip:
*
* GPIO IRQ chip implementation, provided by GPIO driver.
*/
struct irq_chip *chip;

/**
* @domain_ops:
*
Expand All @@ -47,6 +54,11 @@ struct gpio_irq_chip {
*/
void *parent_handler_data;
};

static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip)
{
return container_of(chip, struct gpio_irq_chip, chip);
}
#endif

/**
Expand Down Expand Up @@ -112,7 +124,6 @@ struct gpio_irq_chip {
* safely.
* @bgpio_dir: shadowed direction register for generic GPIO to clear/set
* direction safely.
* @irqchip: GPIO IRQ chip impl, provided by GPIO driver
* @irqdomain: Interrupt translation domain; responsible for mapping
* between GPIO hwirq number and linux irq number
* @irq_handler: the irq handler to use (often a predefined irq core function)
Expand Down Expand Up @@ -197,7 +208,6 @@ struct gpio_chip {
* With CONFIG_GPIOLIB_IRQCHIP we get an irqchip inside the gpiolib
* to handle IRQs for most practical cases.
*/
struct irq_chip *irqchip;
struct irq_domain *irqdomain;
irq_flow_handler_t irq_handler;
unsigned int irq_default_type;
Expand Down

0 comments on commit da80ff8

Please sign in to comment.