linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: max9611: Avoid implicit enum conversion warning
@ 2018-09-15  5:25 Nathan Chancellor
  2018-09-16  9:53 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2018-09-15  5:25 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-iio, linux-kernel, Nick Desaulniers, Nathan Chancellor

Clang warns when an enumerated type is implicitly converted to another.

drivers/iio/adc/max9611.c:292:16: warning: implicit conversion from
enumeration type 'enum max9611_conf_ids' to different enumeration type
'enum max9611_csa_gain' [-Wenum-conversion]
                        *csa_gain = gain_selectors[i];
                                  ~ ^~~~~~~~~~~~~~~~~
1 warning generated.

Change the type of the variable 'gain_selectors' to int so that Clang
understands this is expected behavior.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/iio/adc/max9611.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
index 0538ff8c4ac1..3c358b16a8fa 100644
--- a/drivers/iio/adc/max9611.c
+++ b/drivers/iio/adc/max9611.c
@@ -275,7 +275,7 @@ static int max9611_read_csa_voltage(struct max9611_dev *max9611,
 				    u16 *adc_raw,
 				    enum max9611_csa_gain *csa_gain)
 {
-	enum max9611_conf_ids gain_selectors[] = {
+	int gain_selectors[] = {
 		CONF_SENSE_1x,
 		CONF_SENSE_4x,
 		CONF_SENSE_8x
-- 
2.18.0


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

* Re: [PATCH] iio: adc: max9611: Avoid implicit enum conversion warning
  2018-09-15  5:25 [PATCH] iio: adc: max9611: Avoid implicit enum conversion warning Nathan Chancellor
@ 2018-09-16  9:53 ` Jonathan Cameron
  2018-09-16 15:15   ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2018-09-16  9:53 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-iio, linux-kernel, Nick Desaulniers

On Fri, 14 Sep 2018 22:25:11 -0700
Nathan Chancellor <natechancellor@gmail.com> wrote:

> Clang warns when an enumerated type is implicitly converted to another.
> 
> drivers/iio/adc/max9611.c:292:16: warning: implicit conversion from
> enumeration type 'enum max9611_conf_ids' to different enumeration type
> 'enum max9611_csa_gain' [-Wenum-conversion]
>                         *csa_gain = gain_selectors[i];
>                                   ~ ^~~~~~~~~~~~~~~~~
> 1 warning generated.
> 
> Change the type of the variable 'gain_selectors' to int so that Clang
> understands this is expected behavior.
> 
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
How does this interact with the patch that Stefan Agner sent for
the same issue last week?

https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?h=testing&id=b1ec0802503820ccbc894aadfd2a44da20232f5e

Thanks,

Jonathan

> ---
>  drivers/iio/adc/max9611.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> index 0538ff8c4ac1..3c358b16a8fa 100644
> --- a/drivers/iio/adc/max9611.c
> +++ b/drivers/iio/adc/max9611.c
> @@ -275,7 +275,7 @@ static int max9611_read_csa_voltage(struct max9611_dev *max9611,
>  				    u16 *adc_raw,
>  				    enum max9611_csa_gain *csa_gain)
>  {
> -	enum max9611_conf_ids gain_selectors[] = {
> +	int gain_selectors[] = {
>  		CONF_SENSE_1x,
>  		CONF_SENSE_4x,
>  		CONF_SENSE_8x


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

* Re: [PATCH] iio: adc: max9611: Avoid implicit enum conversion warning
  2018-09-16  9:53 ` Jonathan Cameron
@ 2018-09-16 15:15   ` Nathan Chancellor
  2018-09-17 16:52     ` Nick Desaulniers
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2018-09-16 15:15 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-iio, linux-kernel, Nick Desaulniers

On Sun, Sep 16, 2018 at 10:53:51AM +0100, Jonathan Cameron wrote:
> On Fri, 14 Sep 2018 22:25:11 -0700
> Nathan Chancellor <natechancellor@gmail.com> wrote:
> 
> > Clang warns when an enumerated type is implicitly converted to another.
> > 
> > drivers/iio/adc/max9611.c:292:16: warning: implicit conversion from
> > enumeration type 'enum max9611_conf_ids' to different enumeration type
> > 'enum max9611_csa_gain' [-Wenum-conversion]
> >                         *csa_gain = gain_selectors[i];
> >                                   ~ ^~~~~~~~~~~~~~~~~
> > 1 warning generated.
> > 
> > Change the type of the variable 'gain_selectors' to int so that Clang
> > understands this is expected behavior.
> > 
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> How does this interact with the patch that Stefan Agner sent for
> the same issue last week?
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?h=testing&id=b1ec0802503820ccbc894aadfd2a44da20232f5e
> 
> Thanks,
> 
> Jonathan
> 

Hi Jonathan,

Sorry for the overlap. My patch is not necessary. I was working off
of linux-next so I didn't catch this. I'll be better about checking
maintainer trees before sending patches in the future.

Thanks for the quick response!
Nathan

> > ---
> >  drivers/iio/adc/max9611.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> > index 0538ff8c4ac1..3c358b16a8fa 100644
> > --- a/drivers/iio/adc/max9611.c
> > +++ b/drivers/iio/adc/max9611.c
> > @@ -275,7 +275,7 @@ static int max9611_read_csa_voltage(struct max9611_dev *max9611,
> >  				    u16 *adc_raw,
> >  				    enum max9611_csa_gain *csa_gain)
> >  {
> > -	enum max9611_conf_ids gain_selectors[] = {
> > +	int gain_selectors[] = {
> >  		CONF_SENSE_1x,
> >  		CONF_SENSE_4x,
> >  		CONF_SENSE_8x
> 

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

* Re: [PATCH] iio: adc: max9611: Avoid implicit enum conversion warning
  2018-09-16 15:15   ` Nathan Chancellor
@ 2018-09-17 16:52     ` Nick Desaulniers
  2018-09-17 19:22       ` Stefan Agner
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Desaulniers @ 2018-09-17 16:52 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: jic23, knaack.h, lars, pmeerw, linux-iio, LKML, Stefan Agner

On Sun, Sep 16, 2018 at 8:15 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Sun, Sep 16, 2018 at 10:53:51AM +0100, Jonathan Cameron wrote:
> > On Fri, 14 Sep 2018 22:25:11 -0700
> > Nathan Chancellor <natechancellor@gmail.com> wrote:
> >
> > > Clang warns when an enumerated type is implicitly converted to another.
> > >
> > > drivers/iio/adc/max9611.c:292:16: warning: implicit conversion from
> > > enumeration type 'enum max9611_conf_ids' to different enumeration type
> > > 'enum max9611_csa_gain' [-Wenum-conversion]
> > >                         *csa_gain = gain_selectors[i];
> > >                                   ~ ^~~~~~~~~~~~~~~~~
> > > 1 warning generated.
> > >
> > > Change the type of the variable 'gain_selectors' to int so that Clang
> > > understands this is expected behavior.
> > >
> > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > How does this interact with the patch that Stefan Agner sent for
> > the same issue last week?

+ Stefan in case he has additional thoughts.  I don't feel strongly
about one patch vs the other.

> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?h=testing&id=b1ec0802503820ccbc894aadfd2a44da20232f5e
> >
> > Thanks,
> >
> > Jonathan
> >
>
> Hi Jonathan,
>
> Sorry for the overlap. My patch is not necessary. I was working off
> of linux-next so I didn't catch this. I'll be better about checking
> maintainer trees before sending patches in the future.
>
> Thanks for the quick response!
> Nathan
>
> > > ---
> > >  drivers/iio/adc/max9611.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> > > index 0538ff8c4ac1..3c358b16a8fa 100644
> > > --- a/drivers/iio/adc/max9611.c
> > > +++ b/drivers/iio/adc/max9611.c
> > > @@ -275,7 +275,7 @@ static int max9611_read_csa_voltage(struct max9611_dev *max9611,
> > >                                 u16 *adc_raw,
> > >                                 enum max9611_csa_gain *csa_gain)
> > >  {
> > > -   enum max9611_conf_ids gain_selectors[] = {
> > > +   int gain_selectors[] = {
> > >             CONF_SENSE_1x,
> > >             CONF_SENSE_4x,
> > >             CONF_SENSE_8x
> >



-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] iio: adc: max9611: Avoid implicit enum conversion warning
  2018-09-17 16:52     ` Nick Desaulniers
@ 2018-09-17 19:22       ` Stefan Agner
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Agner @ 2018-09-17 19:22 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Nathan Chancellor, jic23, knaack.h, lars, pmeerw, linux-iio, LKML

On 17.09.2018 09:52, Nick Desaulniers wrote:
> On Sun, Sep 16, 2018 at 8:15 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
>>
>> On Sun, Sep 16, 2018 at 10:53:51AM +0100, Jonathan Cameron wrote:
>> > On Fri, 14 Sep 2018 22:25:11 -0700
>> > Nathan Chancellor <natechancellor@gmail.com> wrote:
>> >
>> > > Clang warns when an enumerated type is implicitly converted to another.
>> > >
>> > > drivers/iio/adc/max9611.c:292:16: warning: implicit conversion from
>> > > enumeration type 'enum max9611_conf_ids' to different enumeration type
>> > > 'enum max9611_csa_gain' [-Wenum-conversion]
>> > >                         *csa_gain = gain_selectors[i];
>> > >                                   ~ ^~~~~~~~~~~~~~~~~
>> > > 1 warning generated.
>> > >
>> > > Change the type of the variable 'gain_selectors' to int so that Clang
>> > > understands this is expected behavior.
>> > >
>> > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
>> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>> > How does this interact with the patch that Stefan Agner sent for
>> > the same issue last week?
> 
> + Stefan in case he has additional thoughts.  I don't feel strongly
> about one patch vs the other.
> 

FWIW, only one is needed.

I prefer mine slightly over Nicks since it continues to use struct max9611_conf_ids which is the type required by the max9611_read_single() function..

I don't have a strong opinion though, and did not look deeper into why the driver makes the differentiation between struct max9611_conf_ids and ax9611_csa_gain...

--
Stefan


>> >
>> > https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?h=testing&id=b1ec0802503820ccbc894aadfd2a44da20232f5e
>> >
>> > Thanks,
>> >
>> > Jonathan
>> >
>>
>> Hi Jonathan,
>>
>> Sorry for the overlap. My patch is not necessary. I was working off
>> of linux-next so I didn't catch this. I'll be better about checking
>> maintainer trees before sending patches in the future.
>>
>> Thanks for the quick response!
>> Nathan
>>
>> > > ---
>> > >  drivers/iio/adc/max9611.c | 2 +-
>> > >  1 file changed, 1 insertion(+), 1 deletion(-)
>> > >
>> > > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
>> > > index 0538ff8c4ac1..3c358b16a8fa 100644
>> > > --- a/drivers/iio/adc/max9611.c
>> > > +++ b/drivers/iio/adc/max9611.c
>> > > @@ -275,7 +275,7 @@ static int max9611_read_csa_voltage(struct max9611_dev *max9611,
>> > >                                 u16 *adc_raw,
>> > >                                 enum max9611_csa_gain *csa_gain)
>> > >  {
>> > > -   enum max9611_conf_ids gain_selectors[] = {
>> > > +   int gain_selectors[] = {
>> > >             CONF_SENSE_1x,
>> > >             CONF_SENSE_4x,
>> > >             CONF_SENSE_8x
>> >

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

end of thread, other threads:[~2018-09-17 19:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-15  5:25 [PATCH] iio: adc: max9611: Avoid implicit enum conversion warning Nathan Chancellor
2018-09-16  9:53 ` Jonathan Cameron
2018-09-16 15:15   ` Nathan Chancellor
2018-09-17 16:52     ` Nick Desaulniers
2018-09-17 19:22       ` Stefan Agner

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