lkml.org 
[lkml]   [2003]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [pm] fix time after suspend-to-*
From
Date
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/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.106 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site