diff mbox

[1/2] spi: core: Fix check for dma_map_sg() failures

Message ID 1404998973-19425-1-git-send-email-geert@linux-m68k.org (mailing list archive)
State Accepted
Delegated to: Vinod Koul
Headers show

Commit Message

Geert Uytterhoeven July 10, 2014, 1:29 p.m. UTC
From: Geert Uytterhoeven <geert+renesas@glider.be>

According to Documentation/DMA-API.txt, dma_map_sg() returns 0 on failure.
As spi_map_buf() returns an error code, convert zero into -ENOMEM.
Keep the existing check for negative numbers just in case.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/spi/spi.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Mark Brown July 11, 2014, 12:57 p.m. UTC | #1
On Thu, Jul 10, 2014 at 03:29:32PM +0200, Geert Uytterhoeven wrote:
> From: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> According to Documentation/DMA-API.txt, dma_map_sg() returns 0 on failure.
> As spi_map_buf() returns an error code, convert zero into -ENOMEM.
> Keep the existing check for negative numbers just in case.

Applied both, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 3a3245dd64ed..3aac0e885cd9 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -617,6 +617,8 @@  static int spi_map_buf(struct spi_master *master, struct device *dev,
 	}
 
 	ret = dma_map_sg(dev, sgt->sgl, sgt->nents, dir);
+	if (!ret)
+		ret = -ENOMEM;
 	if (ret < 0) {
 		sg_free_table(sgt);
 		return ret;