]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soc: qcom: ice: use scoped device node handling to simplify error paths
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 13 Aug 2024 13:09:49 +0000 (15:09 +0200)
committerBjorn Andersson <andersson@kernel.org>
Thu, 15 Aug 2024 03:14:43 +0000 (22:14 -0500)
Obtain the device node reference with scoped/cleanup.h to reduce error
handling and make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240813-b4-cleanup-h-of-node-put-other-v1-3-cfb67323a95c@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/soc/qcom/ice.c

index fbab7fe5c652b93e431acdfc0faa73fb1a56f059..50be7a9274a14e847d8a63cc0ce4017cd2072292 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/bitfield.h>
+#include <linux/cleanup.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/iopoll.h>
@@ -265,7 +266,6 @@ struct qcom_ice *of_qcom_ice_get(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct qcom_ice *ice;
-       struct device_node *node;
        struct resource *res;
        void __iomem *base;
 
@@ -292,15 +292,15 @@ struct qcom_ice *of_qcom_ice_get(struct device *dev)
         * (legacy DT binding), then it must at least provide a phandle
         * to the ICE devicetree node, otherwise ICE is not supported.
         */
-       node = of_parse_phandle(dev->of_node, "qcom,ice", 0);
+       struct device_node *node __free(device_node) = of_parse_phandle(dev->of_node,
+                                                                       "qcom,ice", 0);
        if (!node)
                return NULL;
 
        pdev = of_find_device_by_node(node);
        if (!pdev) {
                dev_err(dev, "Cannot find device node %s\n", node->name);
-               ice = ERR_PTR(-EPROBE_DEFER);
-               goto out;
+               return ERR_PTR(-EPROBE_DEFER);
        }
 
        ice = platform_get_drvdata(pdev);
@@ -308,8 +308,7 @@ struct qcom_ice *of_qcom_ice_get(struct device *dev)
                dev_err(dev, "Cannot get ice instance from %s\n",
                        dev_name(&pdev->dev));
                platform_device_put(pdev);
-               ice = ERR_PTR(-EPROBE_DEFER);
-               goto out;
+               return ERR_PTR(-EPROBE_DEFER);
        }
 
        ice->link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER);
@@ -321,9 +320,6 @@ struct qcom_ice *of_qcom_ice_get(struct device *dev)
                ice = ERR_PTR(-EINVAL);
        }
 
-out:
-       of_node_put(node);
-
        return ice;
 }
 EXPORT_SYMBOL_GPL(of_qcom_ice_get);