gpio fixes for v6.17

- allow looking up GPIOs by the secondary firmware node too
 - fix memory leak in gpio-regmap
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmjWZBgACgkQEacuoBRx
 13KzWQ//b0TTLgektBbPsGbPKNR8Jm0ma0Def+mT5Z6mZz5L2QjuJkbCKpiNyU/u
 +yDnCvvn23baUHXnsvFOB7/s4Hm7fv97EhXcsNF6x5Nr10MYQIiqqQo7IdvjvaT3
 HKHEfrbr6Ei2j7tDoRURi8tyCGVchCRla8pZVItIvuyN+qMfcV5IxnObRi1g4FTu
 GM+fxYI30dwSnYqEDovqpYulb+oVEkIztkWUL6tiL5n7dQ9slUuo3QZQAfcYECln
 g23UwrK/vR3r0EBbV5Y7EFCMxnQ97dNiOiMZ7JsjsPkp7CI43borF8O5NQcdiPp9
 wNtpqUSwEHv+X6jj8J9U1+EVCwftJRTwZ7XBqpIjJh+8yilwbrEOLmfz/9T1COJo
 pk93D2WQckeeodX4akBSZQs9Yc7bjTxlbhyLoR+iVer7kjk8qkHciy08W65BigtQ
 Ka1VIlAmANpfNxXyoVyWi20Gk6WGA7js7kwhYJJagaRfbV37d5Lcs9f4hcCh0P5m
 O+juFb3JChpw4sSTn2K3ML8gOElo16aRjYd4f0GquQSrSoazYkUS05wVuYHncifO
 jWFptOOT43cP8mfT3aC6OOprgimPgXlDmkaQYVuUp9+cFHHML/t912S6+GvL4mGg
 qe7WmwVL4gVxQHNXJdz92NqNOtwQkvRgXqgYah/UDr7ROYl0F48=
 =tnUa
 -----END PGP SIGNATURE-----

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

Pull gpio fixes from Bartosz Golaszewski:

 - allow looking up GPIOs by the secondary firmware node too

 - fix memory leak in gpio-regmap

* tag 'gpio-fixes-for-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpio: regmap: fix memory leak of gpio_regmap structure
  gpiolib: Extend software-node support to support secondary software-nodes
This commit is contained in:
Linus Torvalds 2025-09-26 10:23:58 -07:00
commit df2837012f
2 changed files with 20 additions and 3 deletions

View File

@ -274,7 +274,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
if (!chip->ngpio) {
ret = gpiochip_get_ngpios(chip, chip->parent);
if (ret)
return ERR_PTR(ret);
goto err_free_gpio;
}
/* if not set, assume there is only one register */

View File

@ -4604,6 +4604,23 @@ static struct gpio_desc *gpiod_find_by_fwnode(struct fwnode_handle *fwnode,
return desc;
}
static struct gpio_desc *gpiod_fwnode_lookup(struct fwnode_handle *fwnode,
struct device *consumer,
const char *con_id,
unsigned int idx,
enum gpiod_flags *flags,
unsigned long *lookupflags)
{
struct gpio_desc *desc;
desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx, flags, lookupflags);
if (gpiod_not_found(desc) && !IS_ERR_OR_NULL(fwnode))
desc = gpiod_find_by_fwnode(fwnode->secondary, consumer, con_id,
idx, flags, lookupflags);
return desc;
}
struct gpio_desc *gpiod_find_and_request(struct device *consumer,
struct fwnode_handle *fwnode,
const char *con_id,
@ -4622,8 +4639,8 @@ struct gpio_desc *gpiod_find_and_request(struct device *consumer,
int ret = 0;
scoped_guard(srcu, &gpio_devices_srcu) {
desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx,
&flags, &lookupflags);
desc = gpiod_fwnode_lookup(fwnode, consumer, con_id, idx,
&flags, &lookupflags);
if (gpiod_not_found(desc) && platform_lookup_allowed) {
/*
* Either we are not using DT or ACPI, or their lookup