aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Yakui <yakui.zhao@intel.com>2008-04-28 05:11:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:17 -0400
commitc116bc2ae516e9949d645bc75b1ee294ff15db23 (patch)
tree9296da3e37dfc8f80566624faf781f19d41ea9f1
parente2bfe3424b368e977002fc58f81536d5d8ea9449 (diff)
rtc: add the support for alarm time relative to current time in sysfs
In current kernel if we want to set the alarm time, the absolute time the seconds relative to 1970-01-01 00:00:00) should be written into /sys/class/rtc/rtc0/wakealarm. It is not convenient. It is more reasonable to add the support for the alarm time relative to current RTC time.(the unit is second) For example: If the RTC is required to generate alarm after 2 minutes, the following will be OK. echo +120 > /sys/class/rtc/rtc0/wakealarm or echo +0x78 > /sys/class/rtc/rtc0/wakealarm Signed-off-by: Zhao Yakui <yakui.zhao@intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/rtc/rtc-sysfs.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 4d27ccc4fc06..2531ce4c9db0 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -145,6 +145,8 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
145 unsigned long now, alarm; 145 unsigned long now, alarm;
146 struct rtc_wkalrm alm; 146 struct rtc_wkalrm alm;
147 struct rtc_device *rtc = to_rtc_device(dev); 147 struct rtc_device *rtc = to_rtc_device(dev);
148 char *buf_ptr;
149 int adjust = 0;
148 150
149 /* Only request alarms that trigger in the future. Disable them 151 /* Only request alarms that trigger in the future. Disable them
150 * by writing another time, e.g. 0 meaning Jan 1 1970 UTC. 152 * by writing another time, e.g. 0 meaning Jan 1 1970 UTC.
@@ -154,7 +156,15 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
154 return retval; 156 return retval;
155 rtc_tm_to_time(&alm.time, &now); 157 rtc_tm_to_time(&alm.time, &now);
156 158
157 alarm = simple_strtoul(buf, NULL, 0); 159 buf_ptr = (char *)buf;
160 if (*buf_ptr == '+') {
161 buf_ptr++;
162 adjust = 1;
163 }
164 alarm = simple_strtoul(buf_ptr, NULL, 0);
165 if (adjust) {
166 alarm += now;
167 }
158 if (alarm > now) { 168 if (alarm > now) {
159 /* Avoid accidentally clobbering active alarms; we can't 169 /* Avoid accidentally clobbering active alarms; we can't
160 * entirely prevent that here, without even the minimal 170 * entirely prevent that here, without even the minimal