Skip to content

Commit a85f13d

Browse files
krzkgregkh
authored andcommitted
usb: dwc3: qcom: use scoped device node handling to simplify error paths
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>
1 parent 34e8df2 commit a85f13d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/usb/dwc3/dwc3-qcom.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Inspired by dwc3-of-simple.c
55
*/
66

7+
#include <linux/cleanup.h>
78
#include <linux/io.h>
89
#include <linux/of.h>
910
#include <linux/clk.h>
@@ -702,11 +703,12 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
702703
static int dwc3_qcom_of_register_core(struct platform_device *pdev)
703704
{
704705
struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
705-
struct device_node *np = pdev->dev.of_node, *dwc3_np;
706+
struct device_node *np = pdev->dev.of_node;
706707
struct device *dev = &pdev->dev;
707708
int ret;
708709

709-
dwc3_np = of_get_compatible_child(np, "snps,dwc3");
710+
struct device_node *dwc3_np __free(device_node) = of_get_compatible_child(np,
711+
"snps,dwc3");
710712
if (!dwc3_np) {
711713
dev_err(dev, "failed to find dwc3 core child\n");
712714
return -ENODEV;
@@ -715,7 +717,7 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
715717
ret = of_platform_populate(np, NULL, NULL, dev);
716718
if (ret) {
717719
dev_err(dev, "failed to register dwc3 core - %d\n", ret);
718-
goto node_put;
720+
return ret;
719721
}
720722

721723
qcom->dwc3 = of_find_device_by_node(dwc3_np);
@@ -725,9 +727,6 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
725727
of_platform_depopulate(dev);
726728
}
727729

728-
node_put:
729-
of_node_put(dwc3_np);
730-
731730
return ret;
732731
}
733732

0 commit comments

Comments
 (0)