diff options
author | Ladislav Michl <ladis@linux-mips.org> | 2018-02-23 11:15:01 +0100 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2018-02-28 22:41:30 +0100 |
commit | 58a54f03e73d67432216931854363e4ba15839b9 (patch) | |
tree | 2eff25bbed5762ec7ac87a2ad57b1fcac8567bab /drivers/clocksource | |
parent | clocksource: timer-ti-dm: Consolidate set source (diff) | |
download | linux-58a54f03e73d67432216931854363e4ba15839b9.tar.xz linux-58a54f03e73d67432216931854363e4ba15839b9.zip |
clocksource: timer-ti-dm: Check prescaler value
Invalid value silently disables use of the prescaler.
Use -1 explicitely for that purpose and error out on
invalid value.
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/timer-ti-dm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c index 6abe5ab553ce..4cce6b224b87 100644 --- a/drivers/clocksource/timer-ti-dm.c +++ b/drivers/clocksource/timer-ti-dm.c @@ -663,13 +663,13 @@ static int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, { u32 l; - if (unlikely(!timer)) + if (unlikely(!timer) || prescaler < -1 || prescaler > 7) return -EINVAL; omap_dm_timer_enable(timer); l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); l &= ~(OMAP_TIMER_CTRL_PRE | (0x07 << 2)); - if (prescaler >= 0x00 && prescaler <= 0x07) { + if (prescaler >= 0) { l |= OMAP_TIMER_CTRL_PRE; l |= prescaler << 2; } |