Commit 1932a964 authored by Boris Brezillon's avatar Boris Brezillon

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: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: default avatarMarc Gonzalez <marc_gonzalez@sigmadesigns.com>
parent 215157fb
...@@ -223,12 +223,13 @@ static void tango_dma_callback(void *arg) ...@@ -223,12 +223,13 @@ static void tango_dma_callback(void *arg)
complete(arg); complete(arg);
} }
static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf, static int do_dma(struct tango_nfc *nfc, enum dma_data_direction dir, int cmd,
int len, int page) const void *buf, int len, int page)
{ {
void __iomem *addr = nfc->reg_base + NFC_STATUS; void __iomem *addr = nfc->reg_base + NFC_STATUS;
struct dma_chan *chan = nfc->chan; struct dma_chan *chan = nfc->chan;
struct dma_async_tx_descriptor *desc; struct dma_async_tx_descriptor *desc;
enum dma_transfer_direction tdir;
struct scatterlist sg; struct scatterlist sg;
struct completion tx_done; struct completion tx_done;
int err = -EIO; int err = -EIO;
...@@ -238,7 +239,8 @@ static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf, ...@@ -238,7 +239,8 @@ static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf,
if (dma_map_sg(chan->device->dev, &sg, 1, dir) != 1) if (dma_map_sg(chan->device->dev, &sg, 1, dir) != 1)
return -EIO; return -EIO;
desc = dmaengine_prep_slave_sg(chan, &sg, 1, dir, DMA_PREP_INTERRUPT); tdir = dir == DMA_TO_DEVICE ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
desc = dmaengine_prep_slave_sg(chan, &sg, 1, tdir, DMA_PREP_INTERRUPT);
if (!desc) if (!desc)
goto dma_unmap; goto dma_unmap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment