* [PATCH] crypto: ux500 - Use proper enum in cryp_set_dma_transfer
@ 2018-12-10 23:49 Nathan Chancellor
2018-12-11 23:40 ` Nick Desaulniers
2018-12-23 4:01 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2018-12-10 23:49 UTC (permalink / raw)
To: Herbert Xu
Cc: linux-crypto, linux-kernel, Nick Desaulniers, 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 '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 = 1
DMA_FROM_DEVICE = DMA_DEV_TO_MEM = 2
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/crypto/ux500/cryp/cryp_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
index d2663a4e1f5e..a92a66b1ff46 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: ux500 - Use proper enum in cryp_set_dma_transfer
2018-12-10 23:49 [PATCH] crypto: ux500 - Use proper enum in cryp_set_dma_transfer Nathan Chancellor
@ 2018-12-11 23:40 ` Nick Desaulniers
2018-12-23 4:01 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2018-12-11 23:40 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: Herbert Xu, linux-crypto, LKML
On Mon, Dec 10, 2018 at 3:49 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> 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 = 1
> DMA_FROM_DEVICE = DMA_DEV_TO_MEM = 2
>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
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).
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> drivers/crypto/ux500/cryp/cryp_core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
> index d2663a4e1f5e..a92a66b1ff46 100644
> --- a/drivers/crypto/ux500/cryp/cryp_core.c
> +++ b/drivers/crypto/ux500/cryp/cryp_core.c
> @@ -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
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: ux500 - Use proper enum in cryp_set_dma_transfer
2018-12-10 23:49 [PATCH] crypto: ux500 - Use proper enum in cryp_set_dma_transfer Nathan Chancellor
2018-12-11 23:40 ` Nick Desaulniers
@ 2018-12-23 4:01 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2018-12-23 4:01 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: linux-crypto, linux-kernel, Nick Desaulniers
On Mon, Dec 10, 2018 at 04:49:29PM -0700, Nathan Chancellor wrote:
> 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 = 1
> DMA_FROM_DEVICE = DMA_DEV_TO_MEM = 2
>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/crypto/ux500/cryp/cryp_core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-23 4:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 23:49 [PATCH] crypto: ux500 - Use proper enum in cryp_set_dma_transfer Nathan Chancellor
2018-12-11 23:40 ` Nick Desaulniers
2018-12-23 4:01 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).