Messages in this thread Patch in this message | | | Date | Thu, 23 Oct 2003 01:33:06 +0200 | From | Pavel Machek <> | Subject | [pm] fix time after suspend-to-* |
| |
Hi!
This adds suspend/resume methods for time, so that real time is refreshed from cmos when suspend is finished. Please apply,
Pavel [Code was copied from apm.c, someone familiar from apm.c can probably kill it from there -- after adding device_power_down() and device_power_up() to right places].
--- tmp/linux/arch/i386/kernel/time.c 2003-10-09 00:13:14.000000000 +0200 +++ linux/arch/i386/kernel/time.c 2003-10-23 01:05:36.000000000 +0200 @@ -271,16 +271,39 @@ unsigned long retval; spin_lock(&rtc_lock); - retval = mach_get_cmos_time(); - spin_unlock(&rtc_lock); return retval; } +static long clock_cmos_diff; +static int got_clock_diff; + +static int pit_suspend(struct sys_device *dev, u32 state) +{ + /* + * Estimate time zone so that set_time can update the clock + */ + clock_cmos_diff = -get_cmos_time(); + clock_cmos_diff += get_seconds(); + got_clock_diff = 1; + return 0; +} + +static int pit_resume(struct sys_device *dev) +{ + if (got_clock_diff) { /* Must know time zone in order to set clock */ + xtime.tv_sec = get_cmos_time() + clock_cmos_diff; + xtime.tv_nsec = 0; + } + return 0; +} + static struct sysdev_class pit_sysclass = { set_kset_name("pit"), + .resume = pit_resume, + .suspend = pit_suspend, }; /* XXX this driverfs stuff should probably go elsewhere later -john */ -- When do you have a heart between your knees? [Johanka's followup: and *two* hearts?] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |