linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	linux-crypto@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] crypto: ux500 - Use proper enum in cryp_set_dma_transfer
Date: Tue, 11 Dec 2018 15:40:04 -0800	[thread overview]
Message-ID: <CAKwvOdkB0BViLgVyWBQZw4jZgFjp-3m2ndjiJmutsbevYjy7nA@mail.gmail.com> (raw)
In-Reply-To: <20181210234929.5729-1-natechancellor@gmail.com>

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

  reply	other threads:[~2018-12-11 23:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2018-12-23  4:01 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKwvOdkB0BViLgVyWBQZw4jZgFjp-3m2ndjiJmutsbevYjy7nA@mail.gmail.com \
    --to=ndesaulniers@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).