OSDN Git Service

rtc: Fix some bugs that allowed accumulating time drift in suspend/resume
authorArve Hjønnevåg <arve@android.com>
Tue, 22 Nov 2011 22:56:50 +0000 (14:56 -0800)
committerArve Hjønnevåg <arve@android.com>
Wed, 23 Nov 2011 00:49:58 +0000 (16:49 -0800)
commit9d187300dfeb825b3c851458427a7046d9302c06
treed5010644fe6d9cae37502c8ab7cf154e918fa5f5
parent452d440ab295475afb04dee90879f5fb70254659
rtc: Fix some bugs that allowed accumulating time drift in suspend/resume

The current code checks if abs(delta_delta.tv_sec) is greater or
equal to two before it discards the old delta value, but this can
trigger at close to -1 seconds since -1.000000001 seconds is stored
as tv_sec -2 and tv_nsec 999999999 in a normalized timespec.

rtc_resume had an early return check if the rtc value had not changed
since rtc_suspend. This effectivly stops time for the duration of the
short sleep. Check if sleep_time is positive after all the adjustments
have been applied instead since this allows the old_system adjustment
in rtc_suspend to have an effect even for short sleep cycles.

Change-Id: I00b45c0349ec91a4bab9b41a126b377515427898
Signed-off-by: Arve Hjønnevåg <arve@android.com>
drivers/rtc/class.c