From: Anson Huang Date: Wed, 18 Apr 2018 07:20:03 +0000 (+0800) Subject: MGS-3806: clocksource: tpm: make sure returning -ETIME case correct X-Git-Tag: C0P2-H0.0--20200415~66 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=25fbe1eba777a1f93ccb045037194166cdfdecc0;p=linux.git MGS-3806: clocksource: tpm: make sure returning -ETIME case correct 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 Reviewed-by: Bai Ping --- diff --git a/drivers/clocksource/timer-imx-tpm.c b/drivers/clocksource/timer-imx-tpm.c index f1c87a27ec46..92001e5a4cef 100644 --- a/drivers/clocksource/timer-imx-tpm.c +++ b/drivers/clocksource/timer-imx-tpm.c @@ -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)