With no drivers that manually assign software nodes to platform devices
created with platform_device_alloc(), we can now unify the release path
and remove platform_device_release_full().

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
 drivers/base/platform.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 
fb57d487a6c2aba799b4ca5ccd089006cf2d8bf6..66f9ec73d47e90cecac9217ff6e0f051fea5b057
 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -599,19 +599,19 @@ static void platform_device_release(struct device *dev)
        struct platform_object *pa = container_of(dev, struct platform_object,
                                                  pdev.dev);
 
-       fwnode_handle_put(pa->pdev.dev.fwnode);
+       device_remove_software_node(dev);
+       /*
+        * If the primary firmware node is a software node, its reference count
+        * was already decreased by the call to device_remove_software_node().
+        */
+       if (!is_software_node(dev_fwnode(dev)))
+               fwnode_handle_put(pa->pdev.dev.fwnode);
        kfree(pa->pdev.dev.platform_data);
        kfree(pa->pdev.mfd_cell);
        kfree(pa->pdev.resource);
        kfree(pa);
 }
 
-static void platform_device_release_full(struct device *dev)
-{
-       device_remove_software_node(dev);
-       platform_device_release(dev);
-}
-
 /**
  * platform_device_alloc - create a platform device
  * @name: base name of the device we're adding
@@ -960,8 +960,6 @@ struct platform_device *platform_device_register_full(const 
struct platform_devi
                ret = device_add_software_node(&pdev->dev, pdevinfo->swnode);
                if (ret)
                        goto err;
-
-               pdev->dev.release = platform_device_release_full;
        } else if (pdevinfo->properties) {
                ret = device_create_managed_software_node(&pdev->dev,
                                                          pdevinfo->properties, 
NULL);

-- 
2.47.3

Reply via email to