Commit 081bfdb3 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bartosz Golaszewski

gpiolib: Split out gpiochip_irqchip_add_allocated_domain() helper

The gpiochip_irqchip_add_allocated_domain() can be used
in another place in the code.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 39f3ad73
...@@ -1638,6 +1638,28 @@ static void gpiochip_set_irq_hooks(struct gpio_chip *gc) ...@@ -1638,6 +1638,28 @@ static void gpiochip_set_irq_hooks(struct gpio_chip *gc)
} }
} }
static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc,
struct irq_domain *domain,
bool allocated_externally)
{
if (!domain)
return -EINVAL;
gc->to_irq = gpiochip_to_irq;
gc->irq.domain = domain;
gc->irq.domain_is_allocated_externally = allocated_externally;
/*
* Using barrier() here to prevent compiler from reordering
* gc->irq.initialized before adding irqdomain.
*/
barrier();
gc->irq.initialized = true;
return 0;
}
/** /**
* gpiochip_add_irqchip() - adds an IRQ chip to a GPIO chip * gpiochip_add_irqchip() - adds an IRQ chip to a GPIO chip
* @gc: the GPIO chip to add the IRQ chip to * @gc: the GPIO chip to add the IRQ chip to
...@@ -1791,22 +1813,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc) ...@@ -1791,22 +1813,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc)
int gpiochip_irqchip_add_domain(struct gpio_chip *gc, int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
struct irq_domain *domain) struct irq_domain *domain)
{ {
if (!domain) return gpiochip_irqchip_add_allocated_domain(gc, domain, true);
return -EINVAL;
gc->to_irq = gpiochip_to_irq;
gc->irq.domain = domain;
gc->irq.domain_is_allocated_externally = true;
/*
* Using barrier() here to prevent compiler from reordering
* gc->irq.initialized before adding irqdomain.
*/
barrier();
gc->irq.initialized = true;
return 0;
} }
EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_domain); EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_domain);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment