linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ep93xx: Return proper enum in ep93xx_dma_chan_direction
@ 2018-09-11 23:40 Nathan Chancellor
  2018-09-12 17:00 ` Nick Desaulniers
  2018-10-02 14:42 ` Vinod
  0 siblings, 2 replies; 4+ messages in thread
From: Nathan Chancellor @ 2018-09-11 23:40 UTC (permalink / raw)
  To: Dan Williams, Vinod Koul
  Cc: dmaengine, linux-kernel, Nick Desaulniers, Nathan Chancellor

Clang warns when implicitly converting from one enumerated type to
another. Avoid this by using the equivalent value from the expected
type.

In file included from drivers/dma/ep93xx_dma.c:30:
./include/linux/platform_data/dma-ep93xx.h:88:10: warning: implicit
conversion from enumeration type 'enum dma_data_direction' to different
enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
                return DMA_NONE;
                ~~~~~~ ^~~~~~~~
1 warning generated.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 include/linux/platform_data/dma-ep93xx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/platform_data/dma-ep93xx.h b/include/linux/platform_data/dma-ep93xx.h
index f8f1f6b952a6..eb9805bb3fe8 100644
--- a/include/linux/platform_data/dma-ep93xx.h
+++ b/include/linux/platform_data/dma-ep93xx.h
@@ -85,7 +85,7 @@ static inline enum dma_transfer_direction
 ep93xx_dma_chan_direction(struct dma_chan *chan)
 {
 	if (!ep93xx_dma_chan_is_m2p(chan))
-		return DMA_NONE;
+		return DMA_TRANS_NONE;
 
 	/* even channels are for TX, odd for RX */
 	return (chan->chan_id % 2 == 0) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: ep93xx: Return proper enum in ep93xx_dma_chan_direction
  2018-09-11 23:40 [PATCH] dmaengine: ep93xx: Return proper enum in ep93xx_dma_chan_direction Nathan Chancellor
@ 2018-09-12 17:00 ` Nick Desaulniers
  2018-09-12 18:36   ` Nathan Chancellor
  2018-10-02 14:42 ` Vinod
  1 sibling, 1 reply; 4+ messages in thread
From: Nick Desaulniers @ 2018-09-12 17:00 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: dan.j.williams, vkoul, dmaengine, LKML

On Tue, Sep 11, 2018 at 4:40 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns when implicitly converting from one enumerated type to
> another. Avoid this by using the equivalent value from the expected
> type.
>
> In file included from drivers/dma/ep93xx_dma.c:30:
> ./include/linux/platform_data/dma-ep93xx.h:88:10: warning: implicit
> conversion from enumeration type 'enum dma_data_direction' to different
> enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
>                 return DMA_NONE;
>                 ~~~~~~ ^~~~~~~~
> 1 warning generated.
>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  include/linux/platform_data/dma-ep93xx.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/platform_data/dma-ep93xx.h b/include/linux/platform_data/dma-ep93xx.h
> index f8f1f6b952a6..eb9805bb3fe8 100644
> --- a/include/linux/platform_data/dma-ep93xx.h
> +++ b/include/linux/platform_data/dma-ep93xx.h
> @@ -85,7 +85,7 @@ static inline enum dma_transfer_direction
>  ep93xx_dma_chan_direction(struct dma_chan *chan)
>  {
>         if (!ep93xx_dma_chan_is_m2p(chan))
> -               return DMA_NONE;
> +               return DMA_TRANS_NONE;

Looks like this changes the value of the returned enum from:
DMA_NONE: 3
DMA_TRANS_NONE: 4

Hopefully the DMA maintainer can review if this was ever correct?
Looks like the callers of ep93xx_dma_chan_direction were comparing
this return type, so those comparisons would likely always be failing
if `!ep93xx_dma_chan_is_m2p(chan)`.

Normally this warning (-Wenum-conversion) is kind of noisey, but it's
concerning when the enumerated values evaluate to different integers.
I think it's found an actual bug here.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
>         /* even channels are for TX, odd for RX */
>         return (chan->chan_id % 2 == 0) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
> --
> 2.18.0
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: ep93xx: Return proper enum in ep93xx_dma_chan_direction
  2018-09-12 17:00 ` Nick Desaulniers
@ 2018-09-12 18:36   ` Nathan Chancellor
  0 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2018-09-12 18:36 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: dan.j.williams, vkoul, dmaengine, LKML

On Wed, Sep 12, 2018 at 10:00:57AM -0700, Nick Desaulniers wrote:
> On Tue, Sep 11, 2018 at 4:40 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Clang warns when implicitly converting from one enumerated type to
> > another. Avoid this by using the equivalent value from the expected
> > type.
> >
> > In file included from drivers/dma/ep93xx_dma.c:30:
> > ./include/linux/platform_data/dma-ep93xx.h:88:10: warning: implicit
> > conversion from enumeration type 'enum dma_data_direction' to different
> > enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
> >                 return DMA_NONE;
> >                 ~~~~~~ ^~~~~~~~
> > 1 warning generated.
> >
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >  include/linux/platform_data/dma-ep93xx.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/linux/platform_data/dma-ep93xx.h b/include/linux/platform_data/dma-ep93xx.h
> > index f8f1f6b952a6..eb9805bb3fe8 100644
> > --- a/include/linux/platform_data/dma-ep93xx.h
> > +++ b/include/linux/platform_data/dma-ep93xx.h
> > @@ -85,7 +85,7 @@ static inline enum dma_transfer_direction
> >  ep93xx_dma_chan_direction(struct dma_chan *chan)
> >  {
> >         if (!ep93xx_dma_chan_is_m2p(chan))
> > -               return DMA_NONE;
> > +               return DMA_TRANS_NONE;
> 
> Looks like this changes the value of the returned enum from:
> DMA_NONE: 3
> DMA_TRANS_NONE: 4
> 
> Hopefully the DMA maintainer can review if this was ever correct?
> Looks like the callers of ep93xx_dma_chan_direction were comparing
> this return type, so those comparisons would likely always be failing
> if `!ep93xx_dma_chan_is_m2p(chan)`.
> 
> Normally this warning (-Wenum-conversion) is kind of noisey, but it's
> concerning when the enumerated values evaluate to different integers.
> I think it's found an actual bug here.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> 

I should have highlighted this in the actual commit message but I
checked all of the callsites of ep93xx_dma_chan_direction and one
directly refers to an enum value, DMA_MEM_TO_DEV; every other one
just checks if the value is or isn't equal to another value of this
enum type (DMA_NONE isn't referenced anywhere else in this driver).
I don't believe this results in a funcitonal change.

Thanks for the review!
Nathan

> >
> >         /* even channels are for TX, odd for RX */
> >         return (chan->chan_id % 2 == 0) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
> > --
> > 2.18.0
> >
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: ep93xx: Return proper enum in ep93xx_dma_chan_direction
  2018-09-11 23:40 [PATCH] dmaengine: ep93xx: Return proper enum in ep93xx_dma_chan_direction Nathan Chancellor
  2018-09-12 17:00 ` Nick Desaulniers
@ 2018-10-02 14:42 ` Vinod
  1 sibling, 0 replies; 4+ messages in thread
From: Vinod @ 2018-10-02 14:42 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Dan Williams, dmaengine, linux-kernel, Nick Desaulniers

On 11-09-18, 16:40, Nathan Chancellor wrote:
> Clang warns when implicitly converting from one enumerated type to
> another. Avoid this by using the equivalent value from the expected
> type.
> 
> In file included from drivers/dma/ep93xx_dma.c:30:
> ./include/linux/platform_data/dma-ep93xx.h:88:10: warning: implicit
> conversion from enumeration type 'enum dma_data_direction' to different
> enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
>                 return DMA_NONE;
>                 ~~~~~~ ^~~~~~~~
> 1 warning generated.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-02 14:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11 23:40 [PATCH] dmaengine: ep93xx: Return proper enum in ep93xx_dma_chan_direction Nathan Chancellor
2018-09-12 17:00 ` Nick Desaulniers
2018-09-12 18:36   ` Nathan Chancellor
2018-10-02 14:42 ` Vinod

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).