diff mbox series

[3/3] pwm: bcm2835: suppress error message during deferred probe

Message ID 1566630445-4599-4-git-send-email-wahrenst@gmx.net
State Superseded
Headers show
Series pwm: bcm2835: Minor fixes | expand

Commit Message

Stefan Wahren Aug. 24, 2019, 7:07 a.m. UTC
This suppresses error messages in case the PWM clock isn't ready yet.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/pwm/pwm-bcm2835.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--
2.7.4

Comments

Uwe Kleine-König Aug. 24, 2019, 9:30 a.m. UTC | #1
On Sat, Aug 24, 2019 at 09:07:25AM +0200, Stefan Wahren wrote:
> This suppresses error messages in case the PWM clock isn't ready yet.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
>  drivers/pwm/pwm-bcm2835.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
> index 2c82386..ce362be 100644
> --- a/drivers/pwm/pwm-bcm2835.c
> +++ b/drivers/pwm/pwm-bcm2835.c
> @@ -153,7 +153,10 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
> 
>  	pc->clk = devm_clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(pc->clk)) {
> -		dev_err(&pdev->dev, "clock not found: %ld\n", PTR_ERR(pc->clk));
> +		if (PTR_ERR(pc->clk) != -EPROBE_DEFER) {
> +			dev_err(&pdev->dev, "clock not found: %ld\n",
> +				PTR_ERR(pc->clk));
> +		}
>  		return PTR_ERR(pc->clk);
>  	}

I would have used:

	if (IS_ERR(pc->clk)) {
		int err = PTR_ERR(pc->clk);
		if (err != -EPROBE_DEFER)
			dev_err(&pdev->dev, "clock not found: %d\n", err);

		return err;
	}

This calculates the error code only once and make the dev_err line short
enough to not make it necessary to add a line break.

Best regards
Uwe
Stefan Wahren Aug. 24, 2019, 9:44 a.m. UTC | #2
Am 24.08.19 um 11:30 schrieb Uwe Kleine-König:
> On Sat, Aug 24, 2019 at 09:07:25AM +0200, Stefan Wahren wrote:
>> This suppresses error messages in case the PWM clock isn't ready yet.
>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>>  drivers/pwm/pwm-bcm2835.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
>> index 2c82386..ce362be 100644
>> --- a/drivers/pwm/pwm-bcm2835.c
>> +++ b/drivers/pwm/pwm-bcm2835.c
>> @@ -153,7 +153,10 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
>>
>>  	pc->clk = devm_clk_get(&pdev->dev, NULL);
>>  	if (IS_ERR(pc->clk)) {
>> -		dev_err(&pdev->dev, "clock not found: %ld\n", PTR_ERR(pc->clk));
>> +		if (PTR_ERR(pc->clk) != -EPROBE_DEFER) {
>> +			dev_err(&pdev->dev, "clock not found: %ld\n",
>> +				PTR_ERR(pc->clk));
>> +		}
>>  		return PTR_ERR(pc->clk);
>>  	}
> I would have used:
>
> 	if (IS_ERR(pc->clk)) {
> 		int err = PTR_ERR(pc->clk);
> 		if (err != -EPROBE_DEFER)
> 			dev_err(&pdev->dev, "clock not found: %d\n", err);
>
> 		return err;
> 	}
>
> This calculates the error code only once and make the dev_err line short
> enough to not make it necessary to add a line break.
Sure that's better. Will send V2 soon
>
> Best regards
> Uwe
>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index 2c82386..ce362be 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -153,7 +153,10 @@  static int bcm2835_pwm_probe(struct platform_device *pdev)

 	pc->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pc->clk)) {
-		dev_err(&pdev->dev, "clock not found: %ld\n", PTR_ERR(pc->clk));
+		if (PTR_ERR(pc->clk) != -EPROBE_DEFER) {
+			dev_err(&pdev->dev, "clock not found: %ld\n",
+				PTR_ERR(pc->clk));
+		}
 		return PTR_ERR(pc->clk);
 	}