Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/4] gpio: Unify the GPIO controller node check
@ 2026-08-24  7:42 Andy Shevchenko
  2026-08-24  7:42 ` [PATCH v1 1/4] gpio: Split fwnode_is_gpiochip() helper Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-08-24  7:42 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andy Shevchenko, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Jacky Huang, Shan-Chun Hung

There are handful of drivers perform the same check in different variations
over and over with a potential to make subtle mistakes. Unify the check by
providing a new helper and convert a few users as an example.

Andy Shevchenko (4):
  gpio: Split fwnode_is_gpiochip() helper
  gpio: shared: Replace open coded fwnode_is_gpiochip()
  pinctrl: ma35: Replace open coded fwnode_is_gpiochip()
  pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()

 drivers/gpio/gpiolib-shared.c          | 6 ++----
 drivers/pinctrl/nuvoton/pinctrl-ma35.c | 4 ++--
 drivers/pinctrl/pinctrl-pistachio.c    | 2 +-
 include/linux/gpio/driver.h            | 7 ++++++-
 4 files changed, 11 insertions(+), 8 deletions(-)

-- 
2.50.1



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 1/4] gpio: Split fwnode_is_gpiochip() helper
  2026-08-24  7:42 [PATCH v1 0/4] gpio: Unify the GPIO controller node check Andy Shevchenko
@ 2026-08-24  7:42 ` Andy Shevchenko
  2026-08-24  7:42 ` [PATCH v1 2/4] gpio: shared: Replace open coded fwnode_is_gpiochip() Andy Shevchenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-08-24  7:42 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andy Shevchenko, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Jacky Huang, Shan-Chun Hung

Many drivers repeat the same over and over. For clarity and robustness
split fwnode_is_gpiochip() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/driver.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 2ea21341adea..06d40fb77a73 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -879,9 +879,14 @@ static inline void gpiochip_unlock_as_irq(struct gpio_chip *gc,
 }
 #endif /* CONFIG_GPIOLIB */
 
+static inline bool fwnode_is_gpiochip(struct fwnode_handle *fwnode)
+{
+	return fwnode_property_present(child, "gpio-controller");
+}
+
 #define for_each_gpiochip_node(dev, child)					\
 	device_for_each_child_node(dev, child)					\
-		for_each_if(fwnode_property_present(child, "gpio-controller"))
+		for_each_if(fwnode_is_gpiochip(child))
 
 static inline unsigned int gpiochip_node_count(struct device *dev)
 {
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 2/4] gpio: shared: Replace open coded fwnode_is_gpiochip()
  2026-08-24  7:42 [PATCH v1 0/4] gpio: Unify the GPIO controller node check Andy Shevchenko
  2026-08-24  7:42 ` [PATCH v1 1/4] gpio: Split fwnode_is_gpiochip() helper Andy Shevchenko
@ 2026-08-24  7:42 ` Andy Shevchenko
  2026-08-24  8:37   ` Andy Shevchenko
  2026-08-24  7:42 ` [PATCH v1 3/4] pinctrl: ma35: " Andy Shevchenko
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2026-08-24  7:42 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andy Shevchenko, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Jacky Huang, Shan-Chun Hung

Since GPIOLIB provides a helper, no need to open code it, hence
replace that piece by fwnode_is_gpiochip().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-shared.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index 495bd3d0ddf0..be90926dffcc 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -203,9 +203,8 @@ static int gpio_shared_of_traverse(struct device_node *curr)
 			if (ret)
 				continue;
 
-			np = args.np;
-
-			if (!of_property_present(np, "gpio-controller"))
+			fwnode = of_fwnode_handle(args.np);
+			if (!fwnode_is_gpiochip(fwnode))
 				continue;
 
 			/*
@@ -222,7 +221,6 @@ static int gpio_shared_of_traverse(struct device_node *curr)
 			if (args.args_count != 2)
 				continue;
 
-			fwnode = of_fwnode_handle(args.np);
 			offset = args.args[0];
 
 			entry = gpio_shared_find_entry(fwnode, offset);
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 3/4] pinctrl: ma35: Replace open coded fwnode_is_gpiochip()
  2026-08-24  7:42 [PATCH v1 0/4] gpio: Unify the GPIO controller node check Andy Shevchenko
  2026-08-24  7:42 ` [PATCH v1 1/4] gpio: Split fwnode_is_gpiochip() helper Andy Shevchenko
  2026-08-24  7:42 ` [PATCH v1 2/4] gpio: shared: Replace open coded fwnode_is_gpiochip() Andy Shevchenko
@ 2026-08-24  7:42 ` Andy Shevchenko
  2026-08-24  7:42 ` [PATCH v1 4/4] pinctrl: pistachio: " Andy Shevchenko
  2026-08-26 10:33 ` [PATCH v1 0/4] gpio: Unify the GPIO controller node check Bartosz Golaszewski
  4 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-08-24  7:42 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andy Shevchenko, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Jacky Huang, Shan-Chun Hung

