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

From: Bartosz Golaszewski

Date: Thu Nov 26 2026 - 04:36:34 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 v4:
- Rebase on a smaller bugfix subset of Alejandro's series and go back to
using strends() instead of the proposed strsuffix() which doesn't
cause problems ATM
- Pick up more R-b tags
- Link to v3: https://patch.msgid.link/20261120-fwnode-for-each-prop-v3-0-808e304dc73e@xxxxxxxxxxxxxxxx

Changes in v3:
- Rebase on top of v6 of the strprefix() series
- Initialize variables managed with __free() at declaration (Sashiko)
- Unuglyfy the usage of IS_ENABLED(CONFIG_OF) (Andy)
- Pick up tags
- Link to v2: https://patch.msgid.link/20261113-fwnode-for-each-prop-v2-0-4edc23d5cf50@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: remove 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 | 239 +++++++++++++++++++++--------------------
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, 312 insertions(+), 123 deletions(-)
---
base-commit: 47588e4c16d8876d3058bcec030ed8a016794b9e
change-id: 20260916-fwnode-for-each-prop-d7a6f90e7338
prerequisite-message-id: <cover.1795639368.git.alx@xxxxxxxxxx>
prerequisite-patch-id: 82777ef50a2bc99b1e6f163a2dfcb795093d391f
prerequisite-patch-id: f2667cbc4cf347427b2dccb23e19aefff373b3de
prerequisite-patch-id: 62b224f17ce0f2e68e8963de1180d9764dd24fe1
prerequisite-patch-id: 49110713d1b10ae2972ae738da383215d9be001b

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