iio: afe: rescale: reduce risk of integer overflow
authorLiam Beguin <liambeguin@gmail.com>
Sun, 13 Feb 2022 02:57:34 +0000 (21:57 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 27 Feb 2022 13:38:22 +0000 (13:38 +0000)
commit2eb30577f2533463afed3456141d4becc4f79e91
treef509210b0d40fd695bdda219b2d0f653e0f4145f
parentf5fc003d48033559314f1c9de8198f58f14ed557
iio: afe: rescale: reduce risk of integer overflow

Reduce the risk of integer overflow by doing the scale calculation on
a 64-bit integer. Since the rescaling is only performed on *val, reuse
the IIO_VAL_FRACTIONAL_LOG2 case.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Reviewed-by: Peter Rosin <peda@axentia.se>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220213025739.2561834-6-liambeguin@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/afe/iio-rescale.c