diff mbox series

[9/9] i2c: synquacer: Use dev_err_probe in probe function

Message ID 20230728013148.1720978-10-liaochang1@huawei.com
State New
Headers show
Series Use dev_err_probe in i2c probe function | expand

Commit Message

Liao Chang July 28, 2023, 1:31 a.m. UTC
Use the dev_err_probe function instead of dev_err in the probe function
so that the printed messge includes the return value and also handles
-EPROBE_DEFER nicely.

Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
 drivers/i2c/busses/i2c-synquacer.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Andi Shyti Aug. 1, 2023, 9:44 p.m. UTC | #1
Hi Liao,

On Fri, Jul 28, 2023 at 09:31:48AM +0800, Liao Chang wrote:
> Use the dev_err_probe function instead of dev_err in the probe function
> so that the printed messge includes the return value and also handles
> -EPROBE_DEFER nicely.
> 
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
>  drivers/i2c/busses/i2c-synquacer.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
> index 4cc196ca8f6d..cc2af638bfdd 100644
> --- a/drivers/i2c/busses/i2c-synquacer.c
> +++ b/drivers/i2c/busses/i2c-synquacer.c
> @@ -557,11 +557,8 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
>  		dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk);
>  
>  		ret = clk_prepare_enable(i2c->pclk);
> -		if (ret) {
> -			dev_err(&pdev->dev, "failed to enable clock (%d)\n",
> -				ret);
> -			return ret;
> -		}
> +		if (ret)
> +			return dev_err_probe(&pdev->dev, ret, "failed to enable clock\n");
>  		i2c->pclkrate = clk_get_rate(i2c->pclk);
>  	}

here you forgot a few, as well.

Andi
Liao Chang Aug. 2, 2023, 7:03 a.m. UTC | #2
在 2023/8/2 5:44, Andi Shyti 写道:
> Hi Liao,
> 
> On Fri, Jul 28, 2023 at 09:31:48AM +0800, Liao Chang wrote:
>> Use the dev_err_probe function instead of dev_err in the probe function
>> so that the printed messge includes the return value and also handles
>> -EPROBE_DEFER nicely.
>>
>> Signed-off-by: Liao Chang <liaochang1@huawei.com>
>> ---
>>  drivers/i2c/busses/i2c-synquacer.c | 7 ++-----
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
>> index 4cc196ca8f6d..cc2af638bfdd 100644
>> --- a/drivers/i2c/busses/i2c-synquacer.c
>> +++ b/drivers/i2c/busses/i2c-synquacer.c
>> @@ -557,11 +557,8 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
>>  		dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk);
>>  
>>  		ret = clk_prepare_enable(i2c->pclk);
>> -		if (ret) {
>> -			dev_err(&pdev->dev, "failed to enable clock (%d)\n",
>> -				ret);
>> -			return ret;
>> -		}
>> +		if (ret)
>> +			return dev_err_probe(&pdev->dev, ret, "failed to enable clock\n");
>>  		i2c->pclkrate = clk_get_rate(i2c->pclk);
>>  	}
> 
> here you forgot a few, as well.

Thanks for your feedback, i will improve these patches in next revision.

> 
> Andi
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
index 4cc196ca8f6d..cc2af638bfdd 100644
--- a/drivers/i2c/busses/i2c-synquacer.c
+++ b/drivers/i2c/busses/i2c-synquacer.c
@@ -557,11 +557,8 @@  static int synquacer_i2c_probe(struct platform_device *pdev)
 		dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk);
 
 		ret = clk_prepare_enable(i2c->pclk);
-		if (ret) {
-			dev_err(&pdev->dev, "failed to enable clock (%d)\n",
-				ret);
-			return ret;
-		}
+		if (ret)
+			return dev_err_probe(&pdev->dev, ret, "failed to enable clock\n");
 		i2c->pclkrate = clk_get_rate(i2c->pclk);
 	}