* [PATCH 3/6] staging:iio:ad7291 fix ad7291_threshold_reg()
@ 2014-07-08 11:06 Hartmut Knaack
2014-07-08 20:10 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Hartmut Knaack @ 2014-07-08 11:06 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron, Lars-Peter Clausen
ad7291_threshold_reg() should return the register number of a threshold
register, and thus be safe without handling a default case.
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
---
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
index f5d29ef..b868c64 100644
--- a/drivers/staging/iio/adc/ad7291.c
+++ b/drivers/staging/iio/adc/ad7291.c
@@ -174,8 +174,6 @@ static unsigned int ad7291_threshold_reg(const struct iio_chan_spec *chan,
case IIO_TEMP:
offset = 8;
break;
- default:
- return 0;
}
switch (info) {
@@ -186,10 +184,7 @@ static unsigned int ad7291_threshold_reg(const struct iio_chan_spec *chan,
return AD7291_DATA_LOW(offset);
case IIO_EV_INFO_HYSTERESIS:
return AD7291_HYST(offset);
- default:
- break;
}
- return 0;
}
static int ad7291_read_event_value(struct iio_dev *indio_dev,
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/6] staging:iio:ad7291 fix ad7291_threshold_reg()
2014-07-08 11:06 [PATCH 3/6] staging:iio:ad7291 fix ad7291_threshold_reg() Hartmut Knaack
@ 2014-07-08 20:10 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2014-07-08 20:10 UTC (permalink / raw)
To: Hartmut Knaack, linux-iio; +Cc: Lars-Peter Clausen
On 08/07/14 12:06, Hartmut Knaack wrote:
> ad7291_threshold_reg() should return the register number of a threshold
> register, and thus be safe without handling a default case.
Whilst the code is bug free without those defaults currently I'd rather keep them
there to suppress the warnings we will get without them...
Also without an explanation, please don't stick 'fix' in the title - makes
my fingers want to send it to stable.
Warning wise...
e.g. with gcc4.9 on x86_64 I get the following tiny output ;)
CC [M] drivers/staging/iio/adc/ad7291.o
drivers/staging/iio/adc/ad7291.c: In function ‘ad7291_threshold_reg’:
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_CURRENT’ not handled in switch [-Wswitch]
switch (chan->type) {
^
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_POWER’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_ACCEL’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_ANGL_VEL’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_MAGN’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_LIGHT’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_INTENSITY’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_PROXIMITY’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_INCLI’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_ROT’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_ANGL’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_TIMESTAMP’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_CAPACITANCE’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_ALTVOLTAGE’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_CCT’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_PRESSURE’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:170:2: warning: enumeration value ‘IIO_HUMIDITYRELATIVE’ not handled in switch [-Wswitch]
drivers/staging/iio/adc/ad7291.c:179:2: warning: enumeration value ‘IIO_EV_INFO_ENABLE’ not handled in switch [-Wswitch]
switch (info) {
^
drivers/staging/iio/adc/ad7291.c:188:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
drivers/staging/iio/adc/ad7291.c: In function ‘ad7291_threshold_reg.isra.5’:
drivers/staging/iio/adc/ad7291.c:45:31: warning: ‘offset’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define AD7291_HYST(x) ((x) * 3 + 0x6)
^
drivers/staging/iio/adc/ad7291.c:168:15: note: ‘offset’ was declared here
unsigned int offset;
^
>
> Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
> ---
> diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
> index f5d29ef..b868c64 100644
> --- a/drivers/staging/iio/adc/ad7291.c
> +++ b/drivers/staging/iio/adc/ad7291.c
> @@ -174,8 +174,6 @@ static unsigned int ad7291_threshold_reg(const struct iio_chan_spec *chan,
> case IIO_TEMP:
> offset = 8;
> break;
> - default:
> - return 0;
> }
>
> switch (info) {
> @@ -186,10 +184,7 @@ static unsigned int ad7291_threshold_reg(const struct iio_chan_spec *chan,
> return AD7291_DATA_LOW(offset);
> case IIO_EV_INFO_HYSTERESIS:
> return AD7291_HYST(offset);
> - default:
> - break;
> }
> - return 0;
> }
>
> static int ad7291_read_event_value(struct iio_dev *indio_dev,
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-08 20:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-08 11:06 [PATCH 3/6] staging:iio:ad7291 fix ad7291_threshold_reg() Hartmut Knaack
2014-07-08 20:10 ` Jonathan Cameron
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).