From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Aaro Koskinen <aaro.koskinen@iki.fi>,
Janusz Krzysztofik <jmkrzyszt@gmail.com>,
Tony Lindgren <tony@atomide.com>,
Russell King <linux@armlinux.org.uk>,
Hans de Goede <hansg@kernel.org>,
Linux-OMAP <linux-omap@vger.kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <brgl@kernel.org>
Subject: Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
Date: Wed, 11 Feb 2026 13:40:44 -0800 [thread overview]
Message-ID: <aYz2_pE53G67vv0v@google.com> (raw)
In-Reply-To: <213b82de-fee8-4ebf-a8ee-d8ca783ce403@app.fastmail.com>
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@oss.qualcomm.com>
> > ---
>
> 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@gmail.com>
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@gmail.com>
---
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);
next prev parent reply other threads:[~2026-02-11 21:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 13:13 [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770 Bartosz Golaszewski
2026-02-11 13:19 ` Bartosz Golaszewski
2026-02-11 16:31 ` Arnd Bergmann
2026-02-11 21:40 ` Dmitry Torokhov [this message]
2026-02-12 1:12 ` Dmitry Torokhov
2026-02-12 6:57 ` Arnd Bergmann
2026-02-12 11:40 ` Bartosz Golaszewski
2026-02-12 11:45 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aYz2_pE53G67vv0v@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=aaro.koskinen@iki.fi \
--cc=arnd@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=hansg@kernel.org \
--cc=jmkrzyszt@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.