crypto: ux500 - Use proper enum in cryp_set_dma_transfer
PATCH 1/1 crypto: ux500 - Use proper enum in cryp_set_dma_transfer
Clang warns when one enumerated type is implicitly converted to another:
drivers/crypto/ux500/cryp/cryp_core.c:559:5: warning: implicit conversion from enumeration type 'enum dma_data_direction' to different enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
direction, DMA_CTRL_ACK);
^~~~~~~~~
drivers/crypto/ux500/cryp/cryp_core.c:583:5: warning: implicit
conversion from enumeration type 'enum dma_data_direction' to different
enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
direction,
^~~~~~~~~2 warnings generated.
dmaengine_prep_slave_sg expects an enum from dma_transfer_direction. Because we know the value of the dma_data_direction enum from the switch statement, we can just use the proper value from dma_transfer_direction so there is no more conversion.
DMA_TO_DEVICE = DMA_MEM_TO_DEV = 1DMA_FROM_DEVICE = DMA_DEV_TO_MEM = 2
--- drivers/crypto/ux500/cryp/cryp_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/ux500/cryp/cryp_core.c +2 -2
@@ -556,7 +556,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx, desc =dmaengine_prep_slave_sg (channel, ctx->device->dma.sg_src, ctx->device->dma.sg_src_len, - direction,DMA_CTRL_ACK ); +DMA_MEM_TO_DEV ,DMA_CTRL_ACK );break ;case DMA_FROM_DEVICE :
@@ -580,7 +580,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx, desc =dmaengine_prep_slave_sg (channel, ctx->device->dma.sg_dst, ctx->device->dma.sg_dst_len, - direction, +DMA_DEV_TO_MEM ,DMA_CTRL_ACK |DMA_PREP_INTERRUPT );
Signature · 1 line
2.20.0
Quoted 20 lines · Nathan Chancellor
Clang warns when one enumerated type is implicitly converted to another:
drivers/crypto/ux500/cryp/cryp_core.c:559:5: warning: implicit conversion from enumeration type 'enumdma_data_direction' to different enumeration type 'enumdma_transfer_direction' [-Wenum-conversion]direction, DMA_CTRL_ACK); ^~~~~~~~~ drivers/crypto/ux500/cryp/cryp_core.c:583:5: warning: implicit conversion from enumeration type 'enum dma_data_direction' to different enumeration type 'enum dma_transfer_direction' [-Wenum-conversion] direction, ^~~~~~~~~2 warnings generated.
dmaengine_prep_slave_sgexpects an enum fromdma_transfer_direction. Because we know the value of thedma_data_directionenum from the switch statement, we can just use the proper value fromdma_transfer_directionso there is no more conversion.
Quoted 4 lines
DMA_TO_DEVICE=DMA_MEM_TO_DEV= 1DMA_FROM_DEVICE=DMA_DEV_TO_MEM= 2Signed-off-by Nathan Chancellor <[email protected]>
Deja vu!
These particular enums get mixed up ALL THE TIME. Thanks for fixing probably every instance of this bug (via patches before this one).
Quoted 29 lines
--- drivers/crypto/ux500/cryp/cryp_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/crypto/ux500/cryp/cryp_core.c +2
-3@@ -556,7 +556,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx, desc =dmaengine_prep_slave_sg (channel, ctx->device->dma.sg_src, ctx->device->dma.sg_src_len, - direction,DMA_CTRL_ACK ); +DMA_MEM_TO_DEV ,DMA_CTRL_ACK );break ;case DMA_FROM_DEVICE :@@ -580,7 +580,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx, desc =dmaengine_prep_slave_sg (channel, ctx->device->dma.sg_dst, ctx->device->dma.sg_dst_len, - direction, +DMA_DEV_TO_MEM ,DMA_CTRL_ACK |DMA_PREP_INTERRUPT ); --2.20.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Herbert Xu
maintainerQuoted 19 lines · Nathan Chancellor
Clang warns when one enumerated type is implicitly converted to another:
drivers/crypto/ux500/cryp/cryp_core.c:559:5: warning: implicit conversion from enumeration type 'enumdma_data_direction' to different enumeration type 'enumdma_transfer_direction' [-Wenum-conversion]direction, DMA_CTRL_ACK); ^~~~~~~~~ drivers/crypto/ux500/cryp/cryp_core.c:583:5: warning: implicit conversion from enumeration type 'enum dma_data_direction' to different enumeration type 'enum dma_transfer_direction' [-Wenum-conversion] direction, ^~~~~~~~~2 warnings generated.
dmaengine_prep_slave_sgexpects an enum fromdma_transfer_direction. Because we know the value of thedma_data_directionenum from the switch statement, we can just use the proper value fromdma_transfer_directionso there is no more conversion.
Quoted 7 lines
DMA_TO_DEVICE=DMA_MEM_TO_DEV= 1DMA_FROM_DEVICE=DMA_DEV_TO_MEM= 2Signed-off-by Nathan Chancellor <[email protected]>--- drivers/crypto/ux500/cryp/cryp_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt