Thread (20 messages) 20 messages, 4 authors, 2018-01-08

[PATCH v6 10/10] clocksource: timer-dm: Check prescaler value

From: Ladislav Michl <hidden>
Date: 2018-01-04 22:47:19
Also in: linux-omap, linux-pwm, lkml

On Tue, Jan 02, 2018 at 03:39:59PM +0530, Keerthy wrote:
quoted hunk ↗ jump to hunk
From: Ladislav Michl <redacted>

Invalid prescaler value is silently ignored. Fix that
by returning -EINVAL in such case. As invalid value
disabled use of the prescaler, use -1 explicitely for
that purpose.

Signed-off-by: Ladislav Michl <redacted>
---
 drivers/clocksource/timer-dm.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c
index 60db173..01a9cb0 100644
--- a/drivers/clocksource/timer-dm.c
+++ b/drivers/clocksource/timer-dm.c
@@ -672,6 +672,9 @@ int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler)
 	if (prescaler >= 0x00 && prescaler <= 0x07) {
 		l |= OMAP_TIMER_CTRL_PRE;
 		l |= prescaler << 2;
+	} else {
+		if (prescaler != -1)
+			return -EINVAL;
Argh... This is actually wrong, as it leaves timer enabled.
I suggest simply dropping this patch and I'll rethink whole
approach a bit later (and better).
 	}
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
 
Sorry for the noise,
	ladis
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help