diff mbox series

[v2,3/7] gpiolib: of: return -ENOENT from of_gpio_count() stub

Message ID 20261103-b4-gpiolib-free-v2-3-ea46767c9cf8@gmail.com
State New
Headers show
Series gpiolib: scope-based management and cleanup for GPIO descriptor arrays | expand

Commit Message

Dmitry Torokhov Nov. 4, 2026, 3:40 a.m. UTC
gpiod_count() and its firmware backends are expected to return either a
positive number of GPIOs or a negative error code (-ENOENT) when no
GPIOs are assigned. However, the !CONFIG_OF_GPIO stub for
of_gpio_count() returns 0 instead of -ENOENT. This causes gpiod_count()
to skip the platform_gpio_count() fallback (which triggers when
count < 0) and erroneously return 0 to callers.

Change the stub to return -ENOENT to match the real of_gpio_count()
implementation and the other error-returning stubs in gpiolib-of.h.

Fixes: f626d6dfb709 ("gpio: of: Break out OF-only code")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andy Shevchenko Nov. 4, 2026, 12:07 p.m. UTC | #1
On Tue, Nov 03, 2026 at 07:40:31PM -0800, Dmitry Torokhov wrote:
> gpiod_count() and its firmware backends are expected to return either a
> positive number of GPIOs or a negative error code (-ENOENT) when no
> GPIOs are assigned. However, the !CONFIG_OF_GPIO stub for
> of_gpio_count() returns 0 instead of -ENOENT. This causes gpiod_count()
> to skip the platform_gpio_count() fallback (which triggers when
> count < 0) and erroneously return 0 to callers.
> 
> Change the stub to return -ENOENT to match the real of_gpio_count()
> implementation and the other error-returning stubs in gpiolib-of.h.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h
index 218cfe5bc4ac..9ca540d93f93 100644
--- a/drivers/gpio/gpiolib-of.h
+++ b/drivers/gpio/gpiolib-of.h
@@ -46,7 +46,7 @@  static inline bool of_gpiochip_instance_match(struct gpio_chip *gc,
 static inline int of_gpio_count(const struct fwnode_handle *fwnode,
 				const char *con_id)
 {
-	return 0;
+	return -ENOENT;
 }
 static inline int of_gpiochip_get_lflags(struct gpio_chip *chip,
 					 struct fwnode_reference_args *gpiospec,