mtd: rawnand: Use proper enum for flctl_dma_fifo0_transfer
Subsystems (2)
PATCH 1/1 mtd: rawnand: Use proper enum for flctl_dma_fifo0_transfer
Clang warns when one enumerated type is converted implicitly to another:
drivers/mtd/nand/raw/sh_flctl.c:483:46: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_DEV_TO_MEM) > 0) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~drivers/mtd/nand/raw/sh_flctl.c:542:46: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_MEM_TO_DEV) > 0) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
2 warnings generated.
Use the proper enums from dma_data_direction to satisfy Clang.
DMA_MEM_TO_DEV = DMA_TO_DEVICE = 1DMA_DEV_TO_MEM = DMA_FROM_DEVICE = 2
--- drivers/mtd/nand/raw/sh_flctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/sh_flctl.c +2 -2
@@ -480,7 +480,7 @@ static void read_fiforeg(struct sh_flctl *flctl, int rlen, int offset)/* initiate DMA transfer */ if (flctl->chan_fifo0_rx && rlen >=32 && -flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_DEV_TO_MEM ) >0 ) +flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_FROM_DEVICE ) >0 ) goto convert;/* DMA success */ /* do polling transfer */
@@ -539,7 +539,7 @@ static void write_ec_fiforeg(struct sh_flctl *flctl, int rlen,/* initiate DMA transfer */ if (flctl->chan_fifo0_tx && rlen >=32 && -flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_MEM_TO_DEV ) >0 ) +flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_TO_DEVICE ) >0 )return ;/* DMA success */ /* do polling transfer */
Signature · 1 line
2.19.0
Quoted 31 lines · Nathan Chancellor
Clang warns when one enumerated type is converted implicitly to another:
drivers/mtd/nand/raw/sh_flctl.c:483:46: warning: implicit conversion from enumeration type 'enumdma_transfer_direction' to different enumeration type 'enumdma_data_direction' [-Wenum-conversion]
flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_DEV_TO_MEM)> 0) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~drivers/mtd/nand/raw/sh_flctl.c:542:46: warning: implicit conversion from enumeration type 'enumdma_transfer_direction' to different enumeration type 'enumdma_data_direction' [-Wenum-conversion]
flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_MEM_TO_DEV)> 0) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
2 warnings generated.Use the proper enums from
dma_data_directionto satisfy Clang.
DMA_MEM_TO_DEV=DMA_TO_DEVICE= 1DMA_DEV_TO_MEM=DMA_FROM_DEVICE= 2Reported-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>--- drivers/mtd/nand/raw/sh_flctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mtd/nand/raw/sh_flctl.c +0
-0
drivers/mtd/nand/raw/sh_flctl.c static void read_fiforeg(struct sh_flctl *flctl, int rlen, int offset) · line 483
Quoted 5 lines
drivers/mtd/nand/raw/sh_flctl.c +1
-1@@ -480,7 +480,7 @@ static void read_fiforeg(struct sh_flctl *flctl, int rlen, int offset)/* initiate DMA transfer */ if (flctl->chan_fifo0_rx && rlen >=32 && -flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_DEV_TO_MEM ) >0 ) +flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_FROM_DEVICE ) >0 )
Looks like flctl_dma_fifo0_transfer() expects an enum dma_data_direction dir, not an enum dma_transfer_direction as noted by the warning, and luckily the values specified happened to have the same value today as you noted. So this change is no functional change, but will prevent changes to either enum from potentially breaking this code.
Quoted 15 lines
drivers/mtd/nand/raw/sh_flctl.c +1
-2goto convert;/* DMA success */ /* do polling transfer */ @@ -539,7 +539,7 @@ static void write_ec_fiforeg(struct sh_flctl *flctl, int rlen,/* initiate DMA transfer */ if (flctl->chan_fifo0_tx && rlen >=32 && -flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_MEM_TO_DEV ) >0 ) +flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_TO_DEVICE ) >0 )return ;/* DMA success */ /* do polling transfer */ --2.19.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Miquel Raynal
maintainerHi Nathan,
Nathan Chancellor <[email protected]> wrote on Thu, 20 Sep 2018 16:30:25 -0700:
Quoted 39 lines
Clang warns when one enumerated type is converted implicitly to another:
drivers/mtd/nand/raw/sh_flctl.c:483:46: warning: implicit conversion from enumeration type 'enumdma_transfer_direction' to different enumeration type 'enumdma_data_direction' [-Wenum-conversion]
flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_DEV_TO_MEM)> 0) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~drivers/mtd/nand/raw/sh_flctl.c:542:46: warning: implicit conversion from enumeration type 'enumdma_transfer_direction' to different enumeration type 'enumdma_data_direction' [-Wenum-conversion]
flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_MEM_TO_DEV)> 0) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
2 warnings generated.Use the proper enums from
dma_data_directionto satisfy Clang.
DMA_MEM_TO_DEV=DMA_TO_DEVICE= 1DMA_DEV_TO_MEM=DMA_FROM_DEVICE= 2Reported-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>--- drivers/mtd/nand/raw/sh_flctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mtd/nand/raw/sh_flctl.c +1
-1@@ -480,7 +480,7 @@ static void read_fiforeg(struct sh_flctl *flctl, int rlen, int offset)/* initiate DMA transfer */ if (flctl->chan_fifo0_rx && rlen >=32 && -flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_DEV_TO_MEM ) >0 ) +flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_FROM_DEVICE ) >0 ) goto convert;/* DMA success */ /* do polling transfer */
drivers/mtd/nand/raw/sh_flctl.c static void write_ec_fiforeg(struct sh_flctl *flctl, int rlen, · line 545
Quoted 8 lines
drivers/mtd/nand/raw/sh_flctl.c +1
-1@@ -539,7 +539,7 @@ static void write_ec_fiforeg(struct sh_flctl *flctl, int rlen,/* initiate DMA transfer */ if (flctl->chan_fifo0_tx && rlen >=32 && -flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_MEM_TO_DEV ) >0 ) +flctl_dma_fifo0_transfer (flctl, buf, rlen,DMA_TO_DEVICE ) >0 )return ;/* DMA success */ /* do polling transfer */
Applied on nand/next with the subject prefix changed to
mtd: rawnand: sh_flctl:
Thanks,
Miquèl