Messages in this thread | | | Subject | Re: [pm] fix time after suspend-to-* | From | john stultz <> | Date | 22 Oct 2003 16:52:21 -0700 |
| |
On Wed, 2003-10-22 at 16:33, Pavel Machek wrote: > Hi! > > This adds suspend/resume methods for time, so that real time is > refreshed from cmos when suspend is finished. Please apply, >
[snip]
> > +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, > };
Forgive me, I'm not totally familiar w/ the sysfs/pm stuff, but normally you need to have the xtime_lock to safely manipulate xtime. Also, couldn't you just call settimeofday() instead? The bit about manually setting the timezone also confuses me, as we don't normally do this at bootup in the kernel.
thanks -john
- 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/
| |