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 --
| Theodore Tso | Re: -mm merge plans for 2.6.23 -- sys_fallocate |
| Amit K. Arora | [RFC] Heads up on sys_fallocate() |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 011/196] sysfs: Fix a copy-n-paste typo in comment |
git: | |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | Re: [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Frans Pop | svc: failed to register lockdv1 RPC service (errno 97). |
