iio: adc: ad4000: don't use shift_right()
Subsystems (3)
David Lechner
reviewerPATCH 1/1 iio: adc: ad4000: don't use shift_right()
Drop use of shift_right() macro for unsigned value. The shift_right() macro is intended for signed values and is not needed for unsigned values.
This was found by a static analysis tool [1].
--- drivers/iio/adc/ad4000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad4000.c +1 -1
@@ -554,7 +554,7 @@ static void ad4000_fill_scale_tbl(struct ad4000_state *st, val =mult_frac (st->vref_mv,MICRO , st->gain_milli);/* Would multiply by NANO here but we multiplied by extra MILLI */ - tmp2 =shift_right ((u64 )val *MICRO , scale_bits); + tmp2 = (u64 )val *MICRO >> scale_bits; tmp0 =div_s64_rem (tmp2,NANO , &tmp1);/* Store scale for when span compression is disabled */
---
base-commit: 6742eff60460e77158d4f1b233f17e0345c9e66a
change-id: 20250702-iio-adc-ad4000-don-t-use-shift_right-bda6e41152b6
Best regards,
Signature · 1 line
David Lechner <[email protected]>
Quoted 11 lines · David Lechner
Drop use of
shift_right()macro for unsigned value. Theshift_right()macro is intended for signed values and is not needed for unsigned values.This was found by a static analysis tool [1].
[1]Signed-off-by David Lechner <[email protected]>---
Quoted 24 lines
drivers/iio/adc/ad4000.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/adc/ad4000.c +0
-0index
5609a7845b6f50b5818613170df6b234f8f0c496..fd3d79fca78581e51bb904d0bcfeda3d3663ea25 100644drivers/iio/adc/ad4000.c +0
-0@@ -554,7 +554,7 @@ static void ad4000_fill_scale_tbl(struct ad4000_state *st, val = mult_frac(st->vref_mv, MICRO, st->gain_milli);
/* Would multiply by NANO here but we multiplied by extra MILLI */drivers/iio/adc/ad4000.c +1
-1- tmp2 =shift_right ((u64 )val *MICRO , scale_bits); + tmp2 = (u64 )val *MICRO >> scale_bits;tmp0 =
div_s64_rem(tmp2, NANO, &tmp1);
/* Store scale for when span compression is disabled */---
base-commit:6742eff60460e77158d4f1b233f17e0345c9e66a
change-id: 20250702-iio-adc-ad4000-don-t-use-shift_right-bda6e41152b6Best regards,
Quoted 7 lines · On Wed, 02 Jul 2025 15:09:19 +0100 Nuno Sá <[email protected]> wrote:
Quoted 6 lines · David Lechner
Drop use of
shift_right()macro for unsigned value. Theshift_right()macro is intended for signed values and is not needed for unsigned values.This was found by a static analysis tool [1].
Quoted 7 lines
Quoted 5 lines
[1]Signed-off-by David Lechner <[email protected]>---
Reviewed-by Nuno Sá <[email protected]>
Applied.
Quoted 26 lines
Quoted 25 lines
drivers/iio/adc/ad4000.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/adc/ad4000.c +0
-0index
5609a7845b6f50b5818613170df6b234f8f0c496..fd3d79fca78581e51bb904d0bcfeda3d3663ea25 100644drivers/iio/adc/ad4000.c +0
-0@@ -554,7 +554,7 @@ static void ad4000_fill_scale_tbl(struct ad4000_state *st, val = mult_frac(st->vref_mv, MICRO, st->gain_milli);
/* Would multiply by NANO here but we multiplied by extra MILLI */drivers/iio/adc/ad4000.c +1
-1- tmp2 =shift_right ((u64 )val *MICRO , scale_bits); + tmp2 = (u64 )val *MICRO >> scale_bits;tmp0 =
div_s64_rem(tmp2, NANO, &tmp1);
/* Store scale for when span compression is disabled */---
base-commit:6742eff60460e77158d4f1b233f17e0345c9e66a
change-id: 20250702-iio-adc-ad4000-don-t-use-shift_right-bda6e41152b6Best regards,
Quoted 9 lines · David Lechner
Drop use of
shift_right()macro for unsigned value. Theshift_right()macro is intended for signed values and is not needed for unsigned values.This was found by a static analysis tool [1].
Signed-off-by David Lechner <[email protected]>---
Quoted 26 lines
drivers/iio/adc/ad4000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/adc/ad4000.c +1
-2@@ -554,7 +554,7 @@ static void ad4000_fill_scale_tbl(struct ad4000_state *st, val =mult_frac (st->vref_mv,MICRO , st->gain_milli);/* Would multiply by NANO here but we multiplied by extra MILLI */ - tmp2 =shift_right ((u64 )val *MICRO , scale_bits); + tmp2 = (u64 )val *MICRO >> scale_bits; tmp0 =div_s64_rem (tmp2,NANO , &tmp1);/* Store scale for when span compression is disabled */ ---base-commit:
6742eff60460e77158d4f1b233f17e0345c9e66a
change-id: 20250702-iio-adc-ad4000-don-t-use-shift_right-bda6e41152b6Best regards,
Signature · 1 line
David Lechner <[email protected]>