gpio fixes for v6.4

- 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
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmSVbnsACgkQEacuoBRx
 13JZiQ//QnUfDWPLwOzZ56jkz5rubWz9Gn4mlhWB1YB+897yI9TVpEyvoHXjUTMg
 DneP8y+Dw+2R4IKIxza6E5yGynxFw5o7aCJrF5hSH3IctYYKyWAbmXwEpXvAxdBI
 9Z6X4ASYWEWPzhcXGVS+MXLNK3aCPf9jlv6AvpmtbJ7Vyw7+Z+A1USePdYh7hcwi
 FqnDU2GokJKFKgaUxWHjHpDDu8ad4kwLyExCurTXh8BT/qxYUu4OCcSDKeD7MnmQ
 qHa3BPQA1ozbgjjacsggXGNf3I4av0ayMRNft3yq7PFEXBW7PCH6BTyOY3JiPt9Z
 OMjgOxEzA2LdLnHeUgtFxVjNX8MwTGoMQYG1+piouJ+0Do2XG4GY4DiMk2Op8Dh3
 Z9eqmDAVMJd5eXM5U503TjY4JbP6hCqFYqqFdvPJpSOfFhBk2nV+6X2zZOvqu0kt
 Rl2Ejqp9I4jhUPl/dm+UOZkz+21tm91IGpsxvGdqudsV4cXbHF4/j/atnE9fRM3x
 W0vQkynOamMKfeAKYGyMly20zogJ0+dQ+U+jBDWEBLCSNz6rsTvAzk61jTyXZAW2
 EvmsCJPYehvblJG0ePzUrGmnMf057fc7Ce45vBToEN6JnfJjD5Q1ElwMEDPcB54G
 vo4n8i16Q0NU4CsWGpKirPNTAOZ1e5K1PneTHB9odcvzB2oL9r0=
 =avPl
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2023-06-23 15:24:09 -07:00
commit 6edecb9986
3 changed files with 24 additions and 3 deletions

View File

@ -221,8 +221,12 @@ static int sifive_gpio_probe(struct platform_device *pdev)
return -ENODEV;
}
for (i = 0; i < ngpio; i++)
chip->irq_number[i] = platform_get_irq(pdev, i);
for (i = 0; i < ngpio; i++) {
ret = platform_get_irq(pdev, i);
if (ret < 0)
return ret;
chip->irq_number[i] = ret;
}
ret = bgpio_init(&chip->gc, dev, 4,
chip->base + SIFIVE_GPIO_INPUT_VAL,

View File

@ -1745,7 +1745,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc)
}
/* Remove all IRQ mappings and delete the domain */
if (gc->irq.domain) {
if (!gc->irq.domain_is_allocated_externally && gc->irq.domain) {
unsigned int irq;
for (offset = 0; offset < gc->ngpio; offset++) {
@ -1791,6 +1791,15 @@ int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
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;
}

View File

@ -251,6 +251,14 @@ struct gpio_irq_chip {
*/
bool initialized;
/**
* @domain_is_allocated_externally:
*
* True it the irq_domain was allocated outside of gpiolib, in which
* case gpiolib won't free the irq_domain itself.
*/
bool domain_is_allocated_externally;
/**
* @init_hw: optional routine to initialize hardware before
* an IRQ chip will be added. This is quite useful when