dma-mapping: disallow .map_sg operations from returning zero on error
authorLogan Gunthorpe <logang@deltatee.com>
Mon, 9 Aug 2021 15:13:31 +0000 (17:13 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 9 Aug 2021 15:15:02 +0000 (17:15 +0200)
Now that all the .map_sg operations have been converted to returning
proper error codes, drop the code to handle a zero return value,
add a warning if a zero is returned.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
kernel/dma/mapping.c

index 21e550076be51b50f3770e3c88f2619749d1c809..967b626921021754701dcece269d2e5113f65a2e 100644 (file)
@@ -197,7 +197,7 @@ static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
        if (ents > 0)
                debug_dma_map_sg(dev, sg, nents, ents, dir);
        else if (WARN_ON_ONCE(ents != -EINVAL && ents != -ENOMEM &&
-                             ents != -EIO && ents != 0))
+                             ents != -EIO))
                return -EIO;
 
        return ents;
@@ -261,8 +261,6 @@ int dma_map_sgtable(struct device *dev, struct sg_table *sgt,
        int nents;
 
        nents = __dma_map_sg_attrs(dev, sgt->sgl, sgt->orig_nents, dir, attrs);
-       if (nents == 0)
-               return -EIO;
        if (nents < 0)
                return nents;
        sgt->nents = nents;