I'd like to first apologize for the long, treewide series and an extensive Cc list but I think it's important to show the big picture and the end result of this rework.
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: First tree patches should go directly into individual maintainers' trees and land in v7.1 and stable as bug fixes. The remaining patches touch lots of drivers but the changes are minimal and unlikely to cause any conflicts. I believe they should be queued in the driver core tree for v7.2 (possibly on an immutable branch for others to merge into their trees). If the subsystem maintainers object, the alternative is to queue the three new helpers for platform devices via the driver core tree. After v7.2-rc1, I'd resend individual driver patches to appropriate maintainers and once they're upstream, we can apply the final platform device change. However this would take three cycles to complete so my preference is the former solution. Signed-off-by: Bartosz Golaszewski <[email protected]> --- Bartosz Golaszewski (23): mfd: tps6586x: fix OF node refcount net: mv643xx: fix OF node refcount slimbus: qcom-ngd-ctrl: fix OF node refcount pmdomain: imx: fix OF node refcount 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: 687da68900cd1a46549f7d9430c7d40346cb86a0 change-id: 20260520-pdev-fwnode-ref-d867836971eb Best regards, -- Bartosz Golaszewski <[email protected]>
