diff mbox

[-next] spi: tegra20-slink: fix return value check in tegra_slink_init_dma_param()

Message ID CAPgLHd-CMEbwqXXvEK7ybSYrDeJPQfkbi+LgRepke_U=WoKmkA@mail.gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Wei Yongjun Dec. 14, 2013, 4:42 a.m. UTC
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

In case of error, the function dma_request_slave_channel() returns
NULL pointer not ERR_PTR(). The IS_ERR() test in the return value
check should be replaced with NULL test.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/spi/spi-tegra20-slink.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Stephen Warren Dec. 16, 2013, 4:59 p.m. UTC | #1
On 12/13/2013 09:42 PM, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> In case of error, the function dma_request_slave_channel() returns
> NULL pointer not ERR_PTR(). The IS_ERR() test in the return value

> diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c

>  	dma_chan = dma_request_slave_channel(tspi->dev,
>  					     dma_to_memory ? "rx" : "tx");
> -	if (IS_ERR(dma_chan)) {
...
> +	if (!dma_chan) {

The code should be calling dma_request_slave_channel_or_reason() rather
than dma_request_slave_channel(). Dan Williams provided a patch to fix
this, which I've now applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index 1e61e98..3643178 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -614,12 +614,9 @@  static int tegra_slink_init_dma_param(struct tegra_slink_data *tspi,
 
 	dma_chan = dma_request_slave_channel(tspi->dev,
 					     dma_to_memory ? "rx" : "tx");
-	if (IS_ERR(dma_chan)) {
-		ret = PTR_ERR(dma_chan);
-		if (ret != -EPROBE_DEFER)
-			dev_err(tspi->dev,
-				"Dma channel is not available: %d\n", ret);
-		return ret;
+	if (!dma_chan) {
+		dev_err(tspi->dev, "Dma channel is not available: %d\n", ret);
+		return -ENODEV;
 	}
 
 	dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size,