Skip to content

Commit

Permalink
staging:iio:adis16400: Don't pass 0 to ilog2
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Jan 26, 2013
1 parent 3f6a0ba commit 06220b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/staging/iio/imu/adis16400_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 06220b8

Please sign in to comment.