diff mbox series

i2c: tegra: Only display error messages if DMA setup fails

Message ID 1550761238-23974-1-git-send-email-jonathanh@nvidia.com
State Deferred
Headers show
Series i2c: tegra: Only display error messages if DMA setup fails | expand

Commit Message

Jon Hunter Feb. 21, 2019, 3 p.m. UTC
From: Jonathan Hunter <jonathanh@nvidia.com>

Commit 86c92b9965ff ("i2c: tegra: Add DMA support") added DMA support
to the Tegra I2C driver for Tegra devices that support the APB DMA
controller. One side-effect of this change is that even for Tegra
devices that do not have an APB DMA controller and hence, cannot
support DMA tranfers for I2C transactions, the following error messages
are still displayed ...

 ERR KERN tegra-i2c 31c0000.i2c: cannot use DMA: -19
 ERR KERN tegra-i2c 31c0000.i2c: falling back to PIO

There is no point displaying the above messages for devices that do not
have an APB DMA controller and so fix this by returning from the
tegra_i2c_init_dma() function if 'has_apb_dma' is not true.

Furthermore, if CONFIG_TEGRA20_APB_DMA is not set, then rather than
printing an error message, print an debug message as for whatever reason
this could be intentional.

Fixes: 86c92b9965ff ("i2c: tegra: Add DMA support")

Signed-off-by: Jonathan Hunter <jonathanh@nvidia.com>
---
 drivers/i2c/busses/i2c-tegra.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Dmitry Osipenko Feb. 22, 2019, 6:20 p.m. UTC | #1
21.02.2019 18:00, Jon Hunter пишет:
> From: Jonathan Hunter <jonathanh@nvidia.com>
> 
> Commit 86c92b9965ff ("i2c: tegra: Add DMA support") added DMA support
> to the Tegra I2C driver for Tegra devices that support the APB DMA
> controller. One side-effect of this change is that even for Tegra
> devices that do not have an APB DMA controller and hence, cannot
> support DMA tranfers for I2C transactions, the following error messages
> are still displayed ...
> 
>  ERR KERN tegra-i2c 31c0000.i2c: cannot use DMA: -19
>  ERR KERN tegra-i2c 31c0000.i2c: falling back to PIO
> 
> There is no point displaying the above messages for devices that do not
> have an APB DMA controller and so fix this by returning from the
> tegra_i2c_init_dma() function if 'has_apb_dma' is not true.
> 
> Furthermore, if CONFIG_TEGRA20_APB_DMA is not set, then rather than
> printing an error message, print an debug message as for whatever reason
> this could be intentional.
> 
> Fixes: 86c92b9965ff ("i2c: tegra: Add DMA support")
> 
> Signed-off-by: Jonathan Hunter <jonathanh@nvidia.com>
> ---
>  drivers/i2c/busses/i2c-tegra.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 31ff67015255..ebaa78d17d6e 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -414,10 +414,12 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
>  	dma_addr_t dma_phys;
>  	int err;
>  
> -	if (!IS_ENABLED(CONFIG_TEGRA20_APB_DMA) ||
> -	    !i2c_dev->hw->has_apb_dma) {
> -		err = -ENODEV;
> -		goto err_out;
> +	if (!i2c_dev->hw->has_apb_dma)
> +		return 0;
> +
> +	if (!IS_ENABLED(CONFIG_TEGRA20_APB_DMA)) {
> +		dev_dbg(i2c_dev->dev, "Support for APB DMA not enabled!\n");

Nit: would be awesome if the common style of messages could be maintained across the driver, in particular starting the messages with the same upper/lower case. There is no real need to change it in this patch as the messages are already quite inconsistent. It probably won't hurt to clean up the driver's coding style and fix the checkpatch warnings in the future.

> +		return 0;
>  	}
>  
>  	chan = dma_request_slave_channel_reason(i2c_dev->dev, "rx");
> 
Looks good. Thanks, Jon!

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Thierry Reding Feb. 22, 2019, 7:06 p.m. UTC | #2
On Thu, Feb 21, 2019 at 03:00:38PM +0000, Jon Hunter wrote:
> From: Jonathan Hunter <jonathanh@nvidia.com>
> 
> Commit 86c92b9965ff ("i2c: tegra: Add DMA support") added DMA support
> to the Tegra I2C driver for Tegra devices that support the APB DMA
> controller. One side-effect of this change is that even for Tegra
> devices that do not have an APB DMA controller and hence, cannot
> support DMA tranfers for I2C transactions, the following error messages
> are still displayed ...
> 
>  ERR KERN tegra-i2c 31c0000.i2c: cannot use DMA: -19
>  ERR KERN tegra-i2c 31c0000.i2c: falling back to PIO
> 
> There is no point displaying the above messages for devices that do not
> have an APB DMA controller and so fix this by returning from the
> tegra_i2c_init_dma() function if 'has_apb_dma' is not true.
> 
> Furthermore, if CONFIG_TEGRA20_APB_DMA is not set, then rather than
> printing an error message, print an debug message as for whatever reason
> this could be intentional.
> 
> Fixes: 86c92b9965ff ("i2c: tegra: Add DMA support")
> 
> Signed-off-by: Jonathan Hunter <jonathanh@nvidia.com>
> ---
>  drivers/i2c/busses/i2c-tegra.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>
Wolfram Sang Feb. 23, 2019, 9:50 a.m. UTC | #3
On Thu, Feb 21, 2019 at 03:00:38PM +0000, Jon Hunter wrote:
> From: Jonathan Hunter <jonathanh@nvidia.com>
> 
> Commit 86c92b9965ff ("i2c: tegra: Add DMA support") added DMA support
> to the Tegra I2C driver for Tegra devices that support the APB DMA
> controller. One side-effect of this change is that even for Tegra
> devices that do not have an APB DMA controller and hence, cannot
> support DMA tranfers for I2C transactions, the following error messages
> are still displayed ...
> 
>  ERR KERN tegra-i2c 31c0000.i2c: cannot use DMA: -19
>  ERR KERN tegra-i2c 31c0000.i2c: falling back to PIO
> 
> There is no point displaying the above messages for devices that do not
> have an APB DMA controller and so fix this by returning from the
> tegra_i2c_init_dma() function if 'has_apb_dma' is not true.
> 
> Furthermore, if CONFIG_TEGRA20_APB_DMA is not set, then rather than
> printing an error message, print an debug message as for whatever reason
> this could be intentional.
> 
> Fixes: 86c92b9965ff ("i2c: tegra: Add DMA support")
> 
> Signed-off-by: Jonathan Hunter <jonathanh@nvidia.com>

Applied to for-next, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 31ff67015255..ebaa78d17d6e 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -414,10 +414,12 @@  static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
 	dma_addr_t dma_phys;
 	int err;
 
-	if (!IS_ENABLED(CONFIG_TEGRA20_APB_DMA) ||
-	    !i2c_dev->hw->has_apb_dma) {
-		err = -ENODEV;
-		goto err_out;
+	if (!i2c_dev->hw->has_apb_dma)
+		return 0;
+
+	if (!IS_ENABLED(CONFIG_TEGRA20_APB_DMA)) {
+		dev_dbg(i2c_dev->dev, "Support for APB DMA not enabled!\n");
+		return 0;
 	}
 
 	chan = dma_request_slave_channel_reason(i2c_dev->dev, "rx");