Re: [PATCH v3 03/10] software node: allow referencing firmware nodes

From: Philipp Zabel

Date: Wed Oct 29 2025 - 08:51:38 EST


On Mi, 2025-10-29 at 13:28 +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
>
> At the moment software nodes can only reference other software nodes.
> This is a limitation for devices created, for instance, on the auxiliary
> bus with a dynamic software node attached which cannot reference devices
> the firmware node of which is "real" (as an OF node or otherwise).
>
> Make it possible for a software node to reference all firmware nodes in
> addition to static software nodes. To that end: add a second pointer to
> struct software_node_ref_args of type struct fwnode_handle. The core
> swnode code will first check the swnode pointer and if it's NULL, it
> will assume the fwnode pointer should be set. Rework the helper macros
> and deprecate the existing ones whose names don't indicate the reference
> type.
>
> Software node graphs remain the same, as in: the remote endpoints still
> have to be software nodes.
>
> Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> ---
> drivers/base/swnode.c | 13 +++++++++++--
> include/linux/property.h | 38 +++++++++++++++++++++++++++++++-------
> 2 files changed, 42 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> index b7c3926b67be72671ba4e4c442b3acca80688cf7..8601d1612be31febb6abbbe1fb35228499480c56 100644
> --- a/drivers/base/swnode.c
> +++ b/drivers/base/swnode.c
> @@ -535,7 +535,13 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
> ref_array = prop->pointer;
> ref = &ref_array[index];
>
> - refnode = software_node_fwnode(ref->node);
> + if (ref->swnode)
> + refnode = software_node_fwnode(ref->swnode);

software_node_fwnode(ref->swnode) never returns NULL if given a non-
NULL parameter.

> + else if (ref->fwnode)
> + refnode = ref->fwnode;
> + else
> + return -EINVAL;
> +
> if (!refnode)
> return -ENOENT;

So this check is not needed anymore.

regards
Philipp