Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

amba: bus: balance firmware node reference counting

Currently the ACPI code doesn't bump the reference count of
the firmware node, while OF counter part does. Not that it's
a problem right now, since ACPI doesn't really use the reference
counting for firmware nodes, it still makes sense to make code
robust against any changes done there. For this,
- switch ACPI case to use device_set_node() to be unified with OF
- move reference counting to amba_device_add()
- switch to use firmware nodes instead of OF ones

In the result we will have reference counting done in the same module
for all callers independently on the nature of firmware node behind.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231006145732.3419115-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Rob Herring <robh@kernel.org>

authored by

Andy Shevchenko and committed by
Rob Herring
ca5a75df 780967fe

+6 -3
+1 -1
drivers/acpi/arm64/amba.c
··· 101 101 if (parent) 102 102 dev->dev.parent = acpi_get_first_physical_node(parent); 103 103 104 - ACPI_COMPANION_SET(&dev->dev, adev); 104 + device_set_node(&dev->dev, acpi_fwnode_handle(adev)); 105 105 106 106 ret = amba_device_add(dev, &iomem_resource); 107 107 if (ret) {
+4 -1
drivers/amba/bus.c
··· 18 18 #include <linux/limits.h> 19 19 #include <linux/clk/clk-conf.h> 20 20 #include <linux/platform_device.h> 21 + #include <linux/property.h> 21 22 #include <linux/reset.h> 22 23 #include <linux/of_irq.h> 23 24 #include <linux/of_device.h> ··· 529 528 { 530 529 struct amba_device *d = to_amba_device(dev); 531 530 532 - of_node_put(d->dev.of_node); 531 + fwnode_handle_put(dev_fwnode(&d->dev)); 533 532 if (d->res.parent) 534 533 release_resource(&d->res); 535 534 mutex_destroy(&d->periphid_lock); ··· 548 547 int amba_device_add(struct amba_device *dev, struct resource *parent) 549 548 { 550 549 int ret; 550 + 551 + fwnode_handle_get(dev_fwnode(&dev->dev)); 551 552 552 553 ret = request_resource(parent, &dev->res); 553 554 if (ret)
+1 -1
drivers/of/platform.c
··· 273 273 dev->dev.dma_mask = &dev->dev.coherent_dma_mask; 274 274 275 275 /* setup generic device info */ 276 - device_set_node(&dev->dev, of_fwnode_handle(of_node_get(node))); 276 + device_set_node(&dev->dev, of_fwnode_handle(node)); 277 277 dev->dev.parent = parent ? : &platform_bus; 278 278 dev->dev.platform_data = platform_data; 279 279 if (bus_id)