MGS-3806: clocksource: tpm: make sure returning -ETIME case correct
authorAnson Huang <Anson.Huang@nxp.com>
Wed, 18 Apr 2018 07:20:03 +0000 (15:20 +0800)
committerAnson Huang <Anson.Huang@nxp.com>
Thu, 19 Apr 2018 01:18:12 +0000 (09:18 +0800)
Incorrect condition check causes -ETIME return only
happen when next event is equal to current counter, and
it would cause various system issue like RCU stalls etc.,
the correct case should be whenever next event is less
than current counter, -ETIME should be returned. Correct
the type cast during return condition check to make it
work right.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Bai Ping <ping.bai@nxp.com>
drivers/clocksource/timer-imx-tpm.c

index f1c87a2..92001e5 100644 (file)
@@ -105,7 +105,7 @@ static int tpm_set_next_event(unsigned long delta,
         * of writing CNT registers which may cause the min_delta event got
         * missed, so we need add a ETIME check here in case it happened.
         */
-       return (int)((next - now) <= 0) ? -ETIME : 0;
+       return (int)(next - now) <= 0 ? -ETIME : 0;
 }
 
 static int tpm_set_state_oneshot(struct clock_event_device *evt)