Commit df283701 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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
parents 3a654ee5 3bd44edd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 */
+19 −2
Original line number Diff line number Diff line
@@ -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,7 +4639,7 @@ 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,
		desc = gpiod_fwnode_lookup(fwnode, consumer, con_id, idx,
					   &flags, &lookupflags);
		if (gpiod_not_found(desc) && platform_lookup_allowed) {
			/*