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>
This commit is contained in:
parent
ad6e4b6fdc
commit
58a54f03e7
@ -663,13 +663,13 @@ static int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer,
|
|||||||
{
|
{
|
||||||
u32 l;
|
u32 l;
|
||||||
|
|
||||||
if (unlikely(!timer))
|
if (unlikely(!timer) || prescaler < -1 || prescaler > 7)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
omap_dm_timer_enable(timer);
|
omap_dm_timer_enable(timer);
|
||||||
l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
|
l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
|
||||||
l &= ~(OMAP_TIMER_CTRL_PRE | (0x07 << 2));
|
l &= ~(OMAP_TIMER_CTRL_PRE | (0x07 << 2));
|
||||||
if (prescaler >= 0x00 && prescaler <= 0x07) {
|
if (prescaler >= 0) {
|
||||||
l |= OMAP_TIMER_CTRL_PRE;
|
l |= OMAP_TIMER_CTRL_PRE;
|
||||||
l |= prescaler << 2;
|
l |= prescaler << 2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user