diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2026-02-14 05:52:44 +0300 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2026-03-02 14:13:43 +0300 |
| commit | 0fc434bc2c45fceb9356f2138911db0f454b8ca6 (patch) | |
| tree | a901a96a37ba4ee855ab54027f4d305e31e2b308 /drivers | |
| parent | 94798081732abfb5748471d5c3cced6ff187fa36 (diff) | |
| download | linux-0fc434bc2c45fceb9356f2138911db0f454b8ca6.tar.xz | |
driver core: platform: allow attaching software nodes when creating devices
Extend platform_device_info structure with an 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.
This reduces boilerplate needed when switching legacy board code to
static device properties/GPIO references.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260214025246.2095239-3-dmitry.torokhov@gmail.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/base/platform.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index b45d41b018ca..ec467ccd05b3 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -850,6 +850,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); @@ -875,7 +878,11 @@ struct platform_device *platform_device_register_full( 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) |
