summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-01-16 12:48:00 +0000
committerJonathan Cameron <jic23@kernel.org>2013-01-26 10:07:46 +0000
commit06220b89f2284f910f925676d757fd3331138dc6 (patch)
tree685002999cda586edf7a844da7c73f0eeef5289d
parent3f6a0bad61e34c648fd08ff8dcbfdd58148963d2 (diff)
staging:iio:adis16400: Don't pass 0 to ilog2
ilog2 is not defined for 0, so we need to handle the case where the requested frequency is larger than the base sampling rate. In this case we'll round down and set the sampling rate to the base sampling rate. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/staging/iio/imu/adis16400_core.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index 9c8f5ab7e13b..cb6622578e9b 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -178,7 +178,11 @@ static int adis16334_set_freq(struct iio_dev *indio_dev, unsigned int freq)
{
unsigned int t;
- t = ilog2(8192 / (freq * 10));
+ freq *= 10;
+ if (freq < 8192)
+ t = ilog2(8192 / freq);
+ else
+ t = 0;
if (t > 0x31)
t = 0x31;