Since GPIOLIB provides a helper, no need to open code it, hence
replace that piece by fwnode_is_gpiochip().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/nuvoton/pinctrl-ma35.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index dafa85c105a1..922b727c4b6c 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -1075,7 +1075,7 @@ static int ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35_pinct
 	int ret;
 
 	device_for_each_child_node(dev, child) {
-		if (fwnode_property_present(child, "gpio-controller"))
+		if (fwnode_is_gpiochip(child))
 			continue;
 
 		npctl->nfunctions++;
@@ -1096,7 +1096,7 @@ static int ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35_pinct
 		return -ENOMEM;
 
 	device_for_each_child_node(dev, child) {
-		if (fwnode_property_present(child, "gpio-controller"))
+		if (fwnode_is_gpiochip(child))
 			continue;
 
 		ret = ma35_pinctrl_parse_functions(child, npctl, idx++);
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 4/4] pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()
  2026-08-24  7:42 [PATCH v1 0/4] gpio: Unify the GPIO controller node check Andy Shevchenko
                   ` (2 preceding siblings ...)
  2026-08-24  7:42 ` [PATCH v1 3/4] pinctrl: ma35: " Andy Shevchenko
@ 2026-08-24  7:42 ` Andy Shevchenko
  2026-08-30 14:57   ` kernel test robot
                     ` (2 more replies)
  2026-08-26 10:33 ` [PATCH v1 0/4] gpio: Unify the GPIO controller node check Bartosz Golaszewski
  4 siblings, 3 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-08-24  7:42 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andy Shevchenko, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Jacky Huang, Shan-Chun Hung

Since GPIOLIB provides a helper, no need to open code it, hence
replace that piece by fwnode_is_gpiochip().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/pinctrl-pistachio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index cc5cd2a538c5..32463733f7d7 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -1383,7 +1383,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
 			goto err;
 		}
 
-		if (!fwnode_property_present(child, "gpio-controller")) {
+		if (!fwnode_is_gpiochip(child)) {
 			fwnode_handle_put(child);
 			dev_err(pctl->dev,
 				"No gpio-controller property for bank %u\n", i);
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 2/4] gpio: shared: Replace open coded fwnode_is_gpiochip()
  2026-08-24  7:42 ` [PATCH v1 2/4] gpio: shared: Replace open coded fwnode_is_gpiochip() Andy Shevchenko
@ 2026-08-24  8:37   ` Andy Shevchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-08-24  8:37 UTC (permalink / raw)
  To: Bartosz Golaszewski, linux-gpio, linux-kernel, linux-arm-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Jacky Huang, Shan-Chun Hung

On Mon, Aug 24, 2026 at 09:42:33AM +0200, Andy Shevchenko wrote:
> Since GPIOLIB provides a helper, no need to open code it, hence
> replace that piece by fwnode_is_gpiochip().

...

> -			np = args.np;

Ah, this one is important.
It seems that

                        struct device_node *np __free(device_node) = NULL;

needs to be replaced with

                        struct fwnode_handle *node __free(fwnode_handle) = NULL;

or something alike between the lines.

> -			if (!of_property_present(np, "gpio-controller"))
> +			fwnode = of_fwnode_handle(args.np);
> +			if (!fwnode_is_gpiochip(fwnode))
>  				continue;

-- 
With Best Regards,
Andy Shevchenko




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 0/4] gpio: Unify the GPIO controller node check
  2026-08-24  7:42 [PATCH v1 0/4] gpio: Unify the GPIO controller node check Andy Shevchenko
                   ` (3 preceding siblings ...)
  2026-08-24  7:42 ` [PATCH v1 4/4] pinctrl: pistachio: " Andy Shevchenko
