diff mbox series

[v1,2/2] gpiolib: Get rid of not used of_node member

Message ID 20221109150706.38823-2-andriy.shevchenko@linux.intel.com
State Superseded
Headers show
Series None | expand

Commit Message

Andy Shevchenko Nov. 9, 2022, 3:07 p.m. UTC
All new drivers should use fwnode and / or parent to provide the
necessary information to the GPIO library.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 10 ----------
 drivers/gpio/gpiolib-acpi.h |  4 ----
 drivers/gpio/gpiolib-of.c   | 22 +++-------------------
 drivers/gpio/gpiolib-of.h   |  5 -----
 drivers/gpio/gpiolib.c      | 15 +--------------
 include/linux/gpio/driver.h |  7 -------
 6 files changed, 4 insertions(+), 59 deletions(-)

Comments

kernel test robot Nov. 10, 2022, 8:30 p.m. UTC | #1
Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on next-20221110]
[cannot apply to linus/master v6.1-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpiolib-of-Drop-redundant-check-in-of_mm_gpiochip_remove/20221109-230741
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20221109150706.38823-2-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 2/2] gpiolib: Get rid of not used of_node member
config: parisc-randconfig-r022-20221110
compiler: hppa-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5f1308f0c8de844767f5bb944834bf7d71a714c6
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/gpiolib-of-Drop-redundant-check-in-of_mm_gpiochip_remove/20221109-230741
        git checkout 5f1308f0c8de844767f5bb944834bf7d71a714c6
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/gpio/gpiolib-of.c: In function 'of_mm_gpiochip_add_data':
>> drivers/gpio/gpiolib-of.c:938:31: error: 'struct gpio_chip' has no member named 'of_node'; did you mean 'fwnode'?
     938 |         of_node_put(mm_gc->gc.of_node);
         |                               ^~~~~~~
         |                               fwnode
   drivers/gpio/gpiolib-of.c:939:19: error: 'struct gpio_chip' has no member named 'of_node'; did you mean 'fwnode'?
     939 |         mm_gc->gc.of_node = of_node_get(np);
         |                   ^~~~~~~
         |                   fwnode


vim +938 drivers/gpio/gpiolib-of.c

