spi: core: Fix check for dma_map_sg() failures
authorGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 10 Jul 2014 13:29:32 +0000 (15:29 +0200)
committerMark Brown <broonie@linaro.org>
Fri, 11 Jul 2014 12:57:10 +0000 (13:57 +0100)
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>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi.c

index d4f9670b51bcbd7947b811b5f8dfab8afc711248..91bb512e100995f49c66a9306c494c56ddc9109c 100644 (file)
@@ -619,6 +619,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;