@ 2026-08-26 10:33 ` Bartosz Golaszewski
  2026-08-26 14:00   ` Andy Shevchenko
  4 siblings, 1 reply; 11+ messages in thread
From: Bartosz Golaszewski @ 2026-08-26 10:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, Jacky Huang, Shan-Chun Hung,
	Bartosz Golaszewski, linux-gpio, linux-kernel, linux-arm-kernel

On Mon, 24 Aug 2026 09:42:31 +0200, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> said:
> There are handful of drivers perform the same check in different variations
> over and over with a potential to make subtle mistakes. Unify the check by
> providing a new helper and convert a few users as an example.
>
> Andy Shevchenko (4):
>   gpio: Split fwnode_is_gpiochip() helper
>   gpio: shared: Replace open coded fwnode_is_gpiochip()
>   pinctrl: ma35: Replace open coded fwnode_is_gpiochip()
>   pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()
>
>  drivers/gpio/gpiolib-shared.c          | 6 ++----
>  drivers/pinctrl/nuvoton/pinctrl-ma35.c | 4 ++--
>  drivers/pinctrl/pinctrl-pistachio.c    | 2 +-
>  include/linux/gpio/driver.h            | 7 ++++++-
>  4 files changed, 11 insertions(+), 8 deletions(-)
>
> --
> 2.50.1
>
>

I like it. With an Ack from Linus, I can take the series through the GPIO tree.

Bart


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 0/4] gpio: Unify the GPIO controller node check
  2026-08-26 10:33 ` [PATCH v1 0/4] gpio: Unify the GPIO controller node check Bartosz Golaszewski
@ 2026-08-26 14:00   ` Andy Shevchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-08-26 14:00 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Jacky Huang, Shan-Chun Hung, Bartosz Golaszewski,
	linux-gpio, linux-kernel, linux-arm-kernel

On Wed, Aug 26, 2026 at 05:33:23AM -0500, Bartosz Golaszewski wrote:
> On Mon, 24 Aug 2026 09:42:31 +0200, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> said:
> > There are handful of drivers perform the same check in different variations
> > over and over with a potential to make subtle mistakes. Unify the check by
> > providing a new helper and convert a few users as an example.
> >
> 
> I like it. With an Ack from Linus, I can take the series through the GPIO tree.

Thanks, but note that I need to either drop or redo the patch 2/4.

-- 
With Best Regards,
Andy Shevchenko




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 4/4] pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()
  2026-08-24  7:42 ` [PATCH v1 4/4] pinctrl: pistachio: " Andy Shevchenko
@ 2026-08-30 14:57   ` kernel test robot
  2026-08-30 19:31   ` kernel test robot
  2026-08-30 21:13   ` kernel test robot
  2 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2026-08-30 14:57 UTC (permalink / raw)
  To: Andy Shevchenko, Bartosz Golaszewski, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: oe-kbuild-all, Linus Walleij, Jacky Huang, Shan-Chun Hung

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on linusw-pinctrl/devel linusw-pinctrl/for-next linus/master v7.2 next-20260828]
[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/gpio-Split-fwnode_is_gpiochip-helper/20260824-094232
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20260824074427.3226457-5-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 4/4] pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20260830/202608301629.wjbEOoNN-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
rustc: rustc 1.96.0 (ac68faa20 2026-05-25)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260830/202608301629.wjbEOoNN-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608301629.wjbEOoNN-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from rust/helpers/helpers.c:83:
   In file included from rust/helpers/pwm.c:5:
   In file included from include/linux/pwm.h:8:
>> include/linux/gpio/driver.h:888:33: error: use of undeclared identifier 'child'
     888 |         return fwnode_property_present(child, "gpio-controller");
         |                                        ^~~~~
   1 error generated.
--
>> include/linux/gpio/driver.h:888:33: error: use of undeclared identifier 'child'
>> Unable to generate bindings: clang diagnosed error: include/linux/gpio/driver.h:888:33: error: use of undeclared identifier 'child'


vim +/child +888 include/linux/gpio/driver.h

   885	
   886	static inline bool fwnode_is_gpiochip(struct fwnode_handle *fwnode)
   887	{
 > 888		return fwnode_property_present(child, "gpio-controller");
   889	}
   890	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 4/4] pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()
  2026-08-24  7:42 ` [PATCH v1 4/4] pinctrl: pistachio: " Andy Shevchenko
  2026-08-30 14:57   ` kernel test robot
