All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] i2c: stm32: Simplify with dev_err_probe()
@ 2020-09-02 15:06 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 78+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-02 15:06 UTC (permalink / raw)
  To: Nicolas Saenz Julienne, Florian Fainelli, Ray Jui, Scott Branden,
	bcm-kernel-feedback-list, Michal Simek, Sekhar Nori,
	Bartosz Golaszewski, Oleksij Rempel, Pengutronix Kernel Team,
	Shawn Guo, Sascha Hauer, Fabio Estevam, NXP Linux Team,
	Heiko Stuebner, Pierre-Yves MORDRET, Maxime Coquelin,
	Alexandre Torgue, Peter Rosin, Wolfram Sang, linux-i2c,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel, linux-rockchip,
	linux-stm32
  Cc: 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>
---
 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(-)

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;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 78+ messages in thread

end of thread, other threads:[~2021-06-23 16:28 UTC | newest]

Thread overview: 78+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02 15:06 [PATCH 1/9] i2c: stm32: Simplify with dev_err_probe() Krzysztof Kozlowski
2020-09-02 15:06 ` Krzysztof Kozlowski
2020-09-02 15:06 ` Krzysztof Kozlowski
2020-09-02 15:06 ` [PATCH 2/9] i2c: xiic: " Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2021-06-23  8:57   ` Michal Simek
2021-06-23  8:57     ` Michal Simek
2021-06-23  8:57     ` Michal Simek
2021-06-23 16:26   ` Wolfram Sang
2021-06-23 16:26     ` Wolfram Sang
2021-06-23 16:26     ` Wolfram Sang
2020-09-02 15:06 ` [PATCH 3/9] i2c: bcm2835: " Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:24   ` Florian Fainelli
2020-09-02 15:24     ` Florian Fainelli
2020-09-02 15:24     ` Florian Fainelli
2020-09-10  6:25   ` Wolfram Sang
2020-09-10  6:25     ` Wolfram Sang
2020-09-10  6:25     ` Wolfram Sang
2020-09-02 15:06 ` [PATCH 4/9] i2c: cadence: " Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2021-06-23  8:59   ` Michal Simek
2021-06-23  8:59     ` Michal Simek
2021-06-23  8:59     ` Michal Simek
2021-06-23 16:26   ` Wolfram Sang
2021-06-23 16:26     ` Wolfram Sang
2021-06-23 16:26     ` Wolfram Sang
2020-09-02 15:06 ` [PATCH 5/9] i2c: davinci: " Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2021-06-23 16:26   ` Wolfram Sang
2021-06-23 16:26     ` Wolfram Sang
2021-06-23 16:26     ` Wolfram Sang
2020-09-02 15:06 ` [PATCH 6/9] i2c: imx: " Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 17:58   ` Uwe Kleine-König
2020-09-02 17:58     ` Uwe Kleine-König
2020-09-02 17:58     ` Uwe Kleine-König
2020-09-03  5:36   ` Oleksij Rempel
2020-09-03  5:36     ` Oleksij Rempel
2020-09-03  5:36     ` Oleksij Rempel
2020-09-10  6:27   ` Wolfram Sang
2020-09-10  6:27     ` Wolfram Sang
2020-09-10  6:27     ` Wolfram Sang
2020-09-02 15:06 ` [PATCH 7/9] i2c: rk3x: " Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-22 14:25   ` Heiko Stübner
2020-09-22 14:25     ` Heiko Stübner
2020-09-22 14:25     ` Heiko Stübner
2020-09-27 18:01   ` Wolfram Sang
2020-09-27 18:01     ` Wolfram Sang
2020-09-27 18:01     ` Wolfram Sang
2020-09-02 15:06 ` [PATCH 8/9] i2c: mux: gpmux: " Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 18:33   ` Peter Rosin
2020-09-02 18:33     ` Peter Rosin
2020-09-02 18:33     ` Peter Rosin
2020-09-10  6:24   ` Wolfram Sang
2020-09-10  6:24     ` Wolfram Sang
2020-09-10  6:24     ` Wolfram Sang
2020-09-02 15:06 ` [PATCH 9/9] i2c: mux: reg: " Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 15:06   ` Krzysztof Kozlowski
2020-09-02 18:33   ` Peter Rosin
2020-09-02 18:33     ` Peter Rosin
2020-09-02 18:33     ` Peter Rosin
2020-09-10  6:24   ` Wolfram Sang
2020-09-10  6:24     ` Wolfram Sang
2020-09-10  6:24     ` Wolfram Sang
2020-09-10  9:36 ` [PATCH 1/9] i2c: stm32: " Alain Volmat
2020-09-10  9:36   ` Alain Volmat
2020-09-10  9:36   ` Alain Volmat

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.