* [PATCH] crypto: ux500 - Use proper enum in hash_set_dma_transfer
@ 2018-12-10 23:49 Nathan Chancellor
2018-12-11 23:45 ` 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/hash/hash_core.c:169:4: warning: implicit
conversion from enumeration type 'enum dma_data_direction' to different
enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
^~~~~~~~~
1 warning generated.
dmaengine_prep_slave_sg expects an enum from dma_transfer_direction.
We know that the only direction supported by this function is
DMA_TO_DEVICE because of the check at the top of this function so we can
just use the equivalent value from dma_transfer_direction.
DMA_TO_DEVICE = DMA_MEM_TO_DEV = 1
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/crypto/ux500/hash/hash_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c
index 633321a8dd03..a0bb8a6eec3f 100644
--- a/drivers/crypto/ux500/hash/hash_core.c
+++ b/drivers/crypto/ux500/hash/hash_core.c
@@ -166,7 +166,7 @@ static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg,
__func__);
desc = dmaengine_prep_slave_sg(channel,
ctx->device->dma.sg, ctx->device->dma.sg_len,
- direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
+ DMA_MEM_TO_DEV, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
if (!desc) {
dev_err(ctx->device->dev,
"%s: dmaengine_prep_slave_sg() failed!\n", __func__);
--
2.20.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] crypto: ux500 - Use proper enum in hash_set_dma_transfer
2018-12-10 23:49 [PATCH] crypto: ux500 - Use proper enum in hash_set_dma_transfer Nathan Chancellor
@ 2018-12-11 23:45 ` Nick Desaulniers
2018-12-23 4:01 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2018-12-11 23:45 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: Herbert Xu, linux-crypto, LKML
On Mon, Dec 10, 2018 at 3:50 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns when one enumerated type is implicitly converted to another:
>
> drivers/crypto/ux500/hash/hash_core.c:169:4: warning: implicit
> conversion from enumeration type 'enum dma_data_direction' to different
> enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
> direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
> ^~~~~~~~~
> 1 warning generated.
>
> dmaengine_prep_slave_sg expects an enum from dma_transfer_direction.
> We know that the only direction supported by this function is
> DMA_TO_DEVICE because of the check at the top of this function so we can
> just use the equivalent value from dma_transfer_direction.
That's correct. Thanks for fixing up yet another one of these enum
confusions. (I'm beginning to think we should change the values of the
enum members so that things break when aliased as such. Unfortunately,
that would result in runtime bugs rather than strong type system based
compile time checks; but this warning from Clang helps).
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> DMA_TO_DEVICE = DMA_MEM_TO_DEV = 1
>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/crypto/ux500/hash/hash_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c
> index 633321a8dd03..a0bb8a6eec3f 100644
> --- a/drivers/crypto/ux500/hash/hash_core.c
> +++ b/drivers/crypto/ux500/hash/hash_core.c
> @@ -166,7 +166,7 @@ static int hash_set_dma_transfer(struct hash_ctx *ctx, struct scatterlist *sg,
> __func__);
> desc = dmaengine_prep_slave_sg(channel,
> ctx->device->dma.sg, ctx->device->dma.sg_len,
> - direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
> + DMA_MEM_TO_DEV, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
> if (!desc) {
> dev_err(ctx->device->dev,
> "%s: dmaengine_prep_slave_sg() failed!\n", __func__);
> --
> 2.20.0
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] crypto: ux500 - Use proper enum in hash_set_dma_transfer
2018-12-10 23:49 [PATCH] crypto: ux500 - Use proper enum in hash_set_dma_transfer Nathan Chancellor
2018-12-11 23:45 ` 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:54PM -0700, Nathan Chancellor wrote:
> Clang warns when one enumerated type is implicitly converted to another:
>
> drivers/crypto/ux500/hash/hash_core.c:169:4: warning: implicit
> conversion from enumeration type 'enum dma_data_direction' to different
> enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
> direction, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
> ^~~~~~~~~
> 1 warning generated.
>
> dmaengine_prep_slave_sg expects an enum from dma_transfer_direction.
> We know that the only direction supported by this function is
> DMA_TO_DEVICE because of the check at the top of this function so we can
> just use the equivalent value from dma_transfer_direction.
>
> DMA_TO_DEVICE = DMA_MEM_TO_DEV = 1
>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> drivers/crypto/ux500/hash/hash_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
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 hash_set_dma_transfer Nathan Chancellor
2018-12-11 23:45 ` 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
all inboxes | Powered by JetHome®