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

From: Bartosz Golaszewski

Date: Fri Nov 20 2026 - 07:46:59 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 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: d785d132202e8e8e93335ebf74ad5b29fca0951f
change-id: 20260916-fwnode-for-each-prop-d7a6f90e7338
prerequisite-message-id: <cover.1794667407.git.alx@xxxxxxxxxx>
prerequisite-patch-id: d3e70dd6d3b14266595580dd0a45f358ed227c2c
prerequisite-patch-id: e0431bc18c6ad9be618368f3b128a6146b11c761
prerequisite-patch-id: 62b224f17ce0f2e68e8963de1180d9764dd24fe1
prerequisite-patch-id: 49110713d1b10ae2972ae738da383215d9be001b
prerequisite-patch-id: 97bf1ce8e594218715d5df30711d0523c7f07bc5
prerequisite-patch-id: 7099f0089dde47dad6548bc2dae7accc71737f84
prerequisite-patch-id: a0c5781fec5351c5e90d1edcd4b4faedd4079e14
prerequisite-patch-id: ea193b5da63539c30bb889caacc564202d335c66
prerequisite-patch-id: 0166cdc28724d37e716e5506b1c7865acc764e66
prerequisite-patch-id: c35ed24ac570ec685c6ede5cff80b9b140bd09b9
prerequisite-patch-id: e38e553067efe98f8c6352ce378e8de9e3491379
prerequisite-patch-id: e7d3995c1e740354072278a4f700da1848bf2d4f
prerequisite-patch-id: 5d211c7ce1cbfdf9fc8a7a6432989194f9f6dac1
prerequisite-patch-id: 6708d2610b6972e7f8f505492f341d4c0a7bb476
prerequisite-patch-id: 8e386ca3fa87881fa6cf0f00bfda37542eff8141
prerequisite-patch-id: a00aefd04979c68dfa7ae79dc8c4cec5593ca732
prerequisite-patch-id: 5a46d25bb0e28eae712b6ea6bd0fa247a79e0365
prerequisite-patch-id: 02fa7159f2a7660dc7b48138fd48e929c56cc9ae
prerequisite-patch-id: ba05aa979cc564730fdb522e1297a7ff9636cdd1

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