Commit daecca4b authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bartosz Golaszewski
Browse files

gpiolib: Do not alter GPIO chip fwnode member



Ideally we should not touch data in the given GPIO chip structure.
Let's become closer to it by avoiding altering fwnode member.

The GPIO library must use fwnode from GPIO device and the drivers
might use one from GPIO chip in case they initialized it.

Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: default avatarBenjamin Tissoires <bentiss@kernel.org>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 067dbc1e
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -711,13 +711,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
	int base = 0;
	int ret = 0;

	/*
	 * If the calling driver did not initialize firmware node, do it here
	 * using the parent device, if any.
	 */
	if (!gc->fwnode && gc->parent)
		gc->fwnode = dev_fwnode(gc->parent);

	/*
	 * First: allocate and populate the internal stat container, and
	 * set up the struct device.
@@ -732,7 +725,14 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
	gc->gpiodev = gdev;
	gpiochip_set_data(gc, data);

	/*
	 * If the calling driver did not initialize firmware node,
	 * do it here using the parent device, if any.
	 */
	if (gc->fwnode)
		device_set_node(&gdev->dev, gc->fwnode);
	else if (gc->parent)
		device_set_node(&gdev->dev, dev_fwnode(gc->parent));

	gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL);
	if (gdev->id < 0) {