summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiawen Wu <jiawenwu@trustnetic.com>2023-06-07 11:18:03 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-06-28 12:12:34 +0300
commitcb1108e174935ac986c18bf3bb2178b20209c234 (patch)
treee1dab60e5cf05830a73266525fe538005c5726df
parent90714f7ed760bb21a072dfa86795d4864daf9d6d (diff)
downloadlinux-cb1108e174935ac986c18bf3bb2178b20209c234.tar.xz
gpiolib: Fix GPIO chip IRQ initialization restriction
[ Upstream commit 8c00914e5438e3636f26b4f814b3297ae2a1b9ee ] In case of gpio-regmap, IRQ chip is added by regmap-irq and associated with GPIO chip by gpiochip_irqchip_add_domain(). The initialization flag was not added in gpiochip_irqchip_add_domain(), causing gpiochip_to_irq() to return -EPROBE_DEFER. Fixes: 5467801f1fcb ("gpio: Restrict usage of GPIO chip irq members before initialization") Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/gpio/gpiolib.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 5974cfc61b41..f2cb07093185 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1697,6 +1697,14 @@ int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
gc->to_irq = gpiochip_to_irq;
gc->irq.domain = domain;
+ /*
+ * 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);