]> git.baikalelectronics.ru Git - kernel.git/commit
iio: core: Fix IIO_VAL_FRACTIONAL_LOG2 for negative values
authorNikolaus Schulz <nikolaus.schulz@avionic-design.de>
Fri, 24 Mar 2017 12:41:51 +0000 (13:41 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sun, 2 Apr 2017 10:14:49 +0000 (11:14 +0100)
commitde27ef743a6e58ed3d665f2f5c47f95bcea5ee57
treea47926f7b3e59dbb76684b9f18a1c3f2f2ae9082
parentb5fd00cd4b951398c4362a33b62f9d9b48b9bf81
iio: core: Fix IIO_VAL_FRACTIONAL_LOG2 for negative values

Fix formatting of negative values of type IIO_VAL_FRACTIONAL_LOG2 by
switching from do_div(), which can't handle negative numbers, to
div_s64_rem().  Also use shift_right for shifting, which is safe with
negative values.

Signed-off-by: Nikolaus Schulz <nikolaus.schulz@avionic-design.de>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/industrialio-core.c