iio: humidity: htc100c: Fix checkpatch warn unnecessary else
PATCH 1/1 iio: humidity: htc100c: Fix checkpatch warn unnecessary else
Checkpatch warning:
WARNING:UNNECESSARY_ELSE: else is not generally useful after a break or return
+ return IIO_VAL_FRACTIONAL;
+ } else {
--- drivers/iio/humidity/hdc100x.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/humidity/hdc100x.c +1 -3
@@ -229,13 +229,11 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev,if (chan->type ==IIO_TEMP ) { *val =165000 ; *val2 =65536 ; -return IIO_VAL_FRACTIONAL ; }else { *val =100000 ; *val2 =65536 ; -return IIO_VAL_FRACTIONAL ; } -break ; +return IIO_VAL_FRACTIONAL ;case IIO_CHAN_INFO_OFFSET : *val =-15887 ; *val2 =515151 ;
Signature · 1 line
2.47.3
David Lechner
reviewerQuoted 1 line · Adi Nata
Checkpatch warning:
Making checkpatch happy is not a good reason for a change on it's own. It is only there for guidance. It is not a strict rule that has to be followed.
I think this is a good change because it reduces duplication of the return statements and eliminates an unreachable break statement. So write the commit message with that reasoning and don't mention checkpatch.
Quoted 29 lines
WARNING:UNNECESSARY_ELSE: else is not generally useful after a break or return
(quoted diff) +2
-0+ return IIO_VAL_FRACTIONAL; + } else {Signed-off-by Adi Nata <[email protected]>--- drivers/iio/humidity/hdc100x.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/iio/humidity/hdc100x.c +1
-3@@ -229,13 +229,11 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev,if (chan->type ==IIO_TEMP ) { *val =165000 ; *val2 =65536 ; -return IIO_VAL_FRACTIONAL ; }else { *val =100000 ; *val2 =65536 ; -return IIO_VAL_FRACTIONAL ; } -break ; +return IIO_VAL_FRACTIONAL ;case IIO_CHAN_INFO_OFFSET : *val =-15887 ; *val2 =515151 ;
Jonathan Cameron
maintainerQuoted 10 lines · On Sun, 2 Aug 2026 09:48:11 -0500 David Lechner <[email protected]> wrote:
Quoted 1 line · Adi Nata
Checkpatch warning:
Making checkpatch happy is not a good reason for a change on it's own. It is only there for guidance. It is not a strict rule that has to be followed.
I think this is a good change because it reduces duplication of the return statements and eliminates an unreachable break statement. So write the commit message with that reasoning and don't mention checkpatch.
A 'whilst I was looking at this code' comment below if you want to take on an additional minor readability improvement. Whilst it is a bit churn heavy given touching most of the code you are changing here, I think it would still need to be a separate follow on patch. Also do check my suggestion carefully as I may have missed something!
thanks,
Jonathan
Quoted 11 lines
Quoted 11 lines
WARNING:UNNECESSARY_ELSE: else is not generally useful after a break or return
(quoted diff) +2
-0+ return IIO_VAL_FRACTIONAL; + } else {Signed-off-by Adi Nata <[email protected]>--- drivers/iio/humidity/hdc100x.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 8 lines
drivers/iio/humidity/hdc100x.c static int hdc100x_read_raw(struct iio_dev *indio_dev, · line 231
Quoted 8 lines
drivers/iio/humidity/hdc100x.c +0
-0@@ -229,13 +229,11 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev,if (chan->type ==IIO_TEMP ) { *val =165000 ; *val2 =65536 ;
A whilst we are here comment.
This is 2**16 So maybe can use chan->real_bits
to provide a form of documentation of where it comes from and then return IIO_VAL_FRACTIONAL_LOG2;
Quoted 12 lines
Quoted 11 lines
drivers/iio/humidity/hdc100x.c +1
-3-return IIO_VAL_FRACTIONAL ; }else { *val =100000 ; *val2 =65536 ; -return IIO_VAL_FRACTIONAL ; } -break ; +return IIO_VAL_FRACTIONAL ;case IIO_CHAN_INFO_OFFSET : *val =-15887 ; *val2 =515151 ;