Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpiolib: Move of_node operations to gpiolib-of and correct fwnode use

The initial value of the OF node based on presence of parent, but
at the same time this operation somehow appeared separately from others
that handle the OF case. On the other hand there is no need to assign
dev->fwnode in the OF case if code properly retrieves fwnode, i.e.
via dev_fwnode() helper.

Amend gpiolib.c and gpiolib-of.c code in order to group OF operations.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
1df62542 944f4b0a

+8 -7
+4 -2
drivers/gpio/gpiolib-of.c
··· 1042 1042 1043 1043 void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) 1044 1044 { 1045 + /* Set default OF node to parent's one if present */ 1046 + if (gc->parent) 1047 + gdev->dev.of_node = gc->parent->of_node; 1048 + 1045 1049 /* If the gpiochip has an assigned OF node this takes precedence */ 1046 1050 if (gc->of_node) 1047 1051 gdev->dev.of_node = gc->of_node; 1048 1052 else 1049 1053 gc->of_node = gdev->dev.of_node; 1050 - if (gdev->dev.of_node) 1051 - gdev->dev.fwnode = of_fwnode_handle(gdev->dev.of_node); 1052 1054 }
+4 -5
drivers/gpio/gpiolib.c
··· 586 586 if (!gdev) 587 587 return -ENOMEM; 588 588 gdev->dev.bus = &gpio_bus_type; 589 + gdev->dev.parent = gc->parent; 589 590 gdev->chip = gc; 590 591 gc->gpiodev = gdev; 591 - if (gc->parent) { 592 - gdev->dev.parent = gc->parent; 593 - gdev->dev.of_node = gc->parent->of_node; 594 - } 595 592 596 593 of_gpio_dev_init(gc, gdev); 597 594 ··· 4215 4218 4216 4219 static int gpio_bus_match(struct device *dev, struct device_driver *drv) 4217 4220 { 4221 + struct fwnode_handle *fwnode = dev_fwnode(dev); 4222 + 4218 4223 /* 4219 4224 * Only match if the fwnode doesn't already have a proper struct device 4220 4225 * created for it. 4221 4226 */ 4222 - if (dev->fwnode && dev->fwnode->dev != dev) 4227 + if (fwnode && fwnode->dev != dev) 4223 4228 return 0; 4224 4229 return 1; 4225 4230 }