Re: [linux-pm] sleepy linux self-test

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Pavel Machek <pavel@...>
Cc: <linux-pm@...>, Ingo Molnar <mingo@...>, kernel list <linux-kernel@...>
Date: Saturday, February 2, 2008 - 1:31 pm

On Saturday 02 February 2008, Pavel Machek wrote:

Which is why I was puzzled that you didn't start out doing it
the "right" way ... even just hard-wiring the dubious assumption
that "rtc0" is the right RTC to use.  :)



Well, "rtc which (a) has an alarm, (b) may be used for system wakeup".

Assuming there *is* such an RTC ... fortunately, there will usually be
one on systems that are designed to go to sleep.



Easy enough.  Given an RTC device node, you can tell whether it has
no chance at all to meet those requirements:

	static int has_wakealarm(struct device *dev, void *name_ptr)
	{
		struct rtc_device *rtc = to_rtc_device(dev);

		/* (a) has an alarm */
		if (!rtc->op->set_alarm)
			return 0;

		/* (b) may be used for system wakeup */
		if (device_may_wakeup(dev->parent))
			return 0;
		
		*(char **)name_ptr = rtc->name;
		return 1;
	}

Then there's a new class interface you may not have known about,
since it's been merged barely over a week now.  You can use it
to find the name of the rtc to pass to rtc_open():

	static char *find_wake_rtc(void)
	{
		char *pony = NULL;

		dev = class_find_device(rtc_class, &rtc, has_wakealarm);
		return pony;
	}

On most PCs that will return the name "rtc0" ... and it'll do
the same on most of the other systems I have.  On both of the
two-RTC systems I have that will return "rtc1".   On systems
with no wakealarm-enabled RTC, that will return NULL.

Voila!

- Dave
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
sleepy linux self-test, Pavel Machek, (Wed Jan 30, 9:17 am)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Thu Jan 31, 9:55 pm)
Re: [linux-pm] sleepy linux self-test, Pavel Machek, (Sat Feb 2, 8:47 am)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sat Feb 2, 1:31 pm)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sat Feb 2, 2:00 pm)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sat Feb 2, 3:13 pm)
Re: [linux-pm] sleepy linux self-test, Pavel Machek, (Sat Feb 2, 3:32 pm)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sat Feb 2, 3:38 pm)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sat Feb 2, 10:37 pm)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sun Feb 3, 1:05 am)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sun Feb 3, 1:14 am)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sun Feb 3, 3:18 am)
Re: [linux-pm] sleepy linux self-test, Sam Ravnborg, (Sun Feb 3, 3:51 am)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sun Feb 3, 4:26 am)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sun Feb 3, 1:19 am)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sun Feb 3, 1:35 am)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sun Feb 3, 1:54 am)
Re: [linux-pm] sleepy linux self-test, Pavel Machek, (Sun Feb 10, 5:02 pm)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sun Feb 3, 3:05 am)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sun Feb 3, 3:32 am)
Re: [linux-pm] sleepy linux self-test, Rafael J. Wysocki, (Sun Feb 3, 8:21 am)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sun Feb 3, 9:16 am)
Re: [linux-pm] sleepy linux self-test, Pavel Machek, (Mon Feb 18, 4:56 am)
[patch] suspend/resume self-test, Ingo Molnar, (Mon Feb 18, 5:46 am)
Re: [patch] suspend/resume self-test, Rafael J. Wysocki, (Mon Feb 18, 7:06 am)
Re: [patch] suspend/resume self-test, Pavel Machek, (Mon Feb 18, 5:53 am)
Re: [patch] suspend/resume self-test, David Brownell, (Mon Feb 18, 6:40 am)
Re: [patch] suspend/resume self-test, Ingo Molnar, (Mon Feb 18, 9:09 am)
Re: [patch] suspend/resume self-test, David Brownell, (Mon Feb 18, 4:16 pm)
Re: [patch] suspend/resume self-test, Ingo Molnar, (Tue Feb 19, 10:40 am)
Re: [patch] suspend/resume self-test, Pavel Machek, (Tue Feb 19, 6:11 am)
Re: [patch] suspend/resume self-test, Ingo Molnar, (Tue Feb 19, 10:43 am)
Re: [patch] suspend/resume self-test, David Brownell, (Tue Feb 19, 3:12 pm)
Re: [patch] suspend/resume self-test, Ingo Molnar, (Wed Feb 20, 6:15 am)
Re: [patch] suspend/resume self-test, Rafael J. Wysocki, (Mon Feb 18, 7:04 am)
Re: [linux-pm] sleepy linux self-test, Rafael J. Wysocki, (Sun Feb 3, 5:29 pm)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sun Feb 3, 6:42 pm)
Re: [linux-pm] sleepy linux self-test, Pavel Machek, (Sun Feb 3, 6:48 pm)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sun Feb 3, 7:08 pm)
Re: [linux-pm] sleepy linux self-test, Pavel Machek, (Sun Feb 10, 5:03 pm)
Re: [linux-pm] sleepy linux self-test, Rafael J. Wysocki, (Sun Feb 3, 6:43 pm)
Re: [linux-pm] sleepy linux self-test, Pavel Machek, (Sat Feb 2, 3:59 pm)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sat Feb 2, 1:51 pm)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sat Feb 2, 9:50 am)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sat Feb 2, 1:49 pm)
Re: [linux-pm] sleepy linux self-test, Ingo Molnar, (Sat Feb 2, 2:06 pm)
Re: [linux-pm] sleepy linux self-test, David Brownell, (Sat Feb 2, 3:47 pm)
Re: sleepy linux self-test, Ingo Molnar, (Wed Jan 30, 3:36 pm)
Re: sleepy linux self-test, Pavel Machek, (Wed Jan 30, 7:26 pm)
Re: sleepy linux self-test, Ingo Molnar, (Fri Feb 1, 10:22 am)
Re: sleepy linux self-test, Pavel Machek, (Sat Feb 2, 8:45 am)
Re: sleepy linux self-test, Ingo Molnar, (Sat Feb 2, 9:51 am)
Re: sleepy linux self-test, Ingo Molnar, (Sat Feb 2, 9:49 am)
Re: sleepy linux self-test, Ingo Molnar, (Wed Jan 30, 12:35 pm)
Re: sleepy linux self-test, Pavel Machek, (Wed Jan 30, 12:39 pm)