diff mbox series

[v2,4/4] crypto: allwinner/sun8i - Simplify with dev_err_probe()

Message ID 20200910192919.12503-4-krzk@kernel.org
State Accepted
Commit e61a23564e6fa709c5519bbe157ccf67af9c521f
Headers show
Series None | expand

Commit Message

Krzysztof Kozlowski Sept. 10, 2020, 7:29 p.m. UTC
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and the error value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

Changes since v1:
1. None
---
 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 9 +++------
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 9 +++------
 2 files changed, 6 insertions(+), 12 deletions(-)

Comments

Corentin Labbe Sept. 16, 2020, 9:33 a.m. UTC | #1
On Thu, Sep 10, 2020 at 09:29:19PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with

> dev_err_probe().  Less code and the error value gets printed.

> 

> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

> 

> ---

> 

> Changes since v1:

> 1. None

> ---

>  drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 9 +++------

>  drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 9 +++------

>  2 files changed, 6 insertions(+), 12 deletions(-)

> 

> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c

> index 138759dc8190..e3c62051c595 100644

> --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c

> +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c

> @@ -573,12 +573,9 @@ static int sun8i_ce_probe(struct platform_device *pdev)

>  		return irq;

>  

>  	ce->reset = devm_reset_control_get(&pdev->dev, NULL);

> -	if (IS_ERR(ce->reset)) {

> -		if (PTR_ERR(ce->reset) == -EPROBE_DEFER)

> -			return PTR_ERR(ce->reset);

> -		dev_err(&pdev->dev, "No reset control found\n");

> -		return PTR_ERR(ce->reset);

> -	}

> +	if (IS_ERR(ce->reset))

> +		return dev_err_probe(&pdev->dev, PTR_ERR(ce->reset),

> +				     "No reset control found\n");

>  

>  	mutex_init(&ce->mlock);

>  

> diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c

> index 9a23515783a6..576df8c8df51 100644

> --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c

> +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c

> @@ -545,12 +545,9 @@ static int sun8i_ss_probe(struct platform_device *pdev)

>  		return irq;

>  

>  	ss->reset = devm_reset_control_get(&pdev->dev, NULL);

> -	if (IS_ERR(ss->reset)) {

> -		if (PTR_ERR(ss->reset) == -EPROBE_DEFER)

> -			return PTR_ERR(ss->reset);

> -		dev_err(&pdev->dev, "No reset control found\n");

> -		return PTR_ERR(ss->reset);

> -	}

> +	if (IS_ERR(ss->reset))

> +		return dev_err_probe(&pdev->dev, PTR_ERR(ss->reset),

> +				     "No reset control found\n");

>  

>  	mutex_init(&ss->mlock);

>  

> -- 

> 2.17.1

> 


Hello

Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>

Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>


Thanks
diff mbox series

Patch

diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
index 138759dc8190..e3c62051c595 100644
--- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
+++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
@@ -573,12 +573,9 @@  static int sun8i_ce_probe(struct platform_device *pdev)
 		return irq;
 
 	ce->reset = devm_reset_control_get(&pdev->dev, NULL);
-	if (IS_ERR(ce->reset)) {
-		if (PTR_ERR(ce->reset) == -EPROBE_DEFER)
-			return PTR_ERR(ce->reset);
-		dev_err(&pdev->dev, "No reset control found\n");
-		return PTR_ERR(ce->reset);
-	}
+	if (IS_ERR(ce->reset))
+		return dev_err_probe(&pdev->dev, PTR_ERR(ce->reset),
+				     "No reset control found\n");
 
 	mutex_init(&ce->mlock);
 
diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
index 9a23515783a6..576df8c8df51 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
@@ -545,12 +545,9 @@  static int sun8i_ss_probe(struct platform_device *pdev)
 		return irq;
 
 	ss->reset = devm_reset_control_get(&pdev->dev, NULL);
-	if (IS_ERR(ss->reset)) {
-		if (PTR_ERR(ss->reset) == -EPROBE_DEFER)
-			return PTR_ERR(ss->reset);
-		dev_err(&pdev->dev, "No reset control found\n");
-		return PTR_ERR(ss->reset);
-	}
+	if (IS_ERR(ss->reset))
+		return dev_err_probe(&pdev->dev, PTR_ERR(ss->reset),
+				     "No reset control found\n");
 
 	mutex_init(&ss->mlock);