* [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node
@ 2026-07-06 12:44 Bartosz Golaszewski
2026-07-06 12:44 ` [PATCH v3 01/20] powerpc/powermac: fix OF node refcount Bartosz Golaszewski
` (19 more replies)
0 siblings, 20 replies; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski, stable,
Manuel Ebner, Wolfram Sang, Konrad Dybcio
Platform device core provides helper interfaces for dealing with
dynamically created platform devices. Most users should use
platform_device_register_full() which encapsulates most of the
operations but some modules will want to use the split approach of
calling platform_device_alloc() + platform_device_add() separately for
various reasons.
With many platform devices now using dynamic software nodes as their
primary firmware nodes and with the platform device interface being
extended to also better cover the use-cases of secondary software nodes,
I believe it makes sense to switch to counting the references of all
kinds of firmware nodes.
To that end, I identified all users of platform_device_alloc() that also
assign dev.of_node or dev.fwnode manually. I noticed five cases where
the references are not increased as they should (patches 1-5 fix these
users) and provided three new functions in platform_device.h that now
become the preferred interfaces for assigning firmware nodes to dynamic
platform devices (in line with platform_device_add_data(),
platform_device_add_resources(), etc.). The bulk of the patches in this
series are small driver conversions to port all users to going through
the new functions that now encapsulate the refcount logic. With that
done, the final patch seamlessly switches to counting the references of
all firmware node types.
This effort is prerequisite of removing platform_device_release_full()
and unifying the release path for dynamic platform devices using
unmanaged software nodes.
Merging strategy: The entire series should go through the driver core
tree, possibly with an immutable branch provided to solve any potential
conflicts though these are rather unlikely.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v3:
- Use device_set_node() where applicable
- Use __free(device_node) in fsl iommu driver
- Don't use __free() where not really required
- Add a patch updating the kerneldoc for platform_device_alloc()
- Collect more tags
- Link to v2: https://patch.msgid.link/20260629-pdev-fwnode-ref-v2-0-8abe2513f96e@oss.qualcomm.com
Changes in v2:
- Rebased on top of v7.2-rc1, dropped applied patches, collected tags
- Link to v1: https://patch.msgid.link/20260521-pdev-fwnode-ref-v1-0-88c324a1b8d2@oss.qualcomm.com
---
Bartosz Golaszewski (20):
powerpc/powermac: fix OF node refcount
driver core: platform: provide platform_device_set_of_node()
driver core: platform: provide platform_device_set_fwnode()
driver core: platform: provide platform_device_set_of_node_from_dev()
driver core: update kerneldoc for platform_device_alloc()
of: platform: use platform_device_set_of_node()
powerpc/powermac: use platform_device_set_of_node()
i2c: pxa-pci: use platform_device_set_of_node()
iommu/fsl: use platform_device_set_of_node()
net: bcmgenet: use platform_device_set_of_node()
pmdomain: imx: use platform_device_set_of_node()
mfd: tps6586: use platform_device_set_of_node()
slimbus: qcom-ngd-ctrl: use platform_device_set_of_node()
net: mv643xx: use platform_device_set_of_node()
drm/xe/i2c: use platform_device_set_fwnode()
platform/surface: gpe: use platform_device_set_fwnode()
usb: chipidea: use platform_device_set_of_node_from_dev()
usb: musb: use platform_device_set_of_node_from_dev()
reset: rzg2l: use platform_device_set_of_node_from_dev()
driver core: platform: count references to all kinds of firmware nodes
arch/powerpc/platforms/powermac/low_i2c.c | 2 +-
drivers/base/platform.c | 61 ++++++++++++++++++++++++++--
drivers/gpu/drm/xe/xe_i2c.c | 2 +-
drivers/i2c/busses/i2c-pxa-pci.c | 3 +-
drivers/iommu/fsl_pamu.c | 16 +++-----
drivers/mfd/tps6586x.c | 2 +-
drivers/net/ethernet/broadcom/genet/bcmmii.c | 3 +-
drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +-
drivers/of/platform.c | 2 +-
drivers/platform/surface/surface_gpe.c | 2 +-
drivers/pmdomain/imx/gpc.c | 3 +-
drivers/reset/reset-rzg2l-usbphy-ctrl.c | 2 +-
drivers/slimbus/qcom-ngd-ctrl.c | 2 +-
drivers/usb/chipidea/core.c | 2 +-
drivers/usb/musb/jz4740.c | 2 +-
include/linux/platform_device.h | 9 ++++
16 files changed, 88 insertions(+), 27 deletions(-)
---
base-commit: 8cdeaa50eae8dad34885515f62559ee83e7e8dda
change-id: 20260520-pdev-fwnode-ref-d867836971eb
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v3 01/20] powerpc/powermac: fix OF node refcount
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
` (18 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski, stable
Platform devices created with platform_device_alloc() call
platform_device_release() when the last reference to the device's
kobject is dropped. This function calls of_node_put() unconditionally.
This works fine for devices created with platform_device_register_full()
but users of the split approach (platform_device_alloc() +
platform_device_add()) must bump the reference of the of_node they
assign manually. Add the missing call to of_node_get().
Cc: stable@vger.kernel.org
Fixes: 81e5d8646ff6 ("i2c/powermac: Register i2c devices from device-tree")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
arch/powerpc/platforms/powermac/low_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index da72a30ab8657e6dc7e6f3437af612155783d8f9..973f58771d9636605ed5d3e91b45008543b584d3 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -1471,7 +1471,7 @@ static int __init pmac_i2c_create_platform_devices(void)
if (bus->platform_dev == NULL)
return -ENOMEM;
bus->platform_dev->dev.platform_data = bus;
- bus->platform_dev->dev.of_node = bus->busnode;
+ bus->platform_dev->dev.of_node = of_node_get(bus->busnode);
platform_device_add(bus->platform_dev);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
2026-07-06 12:44 ` [PATCH v3 01/20] powerpc/powermac: fix OF node refcount Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-06 14:39 ` Manuel Ebner
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode() Bartosz Golaszewski
` (17 subsequent siblings)
19 siblings, 2 replies; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski, Manuel Ebner
Encapsulate the reference counting logic for OF nodes assigned to
platform devices created with platform_device_alloc() in a helper
function. Make the kerneldoc state that this is the proper interface for
assigning OF nodes to dynamically allocated platform devices. This will
allow us to switch to counting the references of the device's firmware
nodes, not only the OF nodes.
Reviewed-by: Manuel Ebner <manuelebner@mailbox.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/base/platform.c | 18 ++++++++++++++++++
include/linux/platform_device.h | 4 ++++
2 files changed, 22 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index fb9120b0bcfe0e7dd9dfc0d29b91e0ad40a01440..3188d5aba5f90622f821c695049cacda030204fb 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -693,6 +693,24 @@ int platform_device_add_data(struct platform_device *pdev, const void *data,
}
EXPORT_SYMBOL_GPL(platform_device_add_data);
+/**
+ * platform_device_set_of_node - assign an OF node to device
+ * @pdev: platform device to add the node for
+ * @np: new device node
+ *
+ * Assign an OF node to this platform device. Internally keep track of the
+ * reference count. Devices created with platform_device_alloc() must use this
+ * function instead of assigning the node manually.
+ */
+void platform_device_set_of_node(struct platform_device *pdev,
+ struct device_node *np)
+{
+ of_node_put(pdev->dev.of_node);
+ pdev->dev.of_node = of_node_get(np);
+ pdev->dev.fwnode = of_fwnode_handle(np);
+}
+EXPORT_SYMBOL_GPL(platform_device_set_of_node);
+
/**
* platform_device_add - add a platform device to device hierarchy
* @pdev: platform device we're adding
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 8c566f09d04efe420d85ffa046f92c44c6d08526..e9f7baceeb4c8269dbc0143c4d8fc9d73ba024ca 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -19,6 +19,8 @@
struct irq_affinity;
struct mfd_cell;
struct property_entry;
+struct platform_device_id;
+struct device_node;
struct platform_device {
const char *name;
@@ -262,6 +264,8 @@ extern int platform_device_add_resources(struct platform_device *pdev,
unsigned int num);
extern int platform_device_add_data(struct platform_device *pdev,
const void *data, size_t size);
+void platform_device_set_of_node(struct platform_device *pdev,
+ struct device_node *np);
extern int platform_device_add(struct platform_device *pdev);
extern void platform_device_del(struct platform_device *pdev);
extern void platform_device_put(struct platform_device *pdev);
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
2026-07-06 12:44 ` [PATCH v3 01/20] powerpc/powermac: fix OF node refcount Bartosz Golaszewski
2026-07-06 12:44 ` [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev() Bartosz Golaszewski
` (16 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Provide a helper function encapsulating the logic of assigning firmware
nodes to platform devices created with platform_device_alloc(). Make the
kerneldoc state that this is the proper interface for assigning firmware
nodes to dynamically allocated platform devices. This will allow us to
switch to counting the references of the device's firmware nodes in the
future, not only the OF nodes.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/base/platform.c | 19 +++++++++++++++++++
include/linux/platform_device.h | 3 +++
2 files changed, 22 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3188d5aba5f90622f821c695049cacda030204fb..6520b70cf3052d683a2ecb1a0dd7227575546ba0 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -711,6 +711,25 @@ void platform_device_set_of_node(struct platform_device *pdev,
}
EXPORT_SYMBOL_GPL(platform_device_set_of_node);
+/**
+ * platform_device_set_fwnode - assign a firmware node to device
+ * @pdev: platform device to set the node for
+ * @fwnode: new firmware node
+ *
+ * Assign a firmware node to this platform device. Internally keep track of the
+ * reference count. Devices created with platform_device_alloc() must use this
+ * function instead of assigning the node manually.
+ */
+void platform_device_set_fwnode(struct platform_device *pdev,
+ struct fwnode_handle *fwnode)
+{
+ if (is_of_node(fwnode))
+ platform_device_set_of_node(pdev, to_of_node(fwnode));
+ else
+ pdev->dev.fwnode = fwnode;
+}
+EXPORT_SYMBOL_GPL(platform_device_set_fwnode);
+
/**
* platform_device_add - add a platform device to device hierarchy
* @pdev: platform device we're adding
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index e9f7baceeb4c8269dbc0143c4d8fc9d73ba024ca..f037e4101c41dfdbf628d013348d7149ac519721 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -21,6 +21,7 @@ struct mfd_cell;
struct property_entry;
struct platform_device_id;
struct device_node;
+struct fwnode_handle;
struct platform_device {
const char *name;
@@ -266,6 +267,8 @@ extern int platform_device_add_data(struct platform_device *pdev,
const void *data, size_t size);
void platform_device_set_of_node(struct platform_device *pdev,
struct device_node *np);
+void platform_device_set_fwnode(struct platform_device *pdev,
+ struct fwnode_handle *fwnode);
extern int platform_device_add(struct platform_device *pdev);
extern void platform_device_del(struct platform_device *pdev);
extern void platform_device_put(struct platform_device *pdev);
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (2 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode() Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc() Bartosz Golaszewski
` (15 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Provide a platform-specific variant of device_set_of_node_from_dev(). In
addition to bumping the reference count of the OF node being assigned,
it also assigns the fwnode of the platform device.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/base/platform.c | 16 ++++++++++++++++
include/linux/platform_device.h | 2 ++
2 files changed, 18 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6520b70cf3052d683a2ecb1a0dd7227575546ba0..f24a5f406746b53ca9eaab9472f6dd1345e04ad6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -730,6 +730,22 @@ void platform_device_set_fwnode(struct platform_device *pdev,
}
EXPORT_SYMBOL_GPL(platform_device_set_fwnode);
+/**
+ * platform_device_set_of_node_from_dev - reuse OF node of another device
+ * @pdev: platform device to set the node for
+ * @dev2: device whose OF node to reuse
+ *
+ * Reuses the OF node of another device in this platform device while
+ * internally keeping track of reference counting.
+ */
+void platform_device_set_of_node_from_dev(struct platform_device *pdev,
+ const struct device *dev2)
+{
+ device_set_of_node_from_dev(&pdev->dev, dev2);
+ pdev->dev.fwnode = of_fwnode_handle(pdev->dev.of_node);
+}
+EXPORT_SYMBOL_GPL(platform_device_set_of_node_from_dev);
+
/**
* platform_device_add - add a platform device to device hierarchy
* @pdev: platform device we're adding
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index f037e4101c41dfdbf628d013348d7149ac519721..5333237ec58f30aecb05a3e160c7704fa07a0490 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -269,6 +269,8 @@ void platform_device_set_of_node(struct platform_device *pdev,
struct device_node *np);
void platform_device_set_fwnode(struct platform_device *pdev,
struct fwnode_handle *fwnode);
+void platform_device_set_of_node_from_dev(struct platform_device *pdev,
+ const struct device *dev2);
extern int platform_device_add(struct platform_device *pdev);
extern void platform_device_del(struct platform_device *pdev);
extern void platform_device_put(struct platform_device *pdev);
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (3 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev() Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-07 16:05 ` Andy Shevchenko
2026-07-06 12:44 ` [PATCH v3 06/20] of: platform: use platform_device_set_of_node() Bartosz Golaszewski
` (14 subsequent siblings)
19 siblings, 2 replies; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski, Manuel Ebner
Users of platform_device_alloc() + platform_device_add() must not modify
certain fields of the dynamically created platform device object. Update
the kernel doc to say which fields are affected and which functions to
use.
Suggested-by: Manuel Ebner <manuelebner@mailbox.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/base/platform.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f24a5f406746b53ca9eaab9472f6dd1345e04ad6..9357942d0c79b032645035879b2bed3d53305b9f 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -619,6 +619,13 @@ static void platform_device_release_full(struct device *dev)
*
* Create a platform device object which can have other objects attached
* to it, and which will have attached objects freed when it is released.
+ *
+ * The following fields of the dynamically allocated platform device must not
+ * be modified manually: resource, num_resources, dev.platform_data,
+ * dev.of_node and dev.fwnode. Users wishing to do the split platform device
+ * registration with platform_device_alloc() + platform_device_add() are
+ * required to use dedicated helpers for adding resources, platform data or
+ * assigning firmware nodes.
*/
struct platform_device *platform_device_alloc(const char *name, int id)
{
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 06/20] of: platform: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (4 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc() Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 07/20] powerpc/powermac: " Bartosz Golaszewski
` (13 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/of/platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 53bca8c6f7810ce2235b4d084a361626b1d2da33..8b1e7640778253492c080085b4015e1423389d83 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -126,7 +126,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
}
/* setup generic device info */
- device_set_node(&dev->dev, of_fwnode_handle(of_node_get(np)));
+ platform_device_set_of_node(dev, np);
dev->dev.parent = parent ? : &platform_bus;
if (bus_id)
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 07/20] powerpc/powermac: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (5 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 06/20] of: platform: use platform_device_set_of_node() Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 08/20] i2c: pxa-pci: " Bartosz Golaszewski
` (12 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
arch/powerpc/platforms/powermac/low_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index 973f58771d9636605ed5d3e91b45008543b584d3..a175a32a222bab4cc7400f6ab6071f5630db2cb8 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -1471,7 +1471,7 @@ static int __init pmac_i2c_create_platform_devices(void)
if (bus->platform_dev == NULL)
return -ENOMEM;
bus->platform_dev->dev.platform_data = bus;
- bus->platform_dev->dev.of_node = of_node_get(bus->busnode);
+ platform_device_set_of_node(bus->platform_dev, bus->busnode);
platform_device_add(bus->platform_dev);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 08/20] i2c: pxa-pci: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (6 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 07/20] powerpc/powermac: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 09/20] iommu/fsl: " Bartosz Golaszewski
` (11 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski, Wolfram Sang
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Acked-by: Andi Shyti <andi.shyti@kernel.org>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> # for I2C
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-pxa-pci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
index dbd542300f80043c6bc65a69fa27ca7b3d5fe787..92a0647f08c69f841ca99caca757c1728b3f6fce 100644
--- a/drivers/i2c/busses/i2c-pxa-pci.c
+++ b/drivers/i2c/busses/i2c-pxa-pci.c
@@ -76,7 +76,8 @@ static struct platform_device *add_i2c_device(struct pci_dev *dev, int bar)
goto out;
}
pdev->dev.parent = &dev->dev;
- pdev->dev.of_node = child;
+
+ platform_device_set_of_node(pdev, child);
ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
if (ret)
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 09/20] iommu/fsl: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (7 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 08/20] i2c: pxa-pci: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-06 14:51 ` Frank Li
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 10/20] net: bcmgenet: " Bartosz Golaszewski
` (10 subsequent siblings)
19 siblings, 2 replies; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Acked-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/iommu/fsl_pamu.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
index 25aa477a95a95cb4fa4e132727cde0a936750ee2..c83bbc3faad56d6ee1c89b0a7f74028af02c81e9 100644
--- a/drivers/iommu/fsl_pamu.c
+++ b/drivers/iommu/fsl_pamu.c
@@ -8,6 +8,7 @@
#include "fsl_pamu.h"
+#include <linux/cleanup.h>
#include <linux/fsl/guts.h>
#include <linux/interrupt.h>
#include <linux/genalloc.h>
@@ -933,7 +934,6 @@ static struct platform_driver fsl_of_pamu_driver = {
static __init int fsl_pamu_init(void)
{
struct platform_device *pdev = NULL;
- struct device_node *np;
int ret;
/*
@@ -955,7 +955,8 @@ static __init int fsl_pamu_init(void)
* PAMU node would require significant changes to a lot of code.
*/
- np = of_find_compatible_node(NULL, NULL, "fsl,pamu");
+ struct device_node *np __free(device_node) =
+ of_find_compatible_node(NULL, NULL, "fsl,pamu");
if (!np) {
pr_err("could not find a PAMU node\n");
return -ENODEV;
@@ -964,7 +965,7 @@ static __init int fsl_pamu_init(void)
ret = platform_driver_register(&fsl_of_pamu_driver);
if (ret) {
pr_err("could not register driver (err=%i)\n", ret);
- goto error_driver_register;
+ return ret;
}
pdev = platform_device_alloc("fsl-of-pamu", 0);
@@ -973,7 +974,8 @@ static __init int fsl_pamu_init(void)
ret = -ENOMEM;
goto error_device_alloc;
}
- pdev->dev.of_node = of_node_get(np);
+
+ platform_device_set_of_node(pdev, np);
ret = pamu_domain_init();
if (ret)
@@ -988,17 +990,11 @@ static __init int fsl_pamu_init(void)
return 0;
error_device_add:
- of_node_put(pdev->dev.of_node);
- pdev->dev.of_node = NULL;
-
platform_device_put(pdev);
error_device_alloc:
platform_driver_unregister(&fsl_of_pamu_driver);
-error_driver_register:
- of_node_put(np);
-
return ret;
}
arch_initcall(fsl_pamu_init);
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 10/20] net: bcmgenet: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (8 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 09/20] iommu/fsl: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 11/20] pmdomain: imx: " Bartosz Golaszewski
` (9 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/net/ethernet/broadcom/genet/bcmmii.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index a4e0d5a682687533a1b034ccf56cdb363d6b7786..0f0dbabfaabbce3469de79af91d7731b8476709f 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -490,8 +490,9 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
/* Retain this platform_device pointer for later cleanup */
priv->mii_pdev = ppdev;
ppdev->dev.parent = &pdev->dev;
+
if (dn)
- ppdev->dev.of_node = bcmgenet_mii_of_find_mdio(priv);
+ platform_device_set_of_node(ppdev, bcmgenet_mii_of_find_mdio(priv));
else
ppd.phy_mask = ~0;
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 11/20] pmdomain: imx: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (9 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 10/20] net: bcmgenet: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 12/20] mfd: tps6586: " Bartosz Golaszewski
` (8 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/pmdomain/imx/gpc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
index 42e50c9b4fb9ffb96a20a462d4eb5168942a893c..abca5f449a226fbae4213926e1395c413160c950 100644
--- a/drivers/pmdomain/imx/gpc.c
+++ b/drivers/pmdomain/imx/gpc.c
@@ -487,8 +487,7 @@ static int imx_gpc_probe(struct platform_device *pdev)
domain->ipg_rate_mhz = ipg_rate_mhz;
pd_pdev->dev.parent = &pdev->dev;
- pd_pdev->dev.of_node = of_node_get(np);
- pd_pdev->dev.fwnode = of_fwnode_handle(np);
+ platform_device_set_of_node(pd_pdev, np);
ret = platform_device_add(pd_pdev);
if (ret) {
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 12/20] mfd: tps6586: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (10 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 11/20] pmdomain: imx: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 13/20] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
` (7 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Acked-by: Lee Jones <lee@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/mfd/tps6586x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index f5f805446603315ba76ce1fc501c908f1cec0d16..3cfd2f02b62f3cc370e0d970ec2643b638fd0fec 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -397,7 +397,7 @@ static int tps6586x_add_subdevs(struct tps6586x *tps6586x,
pdev->dev.parent = tps6586x->dev;
pdev->dev.platform_data = subdev->platform_data;
- pdev->dev.of_node = of_node_get(subdev->of_node);
+ platform_device_set_of_node(pdev, subdev->of_node);
ret = platform_device_add(pdev);
if (ret) {
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 13/20] slimbus: qcom-ngd-ctrl: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (11 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 12/20] mfd: tps6586: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 14/20] net: mv643xx: " Bartosz Golaszewski
` (6 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski, Konrad Dybcio
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Acked-by: Konrad Dybcio <konradybcio@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/slimbus/qcom-ngd-ctrl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index 3071e46d03beaaae2321e858c564b512c22e820e..6e89415712ce1a7a7781af6bd0eaf0d6879da52b 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -1539,7 +1539,7 @@ static int of_qcom_slim_ngd_register(struct device *parent,
kfree(ngd);
return ret;
}
- ngd->pdev->dev.of_node = of_node_get(node);
+ platform_device_set_of_node(ngd->pdev, node);
ctrl->ngd = ngd;
ret = platform_device_add(ngd->pdev);
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 14/20] net: mv643xx: use platform_device_set_of_node()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (12 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 13/20] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode() Bartosz Golaszewski
` (5 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Acked-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 1881583be5ce2e972fceb14c2b8348280c49ad1d..9caa1e47c174c9d7a161b7f2e2ee12a829b813d4 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2780,7 +2780,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
goto put_err;
}
ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
- ppdev->dev.of_node = of_node_get(pnp);
+ platform_device_set_of_node(ppdev, pnp);
ret = platform_device_add_resources(ppdev, &res, 1);
if (ret)
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (13 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 14/20] net: mv643xx: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 16/20] platform/surface: gpe: " Bartosz Golaszewski
` (4 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the firmware node for dynamically allocated
platform devices with the provided helper.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpu/drm/xe/xe_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
index 706783863d07d66b4685005d6649b3cd143ecc3b..af4ebd93ad8e68c95a14cdf99de0959fbe080354 100644
--- a/drivers/gpu/drm/xe/xe_i2c.c
+++ b/drivers/gpu/drm/xe/xe_i2c.c
@@ -123,7 +123,7 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
}
pdev->dev.parent = i2c->drm_dev;
- pdev->dev.fwnode = fwnode;
+ platform_device_set_fwnode(pdev, fwnode);
i2c->adapter_node = fwnode;
i2c->pdev = pdev;
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 16/20] platform/surface: gpe: use platform_device_set_fwnode()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (14 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode() Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 17/20] usb: chipidea: use platform_device_set_of_node_from_dev() Bartosz Golaszewski
` (3 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the firmware node for dynamically allocated
platform devices with the provided helper.
Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/platform/surface/surface_gpe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/surface/surface_gpe.c b/drivers/platform/surface/surface_gpe.c
index b359413903b13c4f8e8b284ef7ae6f6db3f47d72..40896a8544b0a4da4261ea881b1eaed62d93b32b 100644
--- a/drivers/platform/surface/surface_gpe.c
+++ b/drivers/platform/surface/surface_gpe.c
@@ -317,7 +317,7 @@ static int __init surface_gpe_init(void)
goto err_alloc;
}
- pdev->dev.fwnode = fwnode;
+ platform_device_set_fwnode(pdev, fwnode);
status = platform_device_add(pdev);
if (status)
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 17/20] usb: chipidea: use platform_device_set_of_node_from_dev()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (15 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 16/20] platform/surface: gpe: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 18/20] usb: musb: " Bartosz Golaszewski
` (2 subsequent siblings)
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node from another device for
dynamically allocated platform devices with the provided helper.
Acked-by: Peter Chen <peter.chen@kernel.org>
Link: https://lore.kernel.org/r/20211215225646.1997946-1-robh@kernel.org
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/usb/chipidea/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 07563be0013f4d28ed6318a0751670ccef01d0a5..7edc512cc37dc24551efe5fca172777a0a4b0766 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -879,7 +879,7 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,
}
pdev->dev.parent = dev;
- device_set_of_node_from_dev(&pdev->dev, dev);
+ platform_device_set_of_node_from_dev(pdev, dev);
ret = platform_device_add_resources(pdev, res, nres);
if (ret)
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 18/20] usb: musb: use platform_device_set_of_node_from_dev()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (16 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 17/20] usb: chipidea: use platform_device_set_of_node_from_dev() Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 19/20] reset: rzg2l: " Bartosz Golaszewski
2026-07-06 12:44 ` [PATCH v3 20/20] driver core: platform: count references to all kinds of firmware nodes Bartosz Golaszewski
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node from another device for
dynamically allocated platform devices with the provided helper.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/usb/musb/jz4740.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
index df56c972986f7c4f5174a227f35c7e1ac9afa7ca..c770ba576f05b6b672836753cd9b696b752d017a 100644
--- a/drivers/usb/musb/jz4740.c
+++ b/drivers/usb/musb/jz4740.c
@@ -273,7 +273,7 @@ static int jz4740_probe(struct platform_device *pdev)
musb->dev.parent = dev;
musb->dev.dma_mask = &musb->dev.coherent_dma_mask;
musb->dev.coherent_dma_mask = DMA_BIT_MASK(32);
- device_set_of_node_from_dev(&musb->dev, dev);
+ platform_device_set_of_node_from_dev(musb, dev);
glue->pdev = musb;
glue->clk = clk;
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 19/20] reset: rzg2l: use platform_device_set_of_node_from_dev()
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (17 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 18/20] usb: musb: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 20/20] driver core: platform: count references to all kinds of firmware nodes Bartosz Golaszewski
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node from another device for
dynamically allocated platform devices with the provided helper.
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/reset/reset-rzg2l-usbphy-ctrl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
index fd75d9601a3bfde7b7e3f6db287ec8c5c45a20ab..f003b360629c90bb37ed0ade7a675b5b0f28fa7e 100644
--- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
+++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
@@ -249,7 +249,7 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
vdev->dev.parent = dev;
priv->vdev = vdev;
- device_set_of_node_from_dev(&vdev->dev, dev);
+ platform_device_set_of_node_from_dev(vdev, dev);
error = platform_device_add(vdev);
if (error)
goto err_device_put;
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v3 20/20] driver core: platform: count references to all kinds of firmware nodes
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
` (18 preceding siblings ...)
2026-07-06 12:44 ` [PATCH v3 19/20] reset: rzg2l: " Bartosz Golaszewski
@ 2026-07-06 12:44 ` Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
19 siblings, 1 reply; 47+ messages in thread
From: Bartosz Golaszewski @ 2026-07-06 12:44 UTC (permalink / raw)
To: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd, Bartosz Golaszewski
When using platform_device_register_full(), we currently only increase
the reference count of the OF node associated with a platform device. We
symmetrically decrease it in platform_device_release(). With all users in
tree now converted to using provided platform device helpers for
assigning OF and firmware nodes, we can now switch to counting references
of all kinds of firmware nodes.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/base/platform.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9357942d0c79b032645035879b2bed3d53305b9f..a71015f1d915340aa01ebfae67196d4d7ccecba8 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -599,7 +599,7 @@ static void platform_device_release(struct device *dev)
struct platform_object *pa = container_of(dev, struct platform_object,
pdev.dev);
- of_node_put(pa->pdev.dev.of_node);
+ fwnode_handle_put(pa->pdev.dev.fwnode);
kfree(pa->pdev.dev.platform_data);
kfree(pa->pdev.mfd_cell);
kfree(pa->pdev.resource);
@@ -712,9 +712,7 @@ EXPORT_SYMBOL_GPL(platform_device_add_data);
void platform_device_set_of_node(struct platform_device *pdev,
struct device_node *np)
{
- of_node_put(pdev->dev.of_node);
- pdev->dev.of_node = of_node_get(np);
- pdev->dev.fwnode = of_fwnode_handle(np);
+ platform_device_set_fwnode(pdev, of_fwnode_handle(np));
}
EXPORT_SYMBOL_GPL(platform_device_set_of_node);
@@ -730,10 +728,8 @@ EXPORT_SYMBOL_GPL(platform_device_set_of_node);
void platform_device_set_fwnode(struct platform_device *pdev,
struct fwnode_handle *fwnode)
{
- if (is_of_node(fwnode))
- platform_device_set_of_node(pdev, to_of_node(fwnode));
- else
- pdev->dev.fwnode = fwnode;
+ fwnode_handle_put(pdev->dev.fwnode);
+ device_set_node(&pdev->dev, fwnode_handle_get(fwnode));
}
EXPORT_SYMBOL_GPL(platform_device_set_fwnode);
@@ -928,8 +924,7 @@ struct platform_device *platform_device_register_full(const struct platform_devi
return ERR_PTR(-ENOMEM);
pdev->dev.parent = pdevinfo->parent;
- pdev->dev.fwnode = pdevinfo->fwnode;
- pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
+ device_set_node(&pdev->dev, fwnode_handle_get(pdevinfo->fwnode));
dev_assign_of_node_reused(&pdev->dev, pdevinfo->of_node_reused);
if (pdevinfo->dma_mask) {
--
2.47.3
^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
@ 2026-07-06 14:39 ` Manuel Ebner
2026-07-06 14:48 ` Manuel Ebner
2026-07-06 15:49 ` Andy Shevchenko
2026-07-07 13:24 ` sashiko-bot
1 sibling, 2 replies; 47+ messages in thread
From: Manuel Ebner @ 2026-07-06 14:39 UTC (permalink / raw)
To: Bartosz Golaszewski, Lee Jones, Thierry Reding,
Sebastian Hesselbarth, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Srinivas Kandagatla,
Greg Kroah-Hartman, Vinod Koul, Rafael J. Wysocki,
Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd
Hi Bartosz,
On Mon, 2026-07-06 at 14:44 +0200, Bartosz Golaszewski wrote:
> Encapsulate the reference counting logic for OF nodes assigned to
> platform devices created with platform_device_alloc() in a helper
> function. Make the kerneldoc state that this is the proper interface for
> assigning OF nodes to dynamically allocated platform devices. This will
> allow us to switch to counting the references of the device's firmware
> nodes, not only the OF nodes.
>
> Reviewed-by: Manuel Ebner <manuelebner@mailbox.org>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> drivers/base/platform.c | 18 ++++++++++++++++++
> include/linux/platform_device.h | 4 ++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index fb9120b0bcfe0e7dd9dfc0d29b91e0ad40a01440..3188d5aba5f90622f821c695049cacda030204fb
> 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -693,6 +693,24 @@ int platform_device_add_data(struct platform_device *pdev, const
> void *data,
> }
> EXPORT_SYMBOL_GPL(platform_device_add_data);
>
> +/**
> + * platform_device_set_of_node - assign an OF node to device
> + * @pdev: platform device to add the node for
> + * @np: new device node
> + *
> + * Assign an OF node to this platform device. Internally keep track of the
> + * reference count. Devices created with platform_device_alloc() must use this
> + * function instead of assigning the node manually.
I did some more pondering about this patch and concluded the right place
for a warning would be the lines been read right before or after assigning
a node manually.
I think this would be in platform_device_alloc() (as I suggested in v2).
BUT my knowledge in C isn't sound. So if it's good as is keep it. If it isn't
add or move the remark.
Either way Thanks and
Reviewed-by Manuel Ebner.
---
Note:
I removed Mark Brown <broonie@opensource.wolfsonmicro.com> from recipients because:
“RCPT TO <broonie@opensource.wolfsonmicro.com> failed:
<broonie@opensource.wolfsonmicro.com>: Recipient address rejected: Domain not found”.
> + */
> +void platform_device_set_of_node(struct platform_device *pdev,
> + struct device_node *np)
> +{
> + of_node_put(pdev->dev.of_node);
> + pdev->dev.of_node = of_node_get(np);
> + pdev->dev.fwnode = of_fwnode_handle(np);
> +}
> +EXPORT_SYMBOL_GPL(platform_device_set_of_node);
> +
> /**
> * platform_device_add - add a platform device to device hierarchy
> * @pdev: platform device we're adding
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index 8c566f09d04efe420d85ffa046f92c44c6d08526..e9f7baceeb4c8269dbc0143c4d8fc9d73ba024ca
> 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -19,6 +19,8 @@
> struct irq_affinity;
> struct mfd_cell;
> struct property_entry;
> +struct platform_device_id;
> +struct device_node;
>
> struct platform_device {
> const char *name;
> @@ -262,6 +264,8 @@ extern int platform_device_add_resources(struct platform_device
> *pdev,
> unsigned int num);
> extern int platform_device_add_data(struct platform_device *pdev,
> const void *data, size_t size);
> +void platform_device_set_of_node(struct platform_device *pdev,
> + struct device_node *np);
> extern int platform_device_add(struct platform_device *pdev);
> extern void platform_device_del(struct platform_device *pdev);
> extern void platform_device_put(struct platform_device *pdev);
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node()
2026-07-06 14:39 ` Manuel Ebner
@ 2026-07-06 14:48 ` Manuel Ebner
2026-07-06 15:49 ` Andy Shevchenko
1 sibling, 0 replies; 47+ messages in thread
From: Manuel Ebner @ 2026-07-06 14:48 UTC (permalink / raw)
To: Bartosz Golaszewski, Lee Jones, Thierry Reding,
Sebastian Hesselbarth, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Srinivas Kandagatla,
Greg Kroah-Hartman, Vinod Koul, Rafael J. Wysocki,
Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt
Cc: brgl, linux-kernel, netdev, linux-arm-msm, linux-sound,
driver-core, devicetree, linuxppc-dev, linux-i2c, iommu, linux-pm,
imx, linux-arm-kernel, intel-xe, dri-devel, linux-usb, linux-mips,
platform-driver-x86, mfd
On Mon, 2026-07-06 at 16:39 +0200, Manuel Ebner wrote:
> Hi Bartosz,
>
> On Mon, 2026-07-06 at 14:44 +0200, Bartosz Golaszewski wrote:
> >
> > @@ -693,6 +693,24 @@ int platform_device_add_data(struct platform_device *pdev, const
Nevermind, I got confused because of @@ int platform_device_add_data() and
> @@ -619,6 +619,13 @@ static void platform_device_release_full(struct device *dev)
in [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc()
Sorry for the noise
Manuel
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 09/20] iommu/fsl: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 09/20] iommu/fsl: " Bartosz Golaszewski
@ 2026-07-06 14:51 ` Frank Li
2026-07-07 13:24 ` sashiko-bot
1 sibling, 0 replies; 47+ messages in thread
From: Frank Li @ 2026-07-06 14:51 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Andy Shevchenko,
Joerg Roedel, Will Deacon, Robin Murphy, Doug Berger,
Florian Fainelli, Broadcom internal kernel review list,
Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Matthew Brost, Thomas Hellström, Rodrigo Vivi,
David Airlie, Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu,
Philipp Zabel, Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt, brgl, linux-kernel,
netdev, linux-arm-msm, linux-sound, driver-core, devicetree,
linuxppc-dev, linux-i2c, iommu, linux-pm, imx, linux-arm-kernel,
intel-xe, dri-devel, linux-usb, linux-mips, platform-driver-x86,
mfd
On Mon, Jul 06, 2026 at 02:44:21PM +0200, Bartosz Golaszewski wrote:
> Ahead of reworking the reference counting logic for platform devices,
> encapsulate the assignment of the OF node for dynamically allocated
> platform devices with the provided helper.
>
> Acked-by: Robin Murphy <robin.murphy@arm.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/iommu/fsl_pamu.c | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
> index 25aa477a95a95cb4fa4e132727cde0a936750ee2..c83bbc3faad56d6ee1c89b0a7f74028af02c81e9 100644
> --- a/drivers/iommu/fsl_pamu.c
> +++ b/drivers/iommu/fsl_pamu.c
> @@ -8,6 +8,7 @@
>
> #include "fsl_pamu.h"
>
> +#include <linux/cleanup.h>
> #include <linux/fsl/guts.h>
> #include <linux/interrupt.h>
> #include <linux/genalloc.h>
> @@ -933,7 +934,6 @@ static struct platform_driver fsl_of_pamu_driver = {
> static __init int fsl_pamu_init(void)
> {
> struct platform_device *pdev = NULL;
> - struct device_node *np;
> int ret;
>
> /*
> @@ -955,7 +955,8 @@ static __init int fsl_pamu_init(void)
> * PAMU node would require significant changes to a lot of code.
> */
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,pamu");
> + struct device_node *np __free(device_node) =
> + of_find_compatible_node(NULL, NULL, "fsl,pamu");
> if (!np) {
> pr_err("could not find a PAMU node\n");
> return -ENODEV;
> @@ -964,7 +965,7 @@ static __init int fsl_pamu_init(void)
> ret = platform_driver_register(&fsl_of_pamu_driver);
> if (ret) {
> pr_err("could not register driver (err=%i)\n", ret);
> - goto error_driver_register;
> + return ret;
> }
>
> pdev = platform_device_alloc("fsl-of-pamu", 0);
> @@ -973,7 +974,8 @@ static __init int fsl_pamu_init(void)
> ret = -ENOMEM;
> goto error_device_alloc;
> }
> - pdev->dev.of_node = of_node_get(np);
> +
> + platform_device_set_of_node(pdev, np);
>
> ret = pamu_domain_init();
> if (ret)
> @@ -988,17 +990,11 @@ static __init int fsl_pamu_init(void)
> return 0;
>
> error_device_add:
> - of_node_put(pdev->dev.of_node);
> - pdev->dev.of_node = NULL;
> -
> platform_device_put(pdev);
>
> error_device_alloc:
> platform_driver_unregister(&fsl_of_pamu_driver);
>
> -error_driver_register:
> - of_node_put(np);
> -
> return ret;
> }
> arch_initcall(fsl_pamu_init);
>
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node()
2026-07-06 14:39 ` Manuel Ebner
2026-07-06 14:48 ` Manuel Ebner
@ 2026-07-06 15:49 ` Andy Shevchenko
2026-07-06 17:26 ` Mark Brown
1 sibling, 1 reply; 47+ messages in thread
From: Andy Shevchenko @ 2026-07-06 15:49 UTC (permalink / raw)
To: Manuel Ebner, Mark Brown
Cc: Bartosz Golaszewski, Lee Jones, Thierry Reding,
Sebastian Hesselbarth, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Srinivas Kandagatla,
Greg Kroah-Hartman, Vinod Koul, Rafael J. Wysocki,
Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Joerg Roedel,
Will Deacon, Robin Murphy, Doug Berger, Florian Fainelli,
Broadcom internal kernel review list, Ulf Hansson, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Matthew Brost, Thomas Hellström, Rodrigo Vivi, David Airlie,
Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu, Philipp Zabel,
Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt, brgl, linux-kernel,
netdev, linux-arm-msm, linux-sound, driver-core, devicetree,
linuxppc-dev, linux-i2c, iommu, linux-pm, imx, linux-arm-kernel,
intel-xe, dri-devel, linux-usb, linux-mips, platform-driver-x86,
mfd
On Mon, Jul 06, 2026 at 04:39:00PM +0200, Manuel Ebner wrote:
> On Mon, 2026-07-06 at 14:44 +0200, Bartosz Golaszewski wrote:
> I removed Mark Brown <broonie@opensource.wolfsonmicro.com> from recipients because:
> “RCPT TO <broonie@opensource.wolfsonmicro.com> failed:
> <broonie@opensource.wolfsonmicro.com>: Recipient address rejected: Domain not found”.
Perhaps he needs to send a patch to update .mailmap?
Cc'ed to Mark.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node()
2026-07-06 15:49 ` Andy Shevchenko
@ 2026-07-06 17:26 ` Mark Brown
0 siblings, 0 replies; 47+ messages in thread
From: Mark Brown @ 2026-07-06 17:26 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Manuel Ebner, Bartosz Golaszewski, Lee Jones, Thierry Reding,
Sebastian Hesselbarth, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Srinivas Kandagatla,
Greg Kroah-Hartman, Vinod Koul, Rafael J. Wysocki,
Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Joerg Roedel,
Will Deacon, Robin Murphy, Doug Berger, Florian Fainelli,
Broadcom internal kernel review list, Ulf Hansson, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Matthew Brost, Thomas Hellström, Rodrigo Vivi, David Airlie,
Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu, Philipp Zabel,
Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt, brgl, linux-kernel,
netdev, linux-arm-msm, linux-sound, driver-core, devicetree,
linuxppc-dev, linux-i2c, iommu, linux-pm, imx, linux-arm-kernel,
intel-xe, dri-devel, linux-usb, linux-mips, platform-driver-x86,
mfd
[-- Attachment #1: Type: text/plain, Size: 667 bytes --]
On Mon, Jul 06, 2026 at 06:49:55PM +0300, Andy Shevchenko wrote:
> On Mon, Jul 06, 2026 at 04:39:00PM +0200, Manuel Ebner wrote:
> > On Mon, 2026-07-06 at 14:44 +0200, Bartosz Golaszewski wrote:
> > I removed Mark Brown <broonie@opensource.wolfsonmicro.com> from recipients because:
> > “RCPT TO <broonie@opensource.wolfsonmicro.com> failed:
> > <broonie@opensource.wolfsonmicro.com>: Recipient address rejected: Domain not found”.
> Perhaps he needs to send a patch to update .mailmap?
> Cc'ed to Mark.
If it's for something that old I can't imagine I actually care. If it's
important enough I'm sure someone can work out how to get hold of me.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 01/20] powerpc/powermac: fix OF node refcount
2026-07-06 12:44 ` [PATCH v3 01/20] powerpc/powermac: fix OF node refcount Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Frank.Li, mfd, conor+dt, robh, lee, dri-devel, devicetree, imx
> Platform devices created with platform_device_alloc() call
> platform_device_release() when the last reference to the device's
> kobject is dropped. This function calls of_node_put() unconditionally.
> This works fine for devices created with platform_device_register_full()
> but users of the split approach (platform_device_alloc() +
> platform_device_add()) must bump the reference of the of_node they
> assign manually. Add the missing call to of_node_get().
>
> Cc: stable@vger.kernel.org
> Fixes: 81e5d8646ff6 ("i2c/powermac: Register i2c devices from device-tree")
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=1
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
2026-07-06 14:39 ` Manuel Ebner
@ 2026-07-07 13:24 ` sashiko-bot
1 sibling, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: robh, imx, lee, dri-devel, devicetree, Frank.Li, conor+dt, mfd
> Encapsulate the reference counting logic for OF nodes assigned to
> platform devices created with platform_device_alloc() in a helper
> function. Make the kerneldoc state that this is the proper interface for
> assigning OF nodes to dynamically allocated platform devices. This will
> allow us to switch to counting the references of the device's firmware
> nodes, not only the OF nodes.
>
> Reviewed-by: Manuel Ebner <manuelebner@mailbox.org>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=2
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode()
2026-07-06 12:44 ` [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode() Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: imx, Frank.Li, dri-devel, robh, mfd, conor+dt, devicetree, lee
> Provide a helper function encapsulating the logic of assigning firmware
> nodes to platform devices created with platform_device_alloc(). Make the
> kerneldoc state that this is the proper interface for assigning firmware
> nodes to dynamically allocated platform devices. This will allow us to
> switch to counting the references of the device's firmware nodes in the
> future, not only the OF nodes.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=3
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev()
2026-07-06 12:44 ` [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev() Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: conor+dt, robh, imx, mfd, devicetree, dri-devel, lee, Frank.Li
> Provide a platform-specific variant of device_set_of_node_from_dev(). In
> addition to bumping the reference count of the OF node being assigned,
> it also assigns the fwnode of the platform device.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=4
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc()
2026-07-06 12:44 ` [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc() Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
2026-07-07 16:05 ` Andy Shevchenko
1 sibling, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: devicetree, dri-devel, conor+dt, lee, mfd, robh, imx, Frank.Li
> Users of platform_device_alloc() + platform_device_add() must not modify
> certain fields of the dynamically created platform device object. Update
> the kernel doc to say which fields are affected and which functions to
> use.
>
> Suggested-by: Manuel Ebner <manuelebner@mailbox.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=5
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 06/20] of: platform: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 06/20] of: platform: use platform_device_set_of_node() Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: mfd, robh, conor+dt, Frank.Li, devicetree, imx, dri-devel, lee
> Ahead of reworking the reference counting logic for platform devices,
> encapsulate the assignment of the OF node for dynamically allocated
> platform devices with the provided helper.
>
> Acked-by: Rob Herring (Arm) <robh@kernel.org>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=6
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 07/20] powerpc/powermac: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 07/20] powerpc/powermac: " Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: devicetree, imx, mfd, conor+dt, Frank.Li, dri-devel, robh, lee
> Ahead of reworking the reference counting logic for platform devices,
> encapsulate the assignment of the OF node for dynamically allocated
> platform devices with the provided helper.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=7
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 08/20] i2c: pxa-pci: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 08/20] i2c: pxa-pci: " Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: conor+dt, devicetree, lee, Frank.Li, robh, imx, mfd, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The OF device node reference obtained from `for_each_child_of_node()` is leaked when assigning the OF node to the platform device.
--
commit 0b7f7e14c13b65be057bb0d2e9e1a4b953a99635
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
i2c: pxa-pci: use platform_device_set_of_node()
This patch updates the i2c-pxa-pci driver to use the new
platform_device_set_of_node() helper for dynamically allocated platform
devices. It replaces the direct assignment of the OF node pointer ahead of
upcoming reference counting reworks in the driver core.
> diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
> index dbd542300f800..92a0647f08c69 100644
> --- a/drivers/i2c/busses/i2c-pxa-pci.c
> +++ b/drivers/i2c/busses/i2c-pxa-pci.c
> @@ -76,7 +76,8 @@ static struct platform_device *add_i2c_device(struct pci_dev *dev, int bar)
> goto out;
> }
> pdev->dev.parent = &dev->dev;
> - pdev->dev.of_node = child;
> +
> + platform_device_set_of_node(pdev, child);
[Severity: Medium]
Does this change introduce an OF node reference leak?
Earlier in add_i2c_device(), the child node is acquired using a
for_each_child_of_node() loop that exits via break. This leaves the child
variable with an incremented reference count.
Before this patch, the direct assignment implicitly transferred this
reference to the platform device. The new platform_device_set_of_node()
helper takes its own additional reference internally when setting the fwnode.
Since the caller's original reference is never explicitly dropped after
this helper is called, it seems this will leak the OF node reference on both
the success and error paths. Should there be an of_node_put(child) after
calling the helper?
>
> ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
> if (ret)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=8
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 09/20] iommu/fsl: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 09/20] iommu/fsl: " Bartosz Golaszewski
2026-07-06 14:51 ` Frank Li
@ 2026-07-07 13:24 ` sashiko-bot
1 sibling, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: robh, imx, Frank.Li, mfd, dri-devel, devicetree, conor+dt, lee
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Mixing `goto`-based error handling with `__free()` cleanup in the same function.
--
commit 59e996ccb5b78974f4d3d6c2abcfbc8e49cb4d29
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
iommu/fsl: use platform_device_set_of_node()
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
> diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
> index 25aa477a95a95..c83bbc3faad56 100644
> --- a/drivers/iommu/fsl_pamu.c
> +++ b/drivers/iommu/fsl_pamu.c
[ ... ]
> @@ -955,7 +955,8 @@ static __init int fsl_pamu_init(void)
> * PAMU node would require significant changes to a lot of code.
> */
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,pamu");
> + struct device_node *np __free(device_node) =
> + of_find_compatible_node(NULL, NULL, "fsl,pamu");
> if (!np) {
> pr_err("could not find a PAMU node\n");
> return -ENODEV;
> @@ -964,7 +965,7 @@ static __init int fsl_pamu_init(void)
> ret = platform_driver_register(&fsl_of_pamu_driver);
> if (ret) {
> pr_err("could not register driver (err=%i)\n", ret);
> - goto error_driver_register;
> + return ret;
> }
>
> pdev = platform_device_alloc("fsl-of-pamu", 0);
> @@ -973,7 +974,8 @@ static __init int fsl_pamu_init(void)
> ret = -ENOMEM;
> goto error_device_alloc;
[Severity: Medium]
Is it intentional to mix goto-based error handling with scope-based
cleanup in fsl_pamu_init()?
The cleanup helper documentation in include/linux/cleanup.h specifies that
goto and cleanup helpers should never be mixed in the same function to
prevent confusing ownership semantics.
Since pdev allocation and other initialization steps in this function still
use goto labels (like error_device_alloc and error_device_add), should they
all be converted to scope-based cleanup, or should np remain manually
managed to keep the error handling consistent?
> - pdev->dev.of_node = of_node_get(np);
> +
> + platform_device_set_of_node(pdev, np);
>
> ret = pamu_domain_init();
> if (ret)
> @@ -988,17 +990,11 @@ static __init int fsl_pamu_init(void)
> return 0;
>
> error_device_add:
> - of_node_put(pdev->dev.of_node);
> - pdev->dev.of_node = NULL;
> -
> platform_device_put(pdev);
>
> error_device_alloc:
> platform_driver_unregister(&fsl_of_pamu_driver);
>
> -error_driver_register:
> - of_node_put(np);
> -
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=9
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 10/20] net: bcmgenet: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 10/20] net: bcmgenet: " Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: devicetree, imx, robh, conor+dt, dri-devel, lee, Frank.Li, mfd
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] OF Node Reference Leak due to missing of_node_put() on the result of bcmgenet_mii_of_find_mdio()
--
commit 3b29ae0c601cb855b049f7da529812b74080533b
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
net: bcmgenet: use platform_device_set_of_node()
This commit encapsulates the assignment of the OF node for dynamically
allocated platform devices using platform_device_set_of_node().
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
> index a4e0d5a682687..0f0dbabfaabbc 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
[ ... ]
> @@ -490,8 +490,9 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
> /* Retain this platform_device pointer for later cleanup */
> priv->mii_pdev = ppdev;
> ppdev->dev.parent = &pdev->dev;
> +
> if (dn)
> - ppdev->dev.of_node = bcmgenet_mii_of_find_mdio(priv);
> + platform_device_set_of_node(ppdev, bcmgenet_mii_of_find_mdio(priv));
[Severity: Medium]
Does this leak the OF node reference? bcmgenet_mii_of_find_mdio() internally
calls of_get_compatible_child(), which returns a device node with an
incremented reference count.
Previously, direct assignment allowed the platform device to consume this
reference when it was eventually released. Now that
platform_device_set_of_node() is used, it acquires its own reference
internally.
Should there be an explicit of_node_put() to drop the initial reference
returned by bcmgenet_mii_of_find_mdio() so it isn't leaked?
> else
> ppd.phy_mask = ~0;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=10
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 11/20] pmdomain: imx: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 11/20] pmdomain: imx: " Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Frank.Li, lee, devicetree, dri-devel, conor+dt, imx, mfd, robh
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Child platform devices dynamically added during probe are not unregistered on probe error paths or during driver removal.
- [High] The i.MX GPC power domain driver initializes domains as powered on but does not set GENPD_FLAG_NO_STAY_ON or provide a sync_state callback, causing domains to stay on indefinitely.
--
commit 183445e8048cfd412f98719fae14416614f14176
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
pmdomain: imx: use platform_device_set_of_node()
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
> diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
> index 42e50c9b4fb9f..abca5f449a226 100644
> --- a/drivers/pmdomain/imx/gpc.c
> +++ b/drivers/pmdomain/imx/gpc.c
> @@ -487,8 +487,7 @@ static int imx_gpc_probe(struct platform_device *pdev)
> domain->ipg_rate_mhz = ipg_rate_mhz;
>
> pd_pdev->dev.parent = &pdev->dev;
> - pd_pdev->dev.of_node = of_node_get(np);
> - pd_pdev->dev.fwnode = of_fwnode_handle(np);
> + platform_device_set_of_node(pd_pdev, np);
>
> ret = platform_device_add(pd_pdev);
> if (ret) {
[Severity: High]
This isn't a bug introduced by this patch, but I noticed that child platform
devices added in previous loop iterations are not unregistered on this error
path.
If platform_device_add() fails, or if platform_device_alloc() fails earlier
in the loop, imx_gpc_probe() returns immediately. Any successfully added
"imx-pgc-power-domain" devices from previous iterations are left orphaned.
Because these orphaned child devices hold references to the parent's
devm-managed regmap, does this create a use-after-free when the parent's
devres cleanup runs?
The same unregistering step appears to be missing in imx_gpc_remove(), which
skips the cleanup of these dynamically added platform devices entirely when
pgc_node is present.
[Severity: High]
This is also a pre-existing issue, but I noticed a potential problem with how
these domains are initialized.
In imx_pgc_power_domain_probe(), the domains are initialized as powered on
via pm_genpd_init(&domain->base, NULL, false). For OF-based genpd providers,
this sets genpd->stay_on = true.
However, neither imx_gpc_driver nor imx_pgc_power_domain_driver registers a
.sync_state callback, and the domains do not have GENPD_FLAG_NO_STAY_ON set.
Since the stay_on flag is never cleared, will this cause the domains to
remain powered on indefinitely? If regulator_late_cleanup() later disables
the underlying regulators while the domains are still active, could this
lead to hardware malfunctions?
> platform_device_put(pd_pdev);
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=11
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 12/20] mfd: tps6586: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 12/20] mfd: tps6586: " Bartosz Golaszewski
@ 2026-07-07 13:24 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: dri-devel, conor+dt, imx, lee, robh, mfd, Frank.Li, devicetree
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] Subdevice cleanup unconditionally unregisters all children, prematurely removing MFD cell devices and bypassing `mfd_remove_devices_fn()`.
- [Medium] Manual assignment of `pdev->dev.platform_data` leads to invalid `kfree()`.
- [Medium] Missing IRQ domain and IRQ descriptors cleanup on teardown and error paths.
--
commit 0df04ec4b22ac2adb3b77bf67e6a1339f5fd4523
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
mfd: tps6586: use platform_device_set_of_node()
This commit encapsulates the assignment of the OF node for dynamically
allocated platform devices by using the platform_device_set_of_node() helper.
This change prepares for reworking the reference counting logic for platform
devices.
> diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
> index f5f8054466033..3cfd2f02b62f3 100644
> --- a/drivers/mfd/tps6586x.c
> +++ b/drivers/mfd/tps6586x.c
> @@ -397,7 +397,7 @@ static int tps6586x_add_subdevs(struct tps6586x *tps6586x,
>
> pdev->dev.parent = tps6586x->dev;
> pdev->dev.platform_data = subdev->platform_data;
[Severity: Medium]
This is a pre-existing issue, but does this manual assignment of
platform_data at line 399 in tps6586x_add_subdevs() cause problems during
device release?
When the platform device is unregistered, platform_device_release()
unconditionally calls kfree(pdev->dev.platform_data).
If subdev->platform_data was statically allocated or part of devm_kzalloc
memory, could this corrupt the heap?
> - pdev->dev.of_node = of_node_get(subdev->of_node);
> + platform_device_set_of_node(pdev, subdev->of_node);
>
> ret = platform_device_add(pdev);
> if (ret) {
[Severity: High]
This isn't a bug introduced by this patch, but does the cleanup in
tps6586x_remove_subdevs() interfere with MFD core cleanup?
drivers/mfd/tps6586x.c:tps6586x_remove_subdevs() {
...
return device_for_each_child(tps6586x->dev, NULL, __remove_subdev);
}
drivers/mfd/tps6586x.c:__remove_subdev() {
...
platform_device_unregister(to_platform_device(dev));
}
Since MFD cells added by mfd_add_devices() are children of tps6586x->dev,
this unconditional unregistering of all children appears to bypass
mfd_remove_devices_fn().
Could blindly casting dev to struct platform_device also be unsafe if any
child is not a platform device?
[Severity: Medium]
This is a pre-existing issue, but does the driver leak IRQ descriptors and
the IRQ domain during removal or on error paths?
In the removal path, tps6586x_i2c_remove() in drivers/mfd/tps6586x.c cleans
up other resources but misses IRQ cleanup:
drivers/mfd/tps6586x.c:tps6586x_i2c_remove() {
struct tps6586x *tps6586x = i2c_get_clientdata(client);
tps6586x_remove_subdevs(tps6586x);
mfd_remove_devices(tps6586x->dev);
}
Additionally, if irq_domain_create_simple() or request_threaded_irq() fail
in tps6586x_irq_init():
drivers/mfd/tps6586x.c:tps6586x_irq_init() {
...
if (!tps6586x->irq_domain) {
dev_err(tps6586x->dev, "Failed to create IRQ domain\n");
return -ENOMEM;
}
...
}
The error paths exit without freeing the previously allocated descriptors or
domain. Can this cause resource leakage on cold paths?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=12
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 13/20] slimbus: qcom-ngd-ctrl: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 13/20] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
@ 2026-07-07 13:25 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: lee, dri-devel, conor+dt, devicetree, mfd, Frank.Li, imx, robh
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] The dynamically allocated platform device and its associated OF node reference are leaked during device unregistration.
- [High] Unconditional dereference of `of_match_node()` return value leads to a NULL pointer dereference.
- [High] Missing cancellation of asynchronous work `ngd_up_work` causes a Use-After-Free of the `ctrl` structure on module removal.
--
commit 4a2753767e946e9e44740066e0bb9147c741d781
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
slimbus: qcom-ngd-ctrl: use platform_device_set_of_node()
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
Acked-by: Konrad Dybcio <konradybcio@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
> index 3071e46d03bea..6e89415712ce1 100644
> --- a/drivers/slimbus/qcom-ngd-ctrl.c
> +++ b/drivers/slimbus/qcom-ngd-ctrl.c
[ ... ]
[Severity: High]
This isn't a bug introduced by this patch, but can this code cause a NULL
pointer dereference?
Looking at the beginning of of_qcom_slim_ngd_register():
drivers/slimbus/qcom-ngd-ctrl.c:of_qcom_slim_ngd_register() {
...
match = of_match_node(qcom_slim_ngd_dt_match, parent->of_node);
data = match->data;
If the driver is bound via sysfs to a platform device that lacks a device
tree node, of_match_node() will return NULL. Should this use
of_device_get_match_data() or validate the match pointer before accessing
data?
> @@ -1539,7 +1539,7 @@ static int of_qcom_slim_ngd_register(struct device *parent,
> kfree(ngd);
> return ret;
> }
> - ngd->pdev->dev.of_node = of_node_get(node);
> + platform_device_set_of_node(ngd->pdev, node);
> ctrl->ngd = ngd;
>
> ret = platform_device_add(ngd->pdev);
[Severity: High]
This is a pre-existing issue, but does this dynamically allocated device
get leaked when unregistered?
Looking at qcom_slim_ngd_unregister() in drivers/slimbus/qcom-ngd-ctrl.c:
qcom_slim_ngd_unregister() {
...
platform_device_del(ngd->pdev);
...
}
Since of_qcom_slim_ngd_register() allocates the device with
platform_device_alloc(), shouldn't platform_device_put() be called to drop
the initial reference count? Without it, both the device structure and the
device tree node reference acquired above are never freed during unbind.
[Severity: High]
This is a pre-existing issue, but is there a risk of a use-after-free
during module removal?
Looking at the driver teardown in qcom_slim_ngd_ctrl_remove():
drivers/slimbus/qcom-ngd-ctrl.c:qcom_slim_ngd_ctrl_remove() {
...
qcom_slim_ngd_unregister(ctrl);
destroy_workqueue(ctrl->mwq);
}
If qcom_slim_ngd_ssr_pdr_notify() has scheduled ctrl->ngd_up_work on the
system workqueue, can it execute after the devres-managed ctrl structure
is freed? Would adding cancel_work_sync(&ctrl->ngd_up_work) here ensure
the background task completes before the memory is released?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=13
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 14/20] net: mv643xx: use platform_device_set_of_node()
2026-07-06 12:44 ` [PATCH v3 14/20] net: mv643xx: " Bartosz Golaszewski
@ 2026-07-07 13:25 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: devicetree, Frank.Li, lee, dri-devel, imx, mfd, conor+dt, robh
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] Dynamically allocated platform devices are leaked during driver removal due to missing `platform_device_put()`.
- [High] The static global `port_platdev` array is accessed without synchronization, leading to probe races and cross-device teardown corruption.
- [High] Missing `phy_disconnect()` on the error path of `mv643xx_eth_probe()`, leading to a use-after-free of the `net_device`.
--
commit 286e3bdd9b38ee5d56ee5ff7b8525f2effcb4c53
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
net: mv643xx: use platform_device_set_of_node()
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
> index 1881583be5ce2..9caa1e47c174c 100644
> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
[ ... ]
> @@ -2780,7 +2780,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
> goto put_err;
> }
> ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> - ppdev->dev.of_node = of_node_get(pnp);
> + platform_device_set_of_node(ppdev, pnp);
[Severity: High]
This isn't a bug introduced by this patch, but does this dynamically allocated
platform device leak during driver removal?
Earlier in mv643xx_eth_shared_of_add_port(), platform_device_alloc() sets the
initial reference count to 1. During removal, mv643xx_eth_shared_of_remove()
calls platform_device_del(), which removes the device from the hierarchy but
fails to drop the reference count.
Without a matching platform_device_put(), the device and its associated data
leak on unbind or probe failure.
[Severity: High]
This is also a pre-existing issue, but could this global port array logic
cause cross-device teardown corruption?
This function searches for a free slot in the global port_platdev array
without synchronization:
mv643xx_eth_shared_of_add_port() {
...
while (dev_num < 3 && port_platdev[dev_num])
dev_num++;
...
}
If controllers probe concurrently, they could race on this global state.
Additionally, if one controller is unbound via sysfs,
mv643xx_eth_shared_of_remove() unconditionally iterates over the global
array and deletes all ports:
mv643xx_eth_shared_of_remove() {
...
for (n = 0; n < 3; n++) {
if (!port_platdev[n])
continue;
platform_device_del(port_platdev[n]);
port_platdev[n] = NULL;
}
}
Wouldn't this destroy active network ports belonging to completely independent
controllers sharing the driver?
[Severity: High]
This is another pre-existing issue, but does the probe error path leave a
dangling pointer in the PHY subsystem?
In mv643xx_eth_probe(), the driver connects the PHY (which attaches it and
stores a pointer to the net_device in phydev->attached_dev). If a subsequent
operation in the probe fails, the error path frees the net_device but never
disconnects the PHY:
mv643xx_eth_probe() {
...
out:
if (!IS_ERR(mp->clk))
clk_disable_unprepare(mp->clk);
free_netdev(dev);
return err;
}
Can this lead to a use-after-free if the PHY device remains active and
is later accessed via sysfs or core PHY polling routines?
>
> ret = platform_device_add_resources(ppdev, &res, 1);
> if (ret)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=14
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode()
2026-07-06 12:44 ` [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode() Bartosz Golaszewski
@ 2026-07-07 13:25 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: robh, lee, imx, dri-devel, Frank.Li, devicetree, mfd, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing cancel_work_sync() in the xe_i2c teardown path leads to a Use-After-Free of the device structure.
--
commit 1fdde54b64291aceacb95c2a267bee6b6609b500
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drm/xe/i2c: use platform_device_set_fwnode()
This commit encapsulates the assignment of the firmware node for dynamically
allocated platform devices with the provided helper ahead of reworking the
reference counting logic.
> diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
> index 706783863d07d..af4ebd93ad8e6 100644
> --- a/drivers/gpu/drm/xe/xe_i2c.c
> +++ b/drivers/gpu/drm/xe/xe_i2c.c
[ ... ]
> @@ -123,7 +123,7 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
> }
>
> pdev->dev.parent = i2c->drm_dev;
> - pdev->dev.fwnode = fwnode;
> + platform_device_set_fwnode(pdev, fwnode);
> i2c->adapter_node = fwnode;
> i2c->pdev = pdev;
[Severity: High]
This is a pre-existing issue, but does the teardown path for this adapter
need a cancel_work_sync() call?
The I2C adapter registration during xe_i2c_probe() triggers a
BUS_NOTIFY_ADD_DEVICE notification, which schedules i2c->work. If the device
is unbound before this background work completes, xe_i2c_remove() is called:
static void xe_i2c_remove(void *data)
{
struct xe_i2c *i2c = data;
unsigned int i;
for (i = 0; i < XE_I2C_MAX_CLIENTS; i++)
i2c_unregister_device(i2c->client[i]);
bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier);
xe_i2c_unregister_adapter(i2c);
xe_i2c_remove_irq(i2c);
}
Since xe_i2c_remove() unregisters the notifier and adapter but fails to call
cancel_work_sync(&i2c->work), could the scheduled work execute after the
struct xe_i2c memory is freed?
This appears to leave a window for a use-after-free when unbinding the driver,
as the delayed work might dereference the freed i2c pointer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=15
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 16/20] platform/surface: gpe: use platform_device_set_fwnode()
2026-07-06 12:44 ` [PATCH v3 16/20] platform/surface: gpe: " Bartosz Golaszewski
@ 2026-07-07 13:25 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Frank.Li, mfd, lee, imx, robh, dri-devel, conor+dt, devicetree
> Ahead of reworking the reference counting logic for platform devices,
> encapsulate the assignment of the firmware node for dynamically allocated
> platform devices with the provided helper.
>
> Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=16
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 17/20] usb: chipidea: use platform_device_set_of_node_from_dev()
2026-07-06 12:44 ` [PATCH v3 17/20] usb: chipidea: use platform_device_set_of_node_from_dev() Bartosz Golaszewski
@ 2026-07-07 13:25 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: devicetree, imx, Frank.Li, dri-devel, conor+dt, lee, mfd, robh
> Ahead of reworking the reference counting logic for platform devices,
> encapsulate the assignment of the OF node from another device for
> dynamically allocated platform devices with the provided helper.
>
> Acked-by: Peter Chen <peter.chen@kernel.org>
> Link: https://lore.kernel.org/r/20211215225646.1997946-1-robh@kernel.org
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=17
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 18/20] usb: musb: use platform_device_set_of_node_from_dev()
2026-07-06 12:44 ` [PATCH v3 18/20] usb: musb: " Bartosz Golaszewski
@ 2026-07-07 13:25 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: lee, mfd, dri-devel, robh, devicetree, Frank.Li, conor+dt, imx
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch missed replacing `device_set_of_node_from_dev()` with the new `platform_device_set_of_node_from_dev()` wrapper for four dynamically allocated platform devices in the `musb` subsystem. Because the final patch in this series modifies `platform_device_release()` to only drop the `fwnode` reference instead of the `of_node` reference, these four un-migrated drivers will never have their `fwnode` field populated and will leak their `of_node` reference upon device destruction.
--
commit 38644321565357d4bf1b4cbb11a9e179abf72efc
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
usb: musb: use platform_device_set_of_node_from_dev()
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node from another device for
dynamically allocated platform devices with the provided helper.
> diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
> index df56c972986f7..c770ba576f05b 100644
> --- a/drivers/usb/musb/jz4740.c
> +++ b/drivers/usb/musb/jz4740.c
> @@ -273,7 +273,7 @@ static int jz4740_probe(struct platform_device *pdev)
> musb->dev.parent = dev;
> musb->dev.dma_mask = &musb->dev.coherent_dma_mask;
> musb->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> - device_set_of_node_from_dev(&musb->dev, dev);
> + platform_device_set_of_node_from_dev(musb, dev);
[Severity: Medium]
Will this miss other dynamically allocated platform devices in the musb
subsystem?
Because the final patch in this series modifies platform_device_release() to
only drop the fwnode reference instead of the of_node reference, wouldn't
these remaining un-migrated drivers never have their fwnode field populated?
This could cause an of_node reference leak upon device destruction (e.g., via
platform_device_put() on probe failure or driver unbinding). If these devices
are instantiated via dynamic Device Tree overlays, the leaked reference will
prevent the overlay from being safely unloaded.
The following files appear to have missed the migration:
drivers/usb/musb/mpfs.c:mpfs_probe()
device_set_of_node_from_dev(&musb_pdev->dev, dev);
drivers/usb/musb/musb_dsps.c:dsps_create_musb_pdev()
device_set_of_node_from_dev(&musb->dev, &parent->dev);
drivers/usb/musb/omap2430.c:omap2430_probe()
device_set_of_node_from_dev(&musb->dev, &pdev->dev);
drivers/usb/musb/ux500.c:ux500_probe()
device_set_of_node_from_dev(&musb->dev, &pdev->dev);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=18
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 19/20] reset: rzg2l: use platform_device_set_of_node_from_dev()
2026-07-06 12:44 ` [PATCH v3 19/20] reset: rzg2l: " Bartosz Golaszewski
@ 2026-07-07 13:25 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Frank.Li, dri-devel, conor+dt, imx, robh, mfd, lee, devicetree
> Ahead of reworking the reference counting logic for platform devices,
> encapsulate the assignment of the OF node from another device for
> dynamically allocated platform devices with the provided helper.
>
> Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=19
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 20/20] driver core: platform: count references to all kinds of firmware nodes
2026-07-06 12:44 ` [PATCH v3 20/20] driver core: platform: count references to all kinds of firmware nodes Bartosz Golaszewski
@ 2026-07-07 13:25 ` sashiko-bot
0 siblings, 0 replies; 47+ messages in thread
From: sashiko-bot @ 2026-07-07 13:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: robh, devicetree, dri-devel, imx, lee, Frank.Li, mfd, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] OF node reference leak for dynamically allocated platform devices due to incomplete tree-wide conversion.
--
commit 50bc78e1d223d4a9addf4cc0c3c1d384a104d5a6
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
driver core: platform: count references to all kinds of firmware nodes
When using platform_device_register_full(), we currently only increase
the reference count of the OF node associated with a platform device. We
symmetrically decrease it in platform_device_release(). With all users in
tree now converted to using provided platform device helpers for
assigning OF and firmware nodes, we can now switch to counting references
of all kinds of firmware nodes.
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 9357942d0c79b..a71015f1d9153 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -599,7 +599,7 @@ static void platform_device_release(struct device *dev)
> struct platform_object *pa = container_of(dev, struct platform_object,
> pdev.dev);
>
> - of_node_put(pa->pdev.dev.of_node);
> + fwnode_handle_put(pa->pdev.dev.fwnode);
[Severity: High]
Does this code leak the device_node for drivers that haven't been fully
converted to the platform device helpers?
The commit message mentions that all in-tree users are converted, but there
appear to be some unconverted drivers still using device_set_of_node_from_dev
on dynamically allocated platform devices.
For example, in drivers/usb/host/fsl-mph-dr-of.c:fsl_usb2_device_register():
device_set_of_node_from_dev(&pdev->dev, &ofdev->dev);
And in drivers/usb/musb/musb_dsps.c:dsps_create_musb_pdev():
device_set_of_node_from_dev(&musb->dev, &parent->dev);
Since device_set_of_node_from_dev() sets and increments dev->of_node without
setting dev->fwnode, won't fwnode_handle_put(NULL) do nothing and permanently
leak the OF node reference when these devices are released?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=20
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc()
2026-07-06 12:44 ` [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
@ 2026-07-07 16:05 ` Andy Shevchenko
1 sibling, 0 replies; 47+ messages in thread
From: Andy Shevchenko @ 2026-07-07 16:05 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Joerg Roedel,
Will Deacon, Robin Murphy, Doug Berger, Florian Fainelli,
Broadcom internal kernel review list, Ulf Hansson, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Matthew Brost, Thomas Hellström, Rodrigo Vivi, David Airlie,
Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu, Philipp Zabel,
Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt, brgl, linux-kernel,
netdev, linux-arm-msm, linux-sound, driver-core, devicetree,
linuxppc-dev, linux-i2c, iommu, linux-pm, imx, linux-arm-kernel,
intel-xe, dri-devel, linux-usb, linux-mips, platform-driver-x86,
mfd, Manuel Ebner
On Mon, Jul 06, 2026 at 02:44:17PM +0200, Bartosz Golaszewski wrote:
> Users of platform_device_alloc() + platform_device_add() must not modify
> certain fields of the dynamically created platform device object. Update
> the kernel doc to say which fields are affected and which functions to
> use.
Consider using __private checker attribute for them as well. It will make
sparse scream.
> Suggested-by: Manuel Ebner <manuelebner@mailbox.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 47+ messages in thread
end of thread, other threads:[~2026-07-07 16:05 UTC | newest]
Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
2026-07-06 12:44 ` [PATCH v3 01/20] powerpc/powermac: fix OF node refcount Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
2026-07-06 14:39 ` Manuel Ebner
2026-07-06 14:48 ` Manuel Ebner
2026-07-06 15:49 ` Andy Shevchenko
2026-07-06 17:26 ` Mark Brown
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-07 16:05 ` Andy Shevchenko
2026-07-06 12:44 ` [PATCH v3 06/20] of: platform: use platform_device_set_of_node() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 07/20] powerpc/powermac: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 08/20] i2c: pxa-pci: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 09/20] iommu/fsl: " Bartosz Golaszewski
2026-07-06 14:51 ` Frank Li
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 10/20] net: bcmgenet: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 11/20] pmdomain: imx: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 12/20] mfd: tps6586: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 13/20] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 14/20] net: mv643xx: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode() Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 16/20] platform/surface: gpe: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 17/20] usb: chipidea: use platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 18/20] usb: musb: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 19/20] reset: rzg2l: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 20/20] driver core: platform: count references to all kinds of firmware nodes Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox