iio: adc: max9611: Avoid implicit enum conversion warning
PATCH 1/1 iio: adc: max9611: Avoid implicit enum conversion warning
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.
--- drivers/iio/adc/max9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/max9611.c +1 -1
@@ -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
Signature · 1 line
2.18.0
Jonathan Cameron
maintainerQuoted 7 lines · On Fri, 14 Sep 2018 22:25:11 -0700 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 'enummax9611_conf_ids' to different enumeration type 'enummax9611_csa_gain' [-Wenum-conversion]*csa_gain = gain_selectors[i]; ~ ^~~~~~~~~~~~~~~~~
Quoted 7 lines
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 <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
How does this interact with the patch that Stefan Agner sent for the same issue last week?
Thanks,
Jonathan
Quoted 17 lines
--- drivers/iio/adc/max9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/adc/max9611.c +1
-1@@ -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
Quoted 17 lines · Jonathan Cameron
Quoted 7 lines · On Fri, 14 Sep 2018 22:25:11 -0700 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 'enummax9611_conf_ids' to different enumeration type 'enummax9611_csa_gain' [-Wenum-conversion]*csa_gain = gain_selectors[i]; ~ ^~~~~~~~~~~~~~~~~Quoted 7 lines
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 <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Quoted 9 lines
How does this interact with the patch that Stefan Agner sent for the same issue last week?
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
Quoted 18 lines
Quoted 17 lines
--- drivers/iio/adc/max9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/adc/max9611.c +1
-1@@ -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
Quoted 14 lines · Nathan Chancellor
Quoted 12 lines · Jonathan Cameron
Quoted 9 lines · On Fri, 14 Sep 2018 22:25:11 -0700 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 'enummax9611_conf_ids' to different enumeration type 'enummax9611_csa_gain' [-Wenum-conversion]*csa_gain = gain_selectors[i]; ~ ^~~~~~~~~~~~~~~~~1 warning generated.
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Change the type of the variable '
gain_selectors' to int so that Clang understands this is expected behavior.Reported-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>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.
Quoted 35 lines
Quoted 7 lines
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!
NathanQuoted 18 lines
Quoted 17 lines
--- drivers/iio/adc/max9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/adc/max9611.c +1
-1@@ -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
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 19 lines · Nick Desaulniers
Quoted 17 lines · Nathan Chancellor
Quoted 15 lines · Jonathan Cameron
Quoted 12 lines · On Fri, 14 Sep 2018 22:25:11 -0700 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 'enummax9611_conf_ids' to different enumeration type 'enummax9611_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.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Reported-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>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
Quoted 35 lines
Quoted 35 lines
Quoted 7 lines
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!
NathanQuoted 18 lines
Quoted 17 lines
--- drivers/iio/adc/max9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/adc/max9611.c +1
-1@@ -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