diff mbox series

[02/11] usb: dwc3: st: simplify with dev_err_probe

Message ID 20240814-b4-cleanup-h-of-node-put-usb-v1-2-95481b9682bc@linaro.org (mailing list archive)
State Not Applicable
Headers show
Series usb: dwc3: various cleanups | expand

Commit Message

Krzysztof Kozlowski Aug. 14, 2024, 10:35 a.m. UTC
Use dev_err_probe() to make the error paths a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/usb/dwc3/dwc3-st.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Patrice CHOTARD Aug. 14, 2024, 3:44 p.m. UTC | #1
On 8/14/24 12:35, Krzysztof Kozlowski wrote:
> Use dev_err_probe() to make the error paths a bit simpler.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  drivers/usb/dwc3/dwc3-st.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> index 98f43d7082d7..7a0b1821768a 100644
> --- a/drivers/usb/dwc3/dwc3-st.c
> +++ b/drivers/usb/dwc3/dwc3-st.c
> @@ -237,10 +237,9 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  
>  	dwc3_data->rstc_pwrdn =
>  		devm_reset_control_get_exclusive(dev, "powerdown");
> -	if (IS_ERR(dwc3_data->rstc_pwrdn)) {
> -		dev_err(&pdev->dev, "could not get power controller\n");
> -		return PTR_ERR(dwc3_data->rstc_pwrdn);
> -	}
> +	if (IS_ERR(dwc3_data->rstc_pwrdn))
> +		return dev_err_probe(dev, PTR_ERR(dwc3_data->rstc_pwrdn),
> +				     "could not get power controller\n");
>  
>  	/* Manage PowerDown */
>  	reset_control_deassert(dwc3_data->rstc_pwrdn);
> @@ -248,8 +247,8 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	dwc3_data->rstc_rst =
>  		devm_reset_control_get_shared(dev, "softreset");
>  	if (IS_ERR(dwc3_data->rstc_rst)) {
> -		dev_err(&pdev->dev, "could not get reset controller\n");
> -		ret = PTR_ERR(dwc3_data->rstc_rst);
> +		ret = dev_err_probe(dev, PTR_ERR(dwc3_data->rstc_rst),
> +				    "could not get reset controller\n");
>  		goto undo_powerdown;
>  	}
>  
> 


Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
Thinh Nguyen Aug. 27, 2024, 1:19 a.m. UTC | #2
On Wed, Aug 14, 2024, Krzysztof Kozlowski wrote:
> Use dev_err_probe() to make the error paths a bit simpler.

I think it makes more sense to note that this helps with cases of
-EPROBE_DEFER than making this simpler. Regardless, this is an
improvement.

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  drivers/usb/dwc3/dwc3-st.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> index 98f43d7082d7..7a0b1821768a 100644
> --- a/drivers/usb/dwc3/dwc3-st.c
> +++ b/drivers/usb/dwc3/dwc3-st.c
> @@ -237,10 +237,9 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  
>  	dwc3_data->rstc_pwrdn =
>  		devm_reset_control_get_exclusive(dev, "powerdown");
> -	if (IS_ERR(dwc3_data->rstc_pwrdn)) {
> -		dev_err(&pdev->dev, "could not get power controller\n");
> -		return PTR_ERR(dwc3_data->rstc_pwrdn);
> -	}
> +	if (IS_ERR(dwc3_data->rstc_pwrdn))
> +		return dev_err_probe(dev, PTR_ERR(dwc3_data->rstc_pwrdn),
> +				     "could not get power controller\n");
>  
>  	/* Manage PowerDown */
>  	reset_control_deassert(dwc3_data->rstc_pwrdn);
> @@ -248,8 +247,8 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	dwc3_data->rstc_rst =
>  		devm_reset_control_get_shared(dev, "softreset");
>  	if (IS_ERR(dwc3_data->rstc_rst)) {
> -		dev_err(&pdev->dev, "could not get reset controller\n");
> -		ret = PTR_ERR(dwc3_data->rstc_rst);
> +		ret = dev_err_probe(dev, PTR_ERR(dwc3_data->rstc_rst),
> +				    "could not get reset controller\n");
>  		goto undo_powerdown;
>  	}
>  
> 
> -- 
> 2.43.0
>
Krzysztof Kozlowski Aug. 27, 2024, 9:35 a.m. UTC | #3
On 27/08/2024 03:19, Thinh Nguyen wrote:
> On Wed, Aug 14, 2024, Krzysztof Kozlowski wrote:
>> Use dev_err_probe() to make the error paths a bit simpler.
> 
> I think it makes more sense to note that this helps with cases of
> -EPROBE_DEFER than making this simpler. Regardless, this is an
> improvement.
> 
> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Yeah, I forgot about this argument. Getting resets can defer, so this
actually solves the dmesg flood for deferred probes.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index 98f43d7082d7..7a0b1821768a 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -237,10 +237,9 @@  static int st_dwc3_probe(struct platform_device *pdev)
 
 	dwc3_data->rstc_pwrdn =
 		devm_reset_control_get_exclusive(dev, "powerdown");
-	if (IS_ERR(dwc3_data->rstc_pwrdn)) {
-		dev_err(&pdev->dev, "could not get power controller\n");
-		return PTR_ERR(dwc3_data->rstc_pwrdn);
-	}
+	if (IS_ERR(dwc3_data->rstc_pwrdn))
+		return dev_err_probe(dev, PTR_ERR(dwc3_data->rstc_pwrdn),
+				     "could not get power controller\n");
 
 	/* Manage PowerDown */
 	reset_control_deassert(dwc3_data->rstc_pwrdn);
@@ -248,8 +247,8 @@  static int st_dwc3_probe(struct platform_device *pdev)
 	dwc3_data->rstc_rst =
 		devm_reset_control_get_shared(dev, "softreset");
 	if (IS_ERR(dwc3_data->rstc_rst)) {
-		dev_err(&pdev->dev, "could not get reset controller\n");
-		ret = PTR_ERR(dwc3_data->rstc_rst);
+		ret = dev_err_probe(dev, PTR_ERR(dwc3_data->rstc_rst),
+				    "could not get reset controller\n");
 		goto undo_powerdown;
 	}