Message ID | 20211115183029.234898-1-shreeya.patel@collabora.com |
---|---|
State | Accepted |
Commit | ae42f9288846353982e2eab181fb41e7fd8bf60f |
Headers | show |
Series | [v3] gpio: Return EPROBE_DEFER if gc->to_irq is NULL | expand |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index abfbf546d159..4d7fb349e837 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3111,6 +3111,16 @@ int gpiod_to_irq(const struct gpio_desc *desc) return retirq; } +#ifdef CONFIG_GPIOLIB_IRQCHIP + if (gc->irq.chip) { + /* + * avoid race condition with other code, which tries to lookup + * an IRQ before the irqchip has been properly registered, + * i.e. while gpiochip is still being brought up. + */ + return -EPROBE_DEFER; + } +#endif return -ENXIO; } EXPORT_SYMBOL_GPL(gpiod_to_irq);