From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g4hs6-0008DD-Gt for linux-mtd@lists.infradead.org; Tue, 25 Sep 2018 07:35:05 +0000 Received: by mail-wr1-x443.google.com with SMTP id b11-v6so5967290wru.9 for ; Tue, 25 Sep 2018 00:34:42 -0700 (PDT) Date: Tue, 25 Sep 2018 00:34:38 -0700 From: Nathan Chancellor To: Tudor Ambarus Cc: Marek Vasut , David Woodhouse , Brian Norris , Boris Brezillon , Richard Weinberger , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: spi-nor: cadence-quadspi: Use proper enum for dma_unmap_single Message-ID: <20180925073438.GA24068@flashbox> References: <20180921102944.27968-1-natechancellor@gmail.com> <5e1d2e30-764f-f3a9-d0c1-7a6c81f296b7@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5e1d2e30-764f-f3a9-d0c1-7a6c81f296b7@microchip.com> List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Tue, Sep 25, 2018 at 10:24:04AM +0300, Tudor Ambarus wrote: > Hi, Nathan, > > On 09/21/2018 01:29 PM, Nathan Chancellor wrote: > > Clang warns when one enumerated type is converted implicitly to another. > > > > drivers/mtd/spi-nor/cadence-quadspi.c:962:47: warning: implicit > > conversion from enumeration type 'enum dma_transfer_direction' to > > different enumeration type 'enum dma_data_direction' [-Wenum-conversion] > > dma_dst = dma_map_single(nor->dev, buf, len, DMA_DEV_TO_MEM); > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ > > ./include/linux/dma-mapping.h:428:66: note: expanded from macro > > 'dma_map_single' > > #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0) > > ~~~~~~~~~~~~~~~~~~~~ ^ > > drivers/mtd/spi-nor/cadence-quadspi.c:997:43: warning: implicit > > conversion from enumeration type 'enum dma_transfer_direction' to > > different enumeration type 'enum dma_data_direction' [-Wenum-conversion] > > dma_unmap_single(nor->dev, dma_dst, len, DMA_DEV_TO_MEM); > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ > > ./include/linux/dma-mapping.h:429:70: note: expanded from macro > > 'dma_unmap_single' > > #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0) > > ~~~~~~~~~~~~~~~~~~~~~~ ^ > > 2 warnings generated. > > > > Use the proper enums from dma_data_direction to satisfy Clang. > > > > DMA_TO_DEVICE = DMA_MEM_TO_DEV = 1 > > DMA_FROM_DEVICE = DMA_DEV_TO_MEM = 2 > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/108 > > Signed-off-by: Nathan Chancellor > > --- > > drivers/mtd/spi-nor/cadence-quadspi.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c > > index 8e714fbfa521..d0e57ac81098 100644 > > --- a/drivers/mtd/spi-nor/cadence-quadspi.c > > +++ b/drivers/mtd/spi-nor/cadence-quadspi.c > > @@ -959,7 +959,7 @@ static int cqspi_direct_read_execute(struct spi_nor *nor, u_char *buf, > > return 0; > > } > > > > - dma_dst = dma_map_single(nor->dev, buf, len, DMA_DEV_TO_MEM); > > + dma_dst = dma_map_single(nor->dev, buf, len, DMA_FROM_DEVICE); > > if (dma_mapping_error(nor->dev, dma_dst)) { > > dev_err(nor->dev, "dma mapping failed\n"); > > return -ENOMEM; > > @@ -994,7 +994,7 @@ static int cqspi_direct_read_execute(struct spi_nor *nor, u_char *buf, > > } > > > > err_unmap: > > - dma_unmap_single(nor->dev, dma_dst, len, DMA_DEV_TO_MEM); > > + dma_unmap_single(nor->dev, dma_dst, len, DMA_TO_DEVICE); > > Should have used DMA_FROM_DEVICE, as you did above. Otherwise looks good. > > Cheers, > ta Thank you very much for catching this, did several of these conversions back to back and didn't look closely at this. I just sent a v2, I appreciate the review! Nathan