summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-06-21 20:49:40 +0300
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-07-10 11:29:43 +0200
commit1efc43de1781bbb8780ee6f6f2291073003f1ff1 (patch)
tree54caef3430c9c3592159e050435b665980c4d81d /drivers/gpio/gpiolib.c
parentb683b487dce74bd709aa21aa1056bcc9462d1dfc (diff)
gpiolib: Factor out gpiochip_simple_create_domain()
As a preparatory patch and for the sake of consistency, factor out gpiochip_simple_create_domain(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 1c0d0e33c6bd..796d2802ebb9 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1447,6 +1447,19 @@ static const struct irq_domain_ops gpiochip_domain_ops = {
.xlate = irq_domain_xlate_twocell,
};
+static struct irq_domain *gpiochip_simple_create_domain(struct gpio_chip *gc)
+{
+ struct fwnode_handle *fwnode = dev_fwnode(&gc->gpiodev->dev);
+ struct irq_domain *domain;
+
+ domain = irq_domain_create_simple(fwnode, gc->ngpio, gc->irq.first,
+ &gpiochip_domain_ops, gc);
+ if (!domain)
+ return ERR_PTR(-EINVAL);
+
+ return domain;
+}
+
/*
* TODO: move these activate/deactivate in under the hierarchicial
* irqchip implementation as static once SPMI and SSBI (all external
@@ -1673,13 +1686,9 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc,
if (IS_ERR(gc->irq.domain))
return PTR_ERR(gc->irq.domain);
} else {
- gc->irq.domain = irq_domain_create_simple(fwnode,
- gc->ngpio,
- gc->irq.first,
- &gpiochip_domain_ops,
- gc);
- if (!gc->irq.domain)
- return -EINVAL;
+ gc->irq.domain = gpiochip_simple_create_domain(gc);
+ if (IS_ERR(gc->irq.domain))
+ return PTR_ERR(gc->irq.domain);
}
if (gc->irq.parent_handler) {