@ 2026-08-30 19:31   ` kernel test robot
  2026-08-30 21:13   ` kernel test robot
  2 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2026-08-30 19:31 UTC (permalink / raw)
  To: Andy Shevchenko, Bartosz Golaszewski, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: llvm, oe-kbuild-all, Linus Walleij, Jacky Huang, Shan-Chun Hung

Hi Andy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on linusw-pinctrl/devel linusw-pinctrl/for-next linus/master v7.2 next-20260828]
[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/gpio-Split-fwnode_is_gpiochip-helper/20260824-094232
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20260824074427.3226457-5-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 4/4] pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260830/202608302138.FQoQsbAf-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260830/202608302138.FQoQsbAf-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608302138.FQoQsbAf-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/gpio/gpiolib-cdev.c:15:
   include/linux/gpio/driver.h:888:33: error: use of undeclared identifier 'child'
     888 |         return fwnode_property_present(child, "gpio-controller");
         |                                        ^~~~~
>> drivers/gpio/gpiolib-cdev.c:1650:2: warning: implicit conversion from '__size_t' (aka 'unsigned long') to 'unsigned int' changes value from 18446744073709551615 to 4294967295 [-Wconstant-conversion]
    1650 |         INIT_KFIFO(lr->events);
         |         ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/kfifo.h:135:69: note: expanded from macro 'INIT_KFIFO'
     135 |         __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : ARRAY_SIZE(__tmp->buf) - 1;\
         |                       ~                             ~~~~~~~~~~~~~~~~~~~~~~~^~~
   1 warning and 1 error generated.


vim +1650 drivers/gpio/gpiolib-cdev.c

