History

Merge tag 'gpio-fixes-for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski: - fix IRQ initialization in gpiochip_irqchip_add_domain() - add a missing return value check for platform_get_irq() in gpio-sifive - don't free irq_domains which GPIOLIB does not manage * tag 'gpio-fixes-for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpiolib: Fix irq_domain resource tracking for gpiochip_irqchip_add_domain() gpio: sifive: add missing check for platform_get_irq gpiolib: Fix GPIO chip IRQ initialization restriction

Linus Torvalds committed 3 years ago

Commit 6edecb92 parents afa4bb7 ff7a1793 files · +24 −3Browse files

Unified · Split

3 files
  1. drivers/gpio/gpio-sifive.c +6 −2
  2. drivers/gpio/gpiolib.c +10 −1
  3. include/linux/gpio/driver.h +8 −0
drivers/gpio/gpio-sifive.c+6−2
@@ -221,8 +221,12 @@ static int sifive_gpio_probe(struct platform_device *pdev) · 220 unmodified lines
221 return -ENODEV;221 return -ENODEV;
222 }222 }
223 223
224 for (i = 0; i < ngpio; i++)224 for (i = 0; i < ngpio; i++) {
225 chip->irq_number[i] = platform_get_irq(pdev, i);225 ret = platform_get_irq(pdev, i);
226 if (ret < 0)
227 return ret;
228 chip->irq_number[i] = ret;
229 }
226 230
227 ret = bgpio_init(&chip->gc, dev, 4,231 ret = bgpio_init(&chip->gc, dev, 4,
228 chip->base + SIFIVE_GPIO_INPUT_VAL,232 chip->base + SIFIVE_GPIO_INPUT_VAL,
drivers/gpio/gpiolib.c+10−1
@@ -1745,7 +1745,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc) · 1744 unmodified lines
1745 }1745 }
1746 1746
1747 /* Remove all IRQ mappings and delete the domain */1747 /* Remove all IRQ mappings and delete the domain */
1748 if (gc->irq.domain) {1748 if (!gc->irq.domain_is_allocated_externally && gc->irq.domain) {
1749 unsigned int irq;1749 unsigned int irq;
1750 1750
1751 for (offset = 0; offset < gc->ngpio; offset++) {1751 for (offset = 0; offset < gc->ngpio; offset++) {
@@ -1791,6 +1791,15 @@ int gpiochip_irqchip_add_domain(struct gpio_chip *gc, · 39 unmodified lines
1791 1791
1792 gc->to_irq = gpiochip_to_irq;1792 gc->to_irq = gpiochip_to_irq;
1793 gc->irq.domain = domain;1793 gc->irq.domain = domain;
1794 gc->irq.domain_is_allocated_externally = true;
1795
1796 /*
1797 * Using barrier() here to prevent compiler from reordering
1798 * gc->irq.initialized before adding irqdomain.
1799 */
1800 barrier();
1801
1802 gc->irq.initialized = true;
1794 1803
1795 return 0;1804 return 0;
1796}1805}
include/linux/gpio/driver.h+8−0
@@ -251,6 +251,14 @@ struct gpio_irq_chip { · 250 unmodified lines
251 */251 */
252 bool initialized;252 bool initialized;
253 253
254 /**
255 * @domain_is_allocated_externally:
256 *
257 * True it the irq_domain was allocated outside of gpiolib, in which
258 * case gpiolib won't free the irq_domain itself.
259 */
260 bool domain_is_allocated_externally;
261
254 /**262 /**
255 * @init_hw: optional routine to initialize hardware before263 * @init_hw: optional routine to initialize hardware before
256 * an IRQ chip will be added. This is quite useful when264 * an IRQ chip will be added. This is quite useful when