diff mbox series

[1/9] i2c: stm32: Simplify with dev_err_probe()

Message ID 20200902150643.14839-1-krzk@kernel.org
State New
Headers show
Series [1/9] i2c: stm32: Simplify with dev_err_probe() | expand

Commit Message

Krzysztof Kozlowski Sept. 2, 2020, 3:06 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>
---
 drivers/i2c/busses/i2c-stm32.c   | 11 ++++-------
 drivers/i2c/busses/i2c-stm32f4.c |  6 ++----
 drivers/i2c/busses/i2c-stm32f7.c | 24 +++++++++---------------
 3 files changed, 15 insertions(+), 26 deletions(-)

Comments

Uwe Kleine-König Sept. 2, 2020, 5:58 p.m. UTC | #1
On Wed, Sep 02, 2020 at 05:06:40PM +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>

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks
Uwe
Peter Rosin Sept. 2, 2020, 6:33 p.m. UTC | #2
On 2020-09-02 17:06, 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>

Acked-by: Peter Rosin <peda@axentia.se>

Cheers,
Peter
Heiko Stuebner Sept. 22, 2020, 2:25 p.m. UTC | #3
Am Mittwoch, 2. September 2020, 17:06:41 CEST schrieb Krzysztof Kozlowski:
> 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>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Wolfram Sang Sept. 27, 2020, 6:01 p.m. UTC | #4
On Wed, Sep 02, 2020 at 05:06:41PM +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>

Applied to for-next, thanks!
Michal Simek June 23, 2021, 8:57 a.m. UTC | #5
st 2. 9. 2020 v 17:10 odesílatel Krzysztof Kozlowski <krzk@kernel.org> napsal:
>

> 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>

> ---

>  drivers/i2c/busses/i2c-xiic.c | 9 ++++-----

>  1 file changed, 4 insertions(+), 5 deletions(-)

>

> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c

> index 90c1c362394d..a97438f35c5d 100644

> --- a/drivers/i2c/busses/i2c-xiic.c

> +++ b/drivers/i2c/busses/i2c-xiic.c

> @@ -787,11 +787,10 @@ static int xiic_i2c_probe(struct platform_device *pdev)

>         init_waitqueue_head(&i2c->wait);

>

>         i2c->clk = devm_clk_get(&pdev->dev, NULL);

> -       if (IS_ERR(i2c->clk)) {

> -               if (PTR_ERR(i2c->clk) != -EPROBE_DEFER)

> -                       dev_err(&pdev->dev, "input clock not found.\n");

> -               return PTR_ERR(i2c->clk);

> -       }

> +       if (IS_ERR(i2c->clk))

> +               return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),

> +                                    "input clock not found.\n");

> +

>         ret = clk_prepare_enable(i2c->clk);

>         if (ret) {

>                 dev_err(&pdev->dev, "Unable to enable clock.\n");

> --

> 2.17.1

>

>

> _______________________________________________

> linux-arm-kernel mailing list

> linux-arm-kernel@lists.infradead.org

> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


I see that this didn't go through.
Acked-by: Michal Simek <michal.simek@xilinx.com>


Wolfram: Can you please apply?

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
Wolfram Sang June 23, 2021, 4:26 p.m. UTC | #6
On Wed, Sep 02, 2020 at 05:06:36PM +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>


Applied to for-next, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-stm32.c b/drivers/i2c/busses/i2c-stm32.c
index 3f69a3bb6119..198f848b7be9 100644
--- a/drivers/i2c/busses/i2c-stm32.c
+++ b/drivers/i2c/busses/i2c-stm32.c
@@ -25,9 +25,8 @@  struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
 	/* Request and configure I2C TX dma channel */
 	dma->chan_tx = dma_request_chan(dev, "tx");
 	if (IS_ERR(dma->chan_tx)) {
-		ret = PTR_ERR(dma->chan_tx);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "can't request DMA tx channel\n");
+		ret = dev_err_probe(dev, PTR_ERR(dma->chan_tx),
+				    "can't request DMA tx channel\n");
 		goto fail_al;
 	}
 
@@ -45,10 +44,8 @@  struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
 	/* Request and configure I2C RX dma channel */
 	dma->chan_rx = dma_request_chan(dev, "rx");
 	if (IS_ERR(dma->chan_rx)) {
-		ret = PTR_ERR(dma->chan_rx);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "can't request DMA rx channel\n");
-
+		ret = dev_err_probe(dev, PTR_ERR(dma->chan_rx),
+				    "can't request DMA rx channel\n");
 		goto fail_tx;
 	}
 
diff --git a/drivers/i2c/busses/i2c-stm32f4.c b/drivers/i2c/busses/i2c-stm32f4.c
index 48e269284369..937c2c8fd349 100644
--- a/drivers/i2c/busses/i2c-stm32f4.c
+++ b/drivers/i2c/busses/i2c-stm32f4.c
@@ -797,10 +797,8 @@  static int stm32f4_i2c_probe(struct platform_device *pdev)
 
 	rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
 	if (IS_ERR(rst)) {
-		ret = PTR_ERR(rst);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Error: Missing reset ctrl\n");
-
+		ret = dev_err_probe(&pdev->dev, PTR_ERR(rst),
+				    "Error: Missing reset ctrl\n");
 		goto clk_free;
 	}
 	reset_control_assert(rst);
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index bff3479fe122..a8f1758e4c5b 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -1968,11 +1968,9 @@  static int stm32f7_i2c_probe(struct platform_device *pdev)
 						    "wakeup-source");
 
 	i2c_dev->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(i2c_dev->clk)) {
-		if (PTR_ERR(i2c_dev->clk) != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to get controller clock\n");
-		return PTR_ERR(i2c_dev->clk);
-	}
+	if (IS_ERR(i2c_dev->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->clk),
+				     "Failed to get controller clock\n");
 
 	ret = clk_prepare_enable(i2c_dev->clk);
 	if (ret) {
@@ -1982,10 +1980,8 @@  static int stm32f7_i2c_probe(struct platform_device *pdev)
 
 	rst = devm_reset_control_get(&pdev->dev, NULL);
 	if (IS_ERR(rst)) {
-		ret = PTR_ERR(rst);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Error: Missing reset ctrl\n");
-
+		ret = dev_err_probe(&pdev->dev, PTR_ERR(rst),
+				    "Error: Missing reset ctrl\n");
 		goto clk_free;
 	}
 	reset_control_assert(rst);
@@ -2052,13 +2048,11 @@  static int stm32f7_i2c_probe(struct platform_device *pdev)
 	i2c_dev->dma = stm32_i2c_dma_request(i2c_dev->dev, phy_addr,
 					     STM32F7_I2C_TXDR,
 					     STM32F7_I2C_RXDR);
-	if (PTR_ERR(i2c_dev->dma) == -ENODEV)
+	if (PTR_ERR(i2c_dev->dma) == -ENODEV) {
 		i2c_dev->dma = NULL;
-	else if (IS_ERR(i2c_dev->dma)) {
-		ret = PTR_ERR(i2c_dev->dma);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"Failed to request dma error %i\n", ret);
+	} else if (IS_ERR(i2c_dev->dma)) {
+		ret = dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->dma),
+				    "Failed to request dma error\n");
 		goto fmp_clear;
 	}