Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770

From: Dmitry Torokhov

Date: Wed Feb 11 2026 - 16:41:16 EST


On Wed, Feb 11, 2026 at 05:31:52PM +0100, Arnd Bergmann wrote:
> On Wed, Feb 11, 2026, at 14:13, Bartosz Golaszewski wrote:
> > Currently the board file for Nokia 770 creates dummy software nodes not
> > attached in any way to the actual GPIO controller devices and uses the
> > fact that GPIOLIB matching swnode's name to the GPIO chip's label during
> > software node lookup. This behavior is wrong and we want to remove it.
> > To that end, we need to first convert all existing users to creating
> > actual fwnode links.
> >
> > Create real software nodes for GPIO controllers on OMAP16xx and
> > reference them from the software nodes in the nokia board file.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> > ---
>
> I don't see mistakes here, and I don't want to throw a wrench in
> this patch, but I wonder if there is a way to take this one step further:
>
> > @@ -244,6 +263,14 @@ static int __init omap16xx_gpio_init(void)
> > iounmap(base);
> >
> > platform_device_register(omap16xx_gpio_dev[i]);
> > +
> > + ret = device_add_software_node(&omap16xx_gpio_dev[i]->dev,
> > + omap16xx_gpio_swnodes[i]);
> > +
> > + if (ret) {
> > + dev_err(&pdev->dev, "Failed to add software node.\n");
> > + return ret;
> > + }
>
> I was planning to go through the remaining 'static struct platform_device'
> definitions in arch/arm/ after the planned board file removal and
> try to convert these to 'platform_device_info' or similar, using
> platform_device_register_full(). Since that function already contains
> code to dynamically allocate the software_node, I had hoped that
> a lot of this would just go away.
>
> However, I see that your patch creates pointers to those software_node
> instances, so think that would become a bit harder, but I have not
> actually tried it.
>
> Do you know if there is a good way to do this without using static
> platform devices?

I wonder if something like below will help reducing boilerplate...

Thanks.

--
Dmitry


driver core: platform: allow attaching software nodes when creating devices

From: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>

Extend platform_device_info structure with ian optional pointer to a
software node to be used as a secondary firmware node for the device
being created. If software node has not been registered yet it will be
automatically registered.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/base/platform.c | 15 ++++++++++-----
include/linux/platform_device.h | 23 ++++++++++++-----------
2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 09450349cf32..2abacdf714d6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -809,6 +809,9 @@ struct platform_device *platform_device_register_full(
int ret;
struct platform_device *pdev;

+ if (pdevinfo->swnode && pdevinfo->properties)
+ return ERR_PTR(-EINVAL);
+
pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
if (!pdev)
return ERR_PTR(-ENOMEM);
@@ -824,17 +827,19 @@ struct platform_device *platform_device_register_full(
pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
}

- ret = platform_device_add_resources(pdev,
- pdevinfo->res, pdevinfo->num_res);
+ ret = platform_device_add_resources(pdev, pdevinfo->res, pdevinfo->num_res);
if (ret)
goto err;

- ret = platform_device_add_data(pdev,
- pdevinfo->data, pdevinfo->size_data);
+ ret = platform_device_add_data(pdev, pdevinfo->data, pdevinfo->size_data);
if (ret)
goto err;

- if (pdevinfo->properties) {
+ if (pdevinfo->swnode) {
+ ret = device_add_software_node(&pdev->dev, pdevinfo->swnode);
+ if (ret)
+ goto err;
+ } else if (pdevinfo->properties) {
ret = device_create_managed_software_node(&pdev->dev,
pdevinfo->properties, NULL);
if (ret)
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 074754c23d33..ef5b882d08e0 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -117,21 +117,22 @@ extern int platform_get_irq_byname_optional(struct platform_device *dev,
extern int platform_add_devices(struct platform_device **, int);

struct platform_device_info {
- struct device *parent;
- struct fwnode_handle *fwnode;
- bool of_node_reused;
+ struct device *parent;
+ struct fwnode_handle *fwnode;
+ bool of_node_reused;

- const char *name;
- int id;
+ const char *name;
+ int id;

- const struct resource *res;
- unsigned int num_res;
+ const struct resource *res;
+ unsigned int num_res;

- const void *data;
- size_t size_data;
- u64 dma_mask;
+ const void *data;
+ size_t size_data;
+ u64 dma_mask;

- const struct property_entry *properties;
+ const struct software_node *swnode;
+ const struct property_entry *properties;
};
extern struct platform_device *platform_device_register_full(
const struct platform_device_info *pdevinfo);