96c02c906a44bc2 Kent Gibson         2026-02-16  1603  
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1604  static int linereq_create(struct gpio_device *gdev, void __user *ip)
925ca36913fc7df Kent Gibson         2020-06-16  1605  {
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1606  	struct gpio_v2_line_request ulr;
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1607  	struct gpio_v2_line_config *lc;
96c02c906a44bc2 Kent Gibson         2026-02-16  1608  	struct linereq *lr __free(linereq_free) = NULL;
b1a92e94560def6 Kent Gibson         2022-07-14  1609  	u64 flags, edflags;
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1610  	unsigned int i;
96c02c906a44bc2 Kent Gibson         2026-02-16  1611  	int ret;
925ca36913fc7df Kent Gibson         2020-06-16  1612  
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1613  	if (copy_from_user(&ulr, ip, sizeof(ulr)))
925ca36913fc7df Kent Gibson         2020-06-16  1614  		return -EFAULT;
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1615  
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1616  	if ((ulr.num_lines == 0) || (ulr.num_lines > GPIO_V2_LINES_MAX))
925ca36913fc7df Kent Gibson         2020-06-16  1617  		return -EINVAL;
925ca36913fc7df Kent Gibson         2020-06-16  1618  
e106b1dd38e723e Andy Shevchenko     2024-11-10  1619  	if (!mem_is_zero(ulr.padding, sizeof(ulr.padding)))
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1620  		return -EINVAL;
925ca36913fc7df Kent Gibson         2020-06-16  1621  
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1622  	lc = &ulr.config;
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1623  	ret = gpio_v2_line_config_validate(lc, ulr.num_lines);
925ca36913fc7df Kent Gibson         2020-06-16  1624  	if (ret)
925ca36913fc7df Kent Gibson         2020-06-16  1625  		return ret;
925ca36913fc7df Kent Gibson         2020-06-16  1626  
323bbfcf1ef8836 Linus Torvalds      2026-02-21  1627  	lr = kvzalloc_flex(*lr, lines, ulr.num_lines);
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1628  	if (!lr)
925ca36913fc7df Kent Gibson         2020-06-16  1629  		return -ENOMEM;
a512635da9f7223 Kees Cook           2023-09-22  1630  	lr->num_lines = ulr.num_lines;
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1631  
dc0989e3aa58dc4 Andy Shevchenko     2022-12-28  1632  	lr->gdev = gpio_device_get(gdev);
925ca36913fc7df Kent Gibson         2020-06-16  1633  
65cff70464068a8 Kent Gibson         2020-09-28  1634  	for (i = 0; i < ulr.num_lines; i++) {
73e0341992b68bb Kent Gibson         2020-09-28  1635  		lr->lines[i].req = lr;
65cff70464068a8 Kent Gibson         2020-09-28  1636  		WRITE_ONCE(lr->lines[i].sw_debounced, 0);
65cff70464068a8 Kent Gibson         2020-09-28  1637  		INIT_DELAYED_WORK(&lr->lines[i].work, debounce_work_func);
65cff70464068a8 Kent Gibson         2020-09-28  1638  	}
73e0341992b68bb Kent Gibson         2020-09-28  1639  
f188ac1251b909c Kent Gibson         2020-10-05  1640  	if (ulr.consumer[0] != '\0') {
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1641  		/* label is only initialized if consumer is set */
f188ac1251b909c Kent Gibson         2020-10-05  1642  		lr->label = kstrndup(ulr.consumer, sizeof(ulr.consumer) - 1,
925ca36913fc7df Kent Gibson         2020-06-16  1643  				     GFP_KERNEL);
96c02c906a44bc2 Kent Gibson         2026-02-16  1644  		if (!lr->label)
96c02c906a44bc2 Kent Gibson         2026-02-16  1645  			return -ENOMEM;
925ca36913fc7df Kent Gibson         2020-06-16  1646  	}
925ca36913fc7df Kent Gibson         2020-06-16  1647  
a54756cb24eafac Kent Gibson         2020-09-28  1648  	mutex_init(&lr->config_mutex);
73e0341992b68bb Kent Gibson         2020-09-28  1649  	init_waitqueue_head(&lr->wait);
35d848e7a1cbba2 Kent Gibson         2024-05-29 @1650  	INIT_KFIFO(lr->events);
73e0341992b68bb Kent Gibson         2020-09-28  1651  	lr->event_buffer_size = ulr.event_buffer_size;
73e0341992b68bb Kent Gibson         2020-09-28  1652  	if (lr->event_buffer_size == 0)
73e0341992b68bb Kent Gibson         2020-09-28  1653  		lr->event_buffer_size = ulr.num_lines * 16;
73e0341992b68bb Kent Gibson         2020-09-28  1654  	else if (lr->event_buffer_size > GPIO_V2_LINES_MAX * 16)
73e0341992b68bb Kent Gibson         2020-09-28  1655  		lr->event_buffer_size = GPIO_V2_LINES_MAX * 16;
73e0341992b68bb Kent Gibson         2020-09-28  1656  
73e0341992b68bb Kent Gibson         2020-09-28  1657  	atomic_set(&lr->seqno, 0);
883f91981843712 Kent Gibson         2020-07-08  1658  
925ca36913fc7df Kent Gibson         2020-06-16  1659  	/* Request each GPIO */
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1660  	for (i = 0; i < ulr.num_lines; i++) {
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1661  		u32 offset = ulr.offsets[i];
f4e14d45d7fe95f Bartosz Golaszewski 2024-01-24  1662  		struct gpio_desc *desc = gpio_device_get_desc(gdev, offset);
925ca36913fc7df Kent Gibson         2020-06-16  1663  
96c02c906a44bc2 Kent Gibson         2026-02-16  1664  		if (IS_ERR(desc))
96c02c906a44bc2 Kent Gibson         2026-02-16  1665  			return PTR_ERR(desc);
925ca36913fc7df Kent Gibson         2020-06-16  1666  
95a4eed7dd5b7c1 Andy Shevchenko     2022-02-01  1667  		ret = gpiod_request_user(desc, lr->label);
925ca36913fc7df Kent Gibson         2020-06-16  1668  		if (ret)
96c02c906a44bc2 Kent Gibson         2026-02-16  1669  			return ret;
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1670  
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1671  		lr->lines[i].desc = desc;
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1672  		flags = gpio_v2_line_config_flags(lc, i);
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1673  		gpio_v2_line_config_flags_to_desc_flags(flags, &desc->flags);
925ca36913fc7df Kent Gibson         2020-06-16  1674  
925ca36913fc7df Kent Gibson         2020-06-16  1675  		ret = gpiod_set_transitory(desc, false);
925ca36913fc7df Kent Gibson         2020-06-16  1676  		if (ret < 0)
96c02c906a44bc2 Kent Gibson         2026-02-16  1677  			return ret;
925ca36913fc7df Kent Gibson         2020-06-16  1678  
b1a92e94560def6 Kent Gibson         2022-07-14  1679  		edflags = flags & GPIO_V2_LINE_EDGE_DETECTOR_FLAGS;
925ca36913fc7df Kent Gibson         2020-06-16  1680  		/*
925ca36913fc7df Kent Gibson         2020-06-16  1681  		 * Lines have to be requested explicitly for input
925ca36913fc7df Kent Gibson         2020-06-16  1682  		 * or output, else the line will be treated "as is".
925ca36913fc7df Kent Gibson         2020-06-16  1683  		 */
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1684  		if (flags & GPIO_V2_LINE_FLAG_OUTPUT) {
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1685  			int val = gpio_v2_line_config_output_value(lc, i);
925ca36913fc7df Kent Gibson         2020-06-16  1686  
07c61d4da43fa3b Bartosz Golaszewski 2024-10-18  1687  			ret = gpiod_direction_output_nonotify(desc, val);
925ca36913fc7df Kent Gibson         2020-06-16  1688  			if (ret)
96c02c906a44bc2 Kent Gibson         2026-02-16  1689  				return ret;
3c0d9c635ae2b2c Kent Gibson         2020-09-28  1690  		} else if (flags & GPIO_V2_LINE_FLAG_INPUT) {
07c61d4da43fa3b Bartosz Golaszewski 2024-10-18  1691  			ret = gpiod_direction_input_nonotify(desc);
925ca36913fc7df Kent Gibson         2020-06-16  1692  			if (ret)
96c02c906a44bc2 Kent Gibson         2026-02-16  1693  				return ret;
73e0341992b68bb Kent Gibson         2020-09-28  1694  
65cff70464068a8 Kent Gibson         2020-09-28  1695  			ret = edge_detector_setup(&lr->lines[i], lc, i,
b1a92e94560def6 Kent Gibson         2022-07-14  1696  						  edflags);
73e0341992b68bb Kent Gibson         2020-09-28  1697  			if (ret)
96c02c906a44bc2 Kent Gibson         2026-02-16  1698  				return ret;
925ca36913fc7df Kent Gibson         2020-06-16  1699  		}
925ca36913fc7df Kent Gibson         2020-06-16  1700  
b1a92e94560def6 Kent Gibson         2022-07-14  1701  		lr->lines[i].edflags = edflags;
b1a92e94560def6 Kent Gibson         2022-07-14  1702  
9ce4ed5b4db1363 Bartosz Golaszewski 2023-08-21  1703  		gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_REQUESTED);
925ca36913fc7df Kent Gibson         2020-06-16  1704  
925ca36913fc7df Kent Gibson         2020-06-16  1705  		dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
925ca36913fc7df Kent Gibson         2020-06-16  1706  			offset);
925ca36913fc7df Kent Gibson         2020-06-16  1707  	}
925ca36913fc7df Kent Gibson         2020-06-16  1708  
a0dda508bd66b9e Bartosz Golaszewski 2023-08-17  1709  	lr->device_unregistered_nb.notifier_call = linereq_unregistered_notify;
a0dda508bd66b9e Bartosz Golaszewski 2023-08-17  1710  	ret = blocking_notifier_chain_register(&gdev->device_notifier,
a0dda508bd66b9e Bartosz Golaszewski 2023-08-17  1711  					       &lr->device_unregistered_nb);
a0dda508bd66b9e Bartosz Golaszewski 2023-08-17  1712  	if (ret)
96c02c906a44bc2 Kent Gibson         2026-02-16  1713  		return ret;
925ca36913fc7df Kent Gibson         2020-06-16  1714  
96c02c906a44bc2 Kent Gibson         2026-02-16  1715  	FD_PREPARE(fdf, O_RDONLY | O_CLOEXEC,
96c02c906a44bc2 Kent Gibson         2026-02-16  1716  		   anon_inode_getfile("gpio-line", &line_fileops, lr,
96c02c906a44bc2 Kent Gibson         2026-02-16  1717  				      O_RDONLY | O_CLOEXEC));
96c02c906a44bc2 Kent Gibson         2026-02-16  1718  	if (fdf.err)
96c02c906a44bc2 Kent Gibson         2026-02-16  1719  		return fdf.err;
96c02c906a44bc2 Kent Gibson         2026-02-16  1720  	retain_and_null_ptr(lr);
925ca36913fc7df Kent Gibson         2020-06-16  1721  
96c02c906a44bc2 Kent Gibson         2026-02-16  1722  	ulr.fd = fd_prepare_fd(fdf);
96c02c906a44bc2 Kent Gibson         2026-02-16  1723  	if (copy_to_user(ip, &ulr, sizeof(ulr)))
925ca36913fc7df Kent Gibson         2020-06-16  1724  		return -EFAULT;
925ca36913fc7df Kent Gibson         2020-06-16  1725  
96c02c906a44bc2 Kent Gibson         2026-02-16  1726  	fd_publish(fdf);
925ca36913fc7df Kent Gibson         2020-06-16  1727  
925ca36913fc7df Kent Gibson         2020-06-16  1728  	dev_dbg(&gdev->dev, "registered chardev handle for %d lines\n",
96c02c906a44bc2 Kent Gibson         2026-02-16  1729  		ulr.num_lines);
925ca36913fc7df Kent Gibson         2020-06-16  1730  
925ca36913fc7df Kent Gibson         2020-06-16  1731  	return 0;
925ca36913fc7df Kent Gibson         2020-06-16  1732  }
925ca36913fc7df Kent Gibson         2020-06-16  1733  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 4/4] pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()
  2026-08-24  7:42 ` [PATCH v1 4/4] pinctrl: pistachio: " Andy Shevchenko
  2026-08-30 14:57   ` kernel test robot
  2026-08-30 19:31   ` kernel test robot
@ 2026-08-30 21:13   ` kernel test robot
  2 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2026-08-30 21:13 UTC (permalink / raw)
  To: Andy Shevchenko, Bartosz Golaszewski, linux-gpio, linux-kernel,
	linux-arm-kernel
  Cc: oe-kbuild-all, Linus Walleij, Jacky Huang, Shan-Chun Hung

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on linusw-pinctrl/devel linusw-pinctrl/for-next linus/master v7.2 next-20260827]
[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/gpio-Split-fwnode_is_gpiochip-helper/20260824-094232
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20260824074427.3226457-5-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 4/4] pinctrl: pistachio: Replace open coded fwnode_is_gpiochip()
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260830/202608302328.ToabNDV1-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260830/202608302328.ToabNDV1-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608302328.ToabNDV1-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/bcma/bcma_driver_chipcommon.h:7,
                    from include/linux/bcma/bcma.h:9,
                    from arch/x86/kernel/early-quirks.c:17:
   include/linux/gpio/driver.h: In function 'fwnode_is_gpiochip':