863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  897  
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  898  /**
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  899   * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  900   * @np:		device node of the GPIO chip
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  901   * @mm_gc:	pointer to the of_mm_gpio_chip allocated structure
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  902   * @data:	driver data to store in the struct gpio_chip
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  903   *
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  904   * To use this function you should allocate and fill mm_gc with:
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  905   *
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  906   * 1) In the gpio_chip structure:
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  907   *    - all the callbacks
a19e3da5bc5fc6 drivers/of/gpio.c         Anton Vorontsov    2010-06-08  908   *    - of_gpio_n_cells
a19e3da5bc5fc6 drivers/of/gpio.c         Anton Vorontsov    2010-06-08  909   *    - of_xlate callback (optional)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  910   *
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  911   * 3) In the of_mm_gpio_chip structure:
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  912   *    - save_regs callback (optional)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  913   *
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  914   * If succeeded, this function will map bank's memory and will
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  915   * do all necessary work for you. Then you'll able to use .regs
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  916   * to manage GPIOs from the callbacks.
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  917   */
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  918  int of_mm_gpiochip_add_data(struct device_node *np,
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  919  			    struct of_mm_gpio_chip *mm_gc,
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  920  			    void *data)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  921  {
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  922  	int ret = -ENOMEM;
a19e3da5bc5fc6 drivers/of/gpio.c         Anton Vorontsov    2010-06-08  923  	struct gpio_chip *gc = &mm_gc->gc;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  924  
7eb6ce2f272336 drivers/gpio/gpiolib-of.c Rob Herring        2017-07-18  925  	gc->label = kasprintf(GFP_KERNEL, "%pOF", np);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  926  	if (!gc->label)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  927  		goto err0;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  928  
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  929  	mm_gc->regs = of_iomap(np, 0);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  930  	if (!mm_gc->regs)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  931  		goto err1;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  932  
21451155d88587 drivers/of/gpio.c         Anton Vorontsov    2008-04-30  933  	gc->base = -1;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  934  
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  935  	if (mm_gc->save_regs)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  936  		mm_gc->save_regs(mm_gc);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  937  
5d07a692f9562f drivers/gpio/gpiolib-of.c Liang He           2022-07-11 @938  	of_node_put(mm_gc->gc.of_node);
5d07a692f9562f drivers/gpio/gpiolib-of.c Liang He           2022-07-11  939  	mm_gc->gc.of_node = of_node_get(np);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  940  
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  941  	ret = gpiochip_add_data(gc, data);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  942  	if (ret)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  943  		goto err2;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  944  
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  945  	return 0;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  946  err2:
5d07a692f9562f drivers/gpio/gpiolib-of.c Liang He           2022-07-11  947  	of_node_put(np);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  948  	iounmap(mm_gc->regs);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  949  err1:
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  950  	kfree(gc->label);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  951  err0:
7eb6ce2f272336 drivers/gpio/gpiolib-of.c Rob Herring        2017-07-18  952  	pr_err("%pOF: GPIO chip registration failed with status %d\n", np, ret);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  953  	return ret;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  954  }
6d6624554da4a6 drivers/gpio/gpiolib-of.c Geert Uytterhoeven 2019-09-06  955  EXPORT_SYMBOL_GPL(of_mm_gpiochip_add_data);
594fa265e08407 drivers/of/gpio.c         Grant Likely       2010-06-08  956
kernel test robot Nov. 12, 2022, 12:05 p.m. UTC | #2
Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on next-20221111]
[cannot apply to linus/master v6.1-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpiolib-of-Drop-redundant-check-in-of_mm_gpiochip_remove/20221109-230741
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20221109150706.38823-2-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 2/2] gpiolib: Get rid of not used of_node member
config: riscv-randconfig-r023-20221110
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 463da45892e2d2a262277b91b96f5f8c05dc25d0)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/5f1308f0c8de844767f5bb944834bf7d71a714c6
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/gpiolib-of-Drop-redundant-check-in-of_mm_gpiochip_remove/20221109-230741
        git checkout 5f1308f0c8de844767f5bb944834bf7d71a714c6
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/gpio/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/gpio/gpiolib-of.c:938:24: error: no member named 'of_node' in 'struct gpio_chip'; did you mean 'fwnode'?
           of_node_put(mm_gc->gc.of_node);
                                 ^~~~~~~
                                 fwnode
   include/linux/gpio/driver.h:411:24: note: 'fwnode' declared here
           struct fwnode_handle    *fwnode;
                                    ^
   drivers/gpio/gpiolib-of.c:939:12: error: no member named 'of_node' in 'struct gpio_chip'; did you mean 'fwnode'?
           mm_gc->gc.of_node = of_node_get(np);
                     ^~~~~~~
                     fwnode
   include/linux/gpio/driver.h:411:24: note: 'fwnode' declared here
           struct fwnode_handle    *fwnode;
                                    ^
   2 errors generated.


vim +938 drivers/gpio/gpiolib-of.c

