[PATCH v2 00/10] gpio: make gpiolib-shared more fwnode-centric

From: Bartosz Golaszewski

Date: Fri Nov 13 2026 - 14:44:18 EST


Currently the code in gpiolib-shared.c only supports OF nodes and uses a
lot of OF-specific APIs. This series attempts to make the code more
generic, ahead of extending support for sharing GPIOs to other types of
firmware nodes, by defining two new fwnode operations, implementing them
for OF nodes and using them in GPIOLIB in order to limit the OF-specific
API usage to only a few places guarded by ifdefs.

The new fwnode APIs are:
a) property_get_names() - this closes the gap between OF nodes and
fwnodes: OF nodes allow users to iterate over all properties while
fwnodes don't advertise all properties in any way at the moment
b) count_references() - there's currently no way of counting references
in an fwnode reliably: using fwnode_property_get_reference_args()
does not work for empty references (e.g.: phandle = <0>, <&foo 1 2>;)

The first patch adds a CLASS() for string arrays. The following 6 define
and implement new fwnode operations. The final patch generalizes the code
in gpiolib-shared.c.

Merging strategy: patches 1-8 should go through the driver core tree and
be provided on an immutable branch to me so that I can pull it and queue
the final 2 patches via the GPIO tree.

This series depends on the series from Alejandro Colomar adding
strprefix() as indicated in the b4 tracking.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
---
Changes in v2:
- Integrate the series from from Alejandro Colomar adding strprefix() into
this series as a b4 dependency
- Reuse the existing struct strarray in the new CLASS() for string
arrays
- Make sure that props != NULL in fwnode_property_get_names()
- Replace string.h with string_helpers.h instead of including both
- Tweak the kerneldocs (Andy)
- Use size_add() from overflow.h
- Mark gpio_shared_fwnode_traverse() as __maybe_unused for !CONFIG_OF
- Return early in the OF variant of fwnode_property_get_names() if no
properties are defined
- Add commit removing unused leftover code
- Remove useless alias variables
- Link to v1: https://patch.msgid.link/20261104-fwnode-for-each-prop-v1-0-6e28fe1c72c4@xxxxxxxxxxxxxxxx

---
Bartosz Golaszewski (10):
lib: string_helpers: export and rename struct strarray
lib: string_helpers: implement a CLASS() for string arrays
fwnode: define the property_get_names() operation
device property: provide fwnode_property_get_names()
of: property: implement the .property_get_names() fwnode operation
fwnode: define the count_references() fwnode operation
device property: provide fwnode_property_count_references()
of: property: implement the count_references() fwnode operation
gpio: shared: removed unused field from struct gpio_shared_entry
gpio: shared: generalize most code to firmware nodes

drivers/base/property.c | 115 +++++++++++++++++++-
drivers/gpio/gpiolib-shared.c | 242 ++++++++++++++++++++++-------------------
drivers/of/property.c | 41 ++++++-
include/linux/fwnode.h | 15 +++
include/linux/property.h | 4 +
include/linux/string_helpers.h | 12 ++
lib/string_helpers.c | 9 +-
7 files changed, 315 insertions(+), 123 deletions(-)
---
base-commit: 161837d37055642b03475137461d4438c65dbddf
change-id: 20260916-fwnode-for-each-prop-d7a6f90e7338
prerequisite-message-id: <cover.1794574496.git.alx@xxxxxxxxxx>
prerequisite-patch-id: 6c8ea11afdfadea1c72457e460596f9140195f8a
prerequisite-patch-id: 81834766a605fc75e62501a8459944c87aa7848e
prerequisite-patch-id: 49110713d1b10ae2972ae738da383215d9be001b
prerequisite-patch-id: 97bf1ce8e594218715d5df30711d0523c7f07bc5
prerequisite-patch-id: c94cdf0377763fbdcb942add8a058161503f9024
prerequisite-patch-id: d0e6af689d680619ee07aabb50635328052bc9af
prerequisite-patch-id: 1006c25c87a8e46129fdba68822b9592c3f5e0e9

Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>