]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: ad4000: don't use shift_right()
authorDavid Lechner <dlechner@baylibre.com>
Wed, 2 Jul 2025 13:23:00 +0000 (08:23 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 13 Jul 2025 14:36:25 +0000 (15:36 +0100)
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].

Link: https://github.com/analogdevicesinc/linux/pull/2831/files#diff-c14a34a6492576d22e7192cc0f61ad0083190aeb627191596fe12462f0c6f21aR557
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250702-iio-adc-ad4000-don-t-use-shift_right-v1-1-041c2d6c3950@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad4000.c

index 5609a7845b6f50b5818613170df6b234f8f0c496..fd3d79fca78581e51bb904d0bcfeda3d3663ea25 100644 (file)
@@ -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 */