Avoid meaningless DMA error print & use dev_err_probe
Subsystems (3)
cover Avoid meaningless DMA error print & use dev_err_probe
This serie replaces the patch from Holger Assmann [i2c: stm32: remove unnecessary DMA kernel error log] (1) and the first version of [i2c: stm32:
do not display error when DMA is not requested] from myself (2).
A first patch is fixing useless error print when not being able to get DMA channel (DMA is only optional) and also avoid printing twice an error when a real DMA error is happening.
On top of that, dev_err_probe from Krzysztof has been rebased.
[1] https://marc.info/?l=linux-i2c&m=159741480608578&w=2
[2] https://marc.info/?l=linux-i2c&m=159973040314193&w=2
Alain Volmat (1):
i2c: stm32: fix error message on upon dma_request_chan & defer
handling
Krzysztof Kozlowski (1):
i2c: stm32: Simplify with dev_err_probe()
drivers/i2c/busses/i2c-stm32.c | 12 ++++++------ drivers/i2c/busses/i2c-stm32f4.c | 6 ++---- drivers/i2c/busses/i2c-stm32f7.c | 27 +++++++++++---------------- 3 files changed, 19 insertions(+), 26 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 i2c: stm32: fix error message on upon dma_request_chan & defer handling
DMA usage is optional for the I2C driver. check for the -ENODEV error in order to avoid displaying an error when no DMA has been requested.
Cleaning up the error messages during probe, remove the additional -EPROBE_DEFER within probe function since additional error message doesn't give much more information than what is already reported within the stm32_i2c_dma_request function.
---
This patch replaces the patch [i2c: stm32: do not display error when DMA is not requested] previously sent on the mailing list.
--- drivers/i2c/busses/i2c-stm32.c | 6 ++---- drivers/i2c/busses/i2c-stm32f7.c | 13 ++++++------- 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-stm32.c +2 -4
@@ -26,7 +26,7 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, dma->chan_tx =dma_request_chan (dev,"tx" );if (IS_ERR (dma->chan_tx)) { ret =PTR_ERR (dma->chan_tx); -if (ret != -EPROBE_DEFER ) +if ((ret != -ENODEV ) && (ret != -EPROBE_DEFER ))dev_err (dev,"can't request DMA tx channel\n" ); goto fail_al; }
@@ -46,7 +46,7 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, dma->chan_rx =dma_request_chan (dev,"rx" );if (IS_ERR (dma->chan_rx)) { ret =PTR_ERR (dma->chan_rx); -if (ret != -EPROBE_DEFER ) +if ((ret != -ENODEV ) && (ret != -EPROBE_DEFER ))dev_err (dev,"can't request DMA rx channel\n" ); goto fail_tx;
@@ -76,8 +76,6 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,dma_release_channel (dma->chan_tx); fail_al:devm_kfree (dev, dma); -if (ret != -EPROBE_DEFER ) -dev_info (dev,"can't use DMA\n" );return ERR_PTR (ret); }
drivers/i2c/busses/i2c-stm32f7.c +6 -7
@@ -2052,14 +2052,13 @@ 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 ) - i2c_dev->dma =NULL ; -else if (IS_ERR (i2c_dev->dma)) { +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); - goto fmp_clear; +/* DMA support is optional, only report other errors */ +if (ret != -ENODEV ) + goto fmp_clear; +dev_dbg (i2c_dev->dev,"No DMA option: fallback using interrupts\n" ); + i2c_dev->dma =NULL ; }if (i2c_dev->wakeup_src) {
Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/2 i2c: stm32: Simplify with dev_err_probe()
In reply to Alain VolmatFrom: Krzysztof Kozlowski <[email protected]>
Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.
---
v2: rebased on top of patch [i2c: stm32: fix error message on upon dma_request_chan & defer handling]
--- drivers/i2c/busses/i2c-stm32.c | 10 ++++++---- drivers/i2c/busses/i2c-stm32f4.c | 6 ++---- drivers/i2c/busses/i2c-stm32f7.c | 14 +++++--------- 3 files changed, 13 insertions(+), 17 deletions(-)
drivers/i2c/busses/i2c-stm32.c +6 -4
@@ -26,8 +26,9 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, dma->chan_tx =dma_request_chan (dev,"tx" );if (IS_ERR (dma->chan_tx)) { ret =PTR_ERR (dma->chan_tx); -if ((ret != -ENODEV ) && (ret != -EPROBE_DEFER )) -dev_err (dev,"can't request DMA tx channel\n" ); +if (ret != -ENODEV ) + ret =dev_err_probe (dev, ret, +"can't request DMA tx channel\n" ); goto fail_al; }
@@ -46,8 +47,9 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, dma->chan_rx =dma_request_chan (dev,"rx" );if (IS_ERR (dma->chan_rx)) { ret =PTR_ERR (dma->chan_rx); -if ((ret != -ENODEV ) && (ret != -EPROBE_DEFER )) -dev_err (dev,"can't request DMA rx channel\n" ); +if (ret != -ENODEV ) + ret =dev_err_probe (dev, ret, +"can't request DMA rx channel\n" ); goto fail_tx; }
drivers/i2c/busses/i2c-stm32f4.c +2 -4
@@ -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);
drivers/i2c/busses/i2c-stm32f7.c +5 -9
@@ -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);
Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel