[PATCH v2 00/19] driver core: count references of the platform device's fwnode, not OF node
From: Bartosz Golaszewski <hidden>
Date: 2026-06-29 09:13:01
Also in:
dri-devel, driver-core, imx, intel-xe, linux-arm-msm, linux-devicetree, linux-i2c, linux-iommu, linux-mips, linux-pm, linux-sound, linux-usb, lkml, netdev, platform-driver-x86, stable
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 <redacted> --- 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 (19): 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() 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 | 56 ++++++++++++++++++++++++++-- drivers/gpu/drm/xe/xe_i2c.c | 2 +- drivers/i2c/busses/i2c-pxa-pci.c | 3 +- drivers/iommu/fsl_pamu.c | 7 ++-- drivers/mfd/tps6586x.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmmii.c | 10 +++-- 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 | 8 ++++ 16 files changed, 84 insertions(+), 23 deletions(-) --- base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482 change-id: 20260520-pdev-fwnode-ref-d867836971eb Best regards, -- Bartosz Golaszewski [off-list ref]