863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  897  
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  898  /**
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  899   * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  900   * @np:		device node of the GPIO chip
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  901   * @mm_gc:	pointer to the of_mm_gpio_chip allocated structure
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  902   * @data:	driver data to store in the struct gpio_chip
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  903   *
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  904   * To use this function you should allocate and fill mm_gc with:
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  905   *
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  906   * 1) In the gpio_chip structure:
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  907   *    - all the callbacks
a19e3da5bc5fc6 drivers/of/gpio.c         Anton Vorontsov    2010-06-08  908   *    - of_gpio_n_cells
a19e3da5bc5fc6 drivers/of/gpio.c         Anton Vorontsov    2010-06-08  909   *    - of_xlate callback (optional)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  910   *
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  911   * 3) In the of_mm_gpio_chip structure:
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  912   *    - save_regs callback (optional)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  913   *
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  914   * If succeeded, this function will map bank's memory and will
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  915   * do all necessary work for you. Then you'll able to use .regs
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  916   * to manage GPIOs from the callbacks.
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  917   */
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  918  int of_mm_gpiochip_add_data(struct device_node *np,
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  919  			    struct of_mm_gpio_chip *mm_gc,
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  920  			    void *data)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  921  {
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  922  	int ret = -ENOMEM;
a19e3da5bc5fc6 drivers/of/gpio.c         Anton Vorontsov    2010-06-08  923  	struct gpio_chip *gc = &mm_gc->gc;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  924  
7eb6ce2f272336 drivers/gpio/gpiolib-of.c Rob Herring        2017-07-18  925  	gc->label = kasprintf(GFP_KERNEL, "%pOF", np);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  926  	if (!gc->label)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  927  		goto err0;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  928  
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  929  	mm_gc->regs = of_iomap(np, 0);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  930  	if (!mm_gc->regs)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  931  		goto err1;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  932  
21451155d88587 drivers/of/gpio.c         Anton Vorontsov    2008-04-30  933  	gc->base = -1;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  934  
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  935  	if (mm_gc->save_regs)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  936  		mm_gc->save_regs(mm_gc);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  937  
5d07a692f9562f drivers/gpio/gpiolib-of.c Liang He           2022-07-11 @938  	of_node_put(mm_gc->gc.of_node);
5d07a692f9562f drivers/gpio/gpiolib-of.c Liang He           2022-07-11  939  	mm_gc->gc.of_node = of_node_get(np);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  940  
3208b0f0c010b2 drivers/gpio/gpiolib-of.c Linus Walleij      2015-12-04  941  	ret = gpiochip_add_data(gc, data);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  942  	if (ret)
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  943  		goto err2;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  944  
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  945  	return 0;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  946  err2:
5d07a692f9562f drivers/gpio/gpiolib-of.c Liang He           2022-07-11  947  	of_node_put(np);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  948  	iounmap(mm_gc->regs);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  949  err1:
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  950  	kfree(gc->label);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  951  err0:
7eb6ce2f272336 drivers/gpio/gpiolib-of.c Rob Herring        2017-07-18  952  	pr_err("%pOF: GPIO chip registration failed with status %d\n", np, ret);
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  953  	return ret;
863fbf4966a7ac drivers/of/gpio.c         Anton Vorontsov    2008-04-11  954  }
6d6624554da4a6 drivers/gpio/gpiolib-of.c Geert Uytterhoeven 2019-09-06  955  EXPORT_SYMBOL_GPL(of_mm_gpiochip_add_data);
594fa265e08407 drivers/of/gpio.c         Grant Likely       2010-06-08  956
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index a7d2358736fe..5c6ebb249863 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -1363,16 +1363,6 @@  void acpi_gpiochip_remove(struct gpio_chip *chip)
 	kfree(acpi_gpio);
 }
 
-void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev)
-{
-	/* Set default fwnode to parent's one if present */
-	if (gc->parent)
-		ACPI_COMPANION_SET(&gdev->dev, ACPI_COMPANION(gc->parent));
-
-	if (gc->fwnode)
-		device_set_node(&gdev->dev, gc->fwnode);
-}
-
 static int acpi_gpio_package_count(const union acpi_object *obj)
 {
 	const union acpi_object *element = obj->package.elements;
diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
index 1ac6816839db..a15495ef19ea 100644
--- a/drivers/gpio/gpiolib-acpi.h
+++ b/drivers/gpio/gpiolib-acpi.h
@@ -38,8 +38,6 @@  struct acpi_gpio_info {
 void acpi_gpiochip_add(struct gpio_chip *chip);
 void acpi_gpiochip_remove(struct gpio_chip *chip);
 
-void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
-
 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
 
@@ -62,8 +60,6 @@  int acpi_gpio_count(struct device *dev, const char *con_id);
 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
 
-static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { }
-
 static inline void
 acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
 
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 83997434215e..e22d25d85c7e 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -669,7 +669,7 @@  static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
 	u32 tmp;
 	int ret;
 
-	chip_np = chip->of_node;
+	chip_np = to_of_node(chip->fwnode);
 	if (!chip_np)
 		return ERR_PTR(-EINVAL);
 
@@ -761,7 +761,7 @@  static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
 	struct device_node *np;
 	int ret;
 
-	for_each_available_child_of_node(chip->of_node, np) {
+	for_each_available_child_of_node(to_of_node(chip->fwnode), np) {
 		if (!of_property_read_bool(np, "gpio-hog"))
 			continue;
 
@@ -972,7 +972,7 @@  EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove);
 #ifdef CONFIG_PINCTRL
 static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
 {
-	struct device_node *np = chip->of_node;
+	struct device_node *np = to_of_node(chip->fwnode);
 	struct of_phandle_args pinspec;
 	struct pinctrl_dev *pctldev;
 	int index = 0, ret;
@@ -1094,19 +1094,3 @@  void of_gpiochip_remove(struct gpio_chip *chip)
 {
 	fwnode_handle_put(chip->fwnode);
 }
-
-void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev)
-{
-	/* Set default OF node to parent's one if present */
-	if (gc->parent)
-		gdev->dev.of_node = gc->parent->of_node;
-
-	if (gc->fwnode)
-		gc->of_node = to_of_node(gc->fwnode);
-
-	/* If the gpiochip has an assigned OF node this takes precedence */
-	if (gc->of_node)
-		gdev->dev.of_node = gc->of_node;
-	else
-		gc->of_node = gdev->dev.of_node;
-}
diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h
index 2c32a332ede5..f128a7f45945 100644
--- a/drivers/gpio/gpiolib-of.h
+++ b/drivers/gpio/gpiolib-of.h
@@ -14,7 +14,6 @@  struct gpio_desc *of_find_gpio(struct device *dev,
 int of_gpiochip_add(struct gpio_chip *gc);
 void of_gpiochip_remove(struct gpio_chip *gc);
 int of_gpio_get_count(struct device *dev, const char *con_id);
-void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
 #else
 static inline struct gpio_desc *of_find_gpio(struct device *dev,
 					     const char *con_id,
@@ -29,10 +28,6 @@  static inline int of_gpio_get_count(struct device *dev, const char *con_id)
 {
 	return 0;
 }
-static inline void of_gpio_dev_init(struct gpio_chip *gc,
-				    struct gpio_device *gdev)
-{
-}
 #endif /* CONFIG_OF_GPIO */
 
 extern struct notifier_block gpio_of_notifier;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 11fb7ec883e9..4032fbb6994c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -646,7 +646,6 @@  int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 			       struct lock_class_key *lock_key,
 			       struct lock_class_key *request_key)
 {
-	struct fwnode_handle *fwnode = NULL;
 	struct gpio_device *gdev;
 	unsigned long flags;
 	int base = gc->base;
@@ -654,11 +653,6 @@  int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 	int ret = 0;
 	u32 ngpios;
 
-	if (gc->fwnode)
-		fwnode = gc->fwnode;
-	else if (gc->parent)
-		fwnode = dev_fwnode(gc->parent);
-
 	/*
 	 * First: allocate and populate the internal stat container, and
 	 * set up the struct device.
@@ -671,14 +665,7 @@  int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 	gdev->chip = gc;
 	gc->gpiodev = gdev;
 
-	of_gpio_dev_init(gc, gdev);
-	acpi_gpio_dev_init(gc, gdev);
-
-	/*
-	 * Assign fwnode depending on the result of the previous calls,
-	 * if none of them succeed, assign it to the parent's one.
-	 */
-	gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode;
+	device_set_node(&gdev->dev, gc->fwnode ?: dev_fwnode(gc->parent));
 
 	gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL);
 	if (gdev->id < 0) {
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 6aeea1071b1b..12c2c32d42d2 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -503,13 +503,6 @@  struct gpio_chip {
 	 * the device tree automatically may have an OF translation
 	 */
 
-	/**
-	 * @of_node:
-	 *
-	 * Pointer to a device tree node representing this GPIO controller.
-	 */
-	struct device_node *of_node;
-
 	/**
 	 * @of_gpio_n_cells:
 	 *