>> include/linux/gpio/driver.h:888:40: error: 'child' undeclared (first use in this function)
     888 |         return fwnode_property_present(child, "gpio-controller");
         |                                        ^~~~~
   include/linux/gpio/driver.h:888:40: note: each undeclared identifier is reported only once for each function it appears in


vim +/child +888 include/linux/gpio/driver.h

   885	
   886	static inline bool fwnode_is_gpiochip(struct fwnode_handle *fwnode)
   887	{
 > 888		return fwnode_property_present(child, "gpio-controller");
   889	}
   890	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-08-30 21:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24  7:42 [PATCH v1 0/4] gpio: Unify the GPIO controller node check Andy Shevchenko
2026-08-24  7:42 ` [PATCH v1 1/4] gpio: Split fwnode_is_gpiochip() helper Andy Shevchenko
2026-08-24  7:42 ` [PATCH v1 2/4] gpio: shared: Replace open coded fwnode_is_gpiochip() Andy Shevchenko
2026-08-24  8:37   ` Andy Shevchenko
2026-08-24  7:42 ` [PATCH v1 3/4] pinctrl: ma35: " Andy Shevchenko
2026-08-24  7:42 ` [PATCH v1 4/4] pinctrl: pistachio: " Andy Shevchenko
2026-08-30 14:57   ` kernel test robot
2026-08-30 19:31   ` kernel test robot
2026-08-30 21:13   ` kernel test robot
2026-08-26 10:33 ` [PATCH v1 0/4] gpio: Unify the GPIO controller node check Bartosz Golaszewski
2026-08-26 14:00   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox