HSI: omap_ssi_port: Fix dma_map_sg error check
authorJack Wang <jinpu.wang@ionos.com>
Fri, 26 Aug 2022 10:12:27 +0000 (12:12 +0200)
committerSebastian Reichel <sre@kernel.org>
Mon, 29 Aug 2022 16:08:48 +0000 (18:08 +0200)
dma_map_sg return 0 on error, in case of error return -EIO
to caller.

Cc: Sebastian Reichel <sre@kernel.org>
Cc: linux-kernel@vger.kernel.org (open list)
Fixes: b209e047bc74 ("HSI: Introduce OMAP SSI driver")
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/hsi/controllers/omap_ssi_port.c

index a0cb5be246e1cf2ca47f53c5bea5859128474768..b9495b720f1bd121970deaf4f151a517c27b33d4 100644 (file)
@@ -230,10 +230,10 @@ static int ssi_start_dma(struct hsi_msg *msg, int lch)
        if (msg->ttype == HSI_MSG_READ) {
                err = dma_map_sg(&ssi->device, msg->sgt.sgl, msg->sgt.nents,
                                                        DMA_FROM_DEVICE);
-               if (err < 0) {
+               if (!err) {
                        dev_dbg(&ssi->device, "DMA map SG failed !\n");
                        pm_runtime_put_autosuspend(omap_port->pdev);
-                       return err;
+                       return -EIO;
                }
                csdp = SSI_DST_BURST_4x32_BIT | SSI_DST_MEMORY_PORT |
                        SSI_SRC_SINGLE_ACCESS0 | SSI_SRC_PERIPHERAL_PORT |
@@ -247,10 +247,10 @@ static int ssi_start_dma(struct hsi_msg *msg, int lch)
        } else {
                err = dma_map_sg(&ssi->device, msg->sgt.sgl, msg->sgt.nents,
                                                        DMA_TO_DEVICE);
-               if (err < 0) {
+               if (!err) {
                        dev_dbg(&ssi->device, "DMA map SG failed !\n");
                        pm_runtime_put_autosuspend(omap_port->pdev);
-                       return err;
+                       return -EIO;
                }
                csdp = SSI_SRC_BURST_4x32_BIT | SSI_SRC_MEMORY_PORT |
                        SSI_DST_SINGLE_ACCESS0 | SSI_DST_PERIPHERAL_PORT |