Re: [PATCH 07/11] usb: dwc3: qcom: use scoped device node handling to simplify error paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 14, 2024, Krzysztof Kozlowski wrote:
> 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@xxxxxxxxxx>
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 88fb6706a18d..03a8f080078e 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -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;
>  }
>  
> 
> -- 
> 2.43.0
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>

Thanks,
Thinh




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux