Skip to content

Commit 1ca6106

Browse files
Xu Yilungregkh
authored andcommitted
fpga: zynq_fpga: Fix the wrong usage of dma_map_sgtable()
dma_map_sgtable() returns only 0 or the error code. Read sgt->nents to get the number of mapped segments. Fixes: 37e0070 ("zynq_fpga: use sgtable-based scatterlist wrappers") Reported-by: Pavel Pisa <[email protected]> Closes: https://lore.kernel.org/linux-fpga/[email protected]/ Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Marek Szyprowski <[email protected]> Signed-off-by: Xu Yilun <[email protected]> Tested-by: Pavel Pisa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c17b750 commit 1ca6106

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/fpga/zynq-fpga.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,12 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr, struct sg_table *sgt)
405405
}
406406
}
407407

408-
priv->dma_nelms =
409-
dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0);
410-
if (priv->dma_nelms == 0) {
408+
err = dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0);
409+
if (err) {
411410
dev_err(&mgr->dev, "Unable to DMA map (TO_DEVICE)\n");
412-
return -ENOMEM;
411+
return err;
413412
}
413+
priv->dma_nelms = sgt->nents;
414414

415415
/* enable clock */
416416
err = clk_enable(priv->clk);

0 commit comments

Comments
 (0)