Skip to content

Commit 1932a96

Browse files
author
Boris Brezillon
committed
mtd: nand: tango: Enforce DMA direction type
do_dma() uses an int to pass the DMA data direction information and pass the same value to dmaengine_prep_slave_sg(). Currently, DMA_{FROM,TO}_DEVICE match DMA_{DEV_TO_MEM,MEM_TO_DEV} definitions so it works fine, but assuming this will always be the case is not safe. Enforce enum dma_data_direction type in the function prototype and make the enum dma_data_direction -> enum dma_transfer_direction conversion explicit. Reported-by: Richard Weinberger <[email protected]> Signed-off-by: Boris Brezillon <[email protected]> Acked-by: Marc Gonzalez <[email protected]>
1 parent 215157f commit 1932a96

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/mtd/nand/tango_nand.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,13 @@ static void tango_dma_callback(void *arg)
223223
complete(arg);
224224
}
225225

226-
static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf,
227-
int len, int page)
226+
static int do_dma(struct tango_nfc *nfc, enum dma_data_direction dir, int cmd,
227+
const void *buf, int len, int page)
228228
{
229229
void __iomem *addr = nfc->reg_base + NFC_STATUS;
230230
struct dma_chan *chan = nfc->chan;
231231
struct dma_async_tx_descriptor *desc;
232+
enum dma_transfer_direction tdir;
232233
struct scatterlist sg;
233234
struct completion tx_done;
234235
int err = -EIO;
@@ -238,7 +239,8 @@ static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf,
238239
if (dma_map_sg(chan->device->dev, &sg, 1, dir) != 1)
239240
return -EIO;
240241

241-
desc = dmaengine_prep_slave_sg(chan, &sg, 1, dir, DMA_PREP_INTERRUPT);
242+
tdir = dir == DMA_TO_DEVICE ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
243+
desc = dmaengine_prep_slave_sg(chan, &sg, 1, tdir, DMA_PREP_INTERRUPT);
242244
if (!desc)
243245
goto dma_unmap;
244246

0 commit comments

Comments
 (0)