]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: dwc3: qcom: use scoped device node handling to simplify error paths
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Wed, 14 Aug 2024 10:35:43 +0000 (12:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Sep 2024 07:52:45 +0000 (09:52 +0200)
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>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/20240814-b4-cleanup-h-of-node-put-usb-v1-7-95481b9682bc@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/dwc3-qcom.c

index 88fb6706a18d38dc495f089aa706124314919279..03a8f080078e0e84dc2d1bd75e99933c668ef1ea 100644 (file)
@@ -4,6 +4,7 @@
  * Inspired by dwc3-of-simple.c
  */
 
+#include <linux/cleanup.h>
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/clk.h>
@@ -702,11 +703,12 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 static int dwc3_qcom_of_register_core(struct platform_device *pdev)
 {
        struct dwc3_qcom        *qcom = platform_get_drvdata(pdev);
-       struct device_node      *np = pdev->dev.of_node, *dwc3_np;
+       struct device_node      *np = pdev->dev.of_node;
        struct device           *dev = &pdev->dev;
        int                     ret;
 
-       dwc3_np = of_get_compatible_child(np, "snps,dwc3");
+       struct device_node *dwc3_np __free(device_node) = of_get_compatible_child(np,
+                                                                                 "snps,dwc3");
        if (!dwc3_np) {
                dev_err(dev, "failed to find dwc3 core child\n");
                return -ENODEV;
@@ -715,7 +717,7 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
        ret = of_platform_populate(np, NULL, NULL, dev);
        if (ret) {
                dev_err(dev, "failed to register dwc3 core - %d\n", ret);
-               goto node_put;
+               return ret;
        }
 
        qcom->dwc3 = of_find_device_by_node(dwc3_np);
@@ -725,9 +727,6 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
                of_platform_depopulate(dev);
        }
 
-node_put:
-       of_node_put(dwc3_np);
-
        return ret;
 }