diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-09-17 13:26:00 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-09-17 22:09:59 +0100 |
commit | 37812d2e10e5790f3cc3319055aac0647080c4af (patch) | |
tree | 6f7b69bccef02ce8098d8e8c5afd429481dfbc1b /drivers | |
parent | a0e545e0e75006a7de0e9bc5397f6b44c61990b2 (diff) | |
download | linux-37812d2e10e5790f3cc3319055aac0647080c4af.tar.bz2 |
staging:iio:trigger:bfintmr: Avoid divide by zero
If the timer frequency has not been configured yet get_gptimer_period() will
return 0. Handle this case instead of blindly dividing by the returned value.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c index ce6a7b1b8860..2772ea2fb0dc 100644 --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c @@ -99,9 +99,15 @@ static ssize_t iio_bfin_tmr_frequency_show(struct device *dev, { struct iio_trigger *trig = to_iio_trigger(dev); struct bfin_tmr_state *st = trig->private_data; + unsigned int period = get_gptimer_period(st->t->id); + unsigned long val; - return sprintf(buf, "%lu\n", - get_sclk() / get_gptimer_period(st->t->id)); + if (period == 0) + val = 0; + else + val = get_sclk() / get_gptimer_period(st->t->id); + + return sprintf(buf, "%lu\n", val); } static DEVICE_ATTR(frequency, S_IRUGO | S_IWUSR, iio_bfin_tmr_frequency_show, |