Merge branch 'writeback' of git://git.kernel.dk/linux-2.6-block
[pandora-kernel.git] / drivers / rtc / rtc-sysfs.c
index 4d27ccc..7dd23a6 100644 (file)
@@ -102,6 +102,19 @@ rtc_sysfs_set_max_user_freq(struct device *dev, struct device_attribute *attr,
        return n;
 }
 
+static ssize_t
+rtc_sysfs_show_hctosys(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+#ifdef CONFIG_RTC_HCTOSYS_DEVICE
+       if (strcmp(dev_name(&to_rtc_device(dev)->dev),
+                  CONFIG_RTC_HCTOSYS_DEVICE) == 0)
+               return sprintf(buf, "1\n");
+       else
+#endif
+               return sprintf(buf, "0\n");
+}
+
 static struct device_attribute rtc_attrs[] = {
        __ATTR(name, S_IRUGO, rtc_sysfs_show_name, NULL),
        __ATTR(date, S_IRUGO, rtc_sysfs_show_date, NULL),
@@ -109,6 +122,7 @@ static struct device_attribute rtc_attrs[] = {
        __ATTR(since_epoch, S_IRUGO, rtc_sysfs_show_since_epoch, NULL),
        __ATTR(max_user_freq, S_IRUGO | S_IWUSR, rtc_sysfs_show_max_user_freq,
                        rtc_sysfs_set_max_user_freq),
+       __ATTR(hctosys, S_IRUGO, rtc_sysfs_show_hctosys, NULL),
        { },
 };
 
@@ -145,6 +159,8 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
        unsigned long now, alarm;
        struct rtc_wkalrm alm;
        struct rtc_device *rtc = to_rtc_device(dev);
+       char *buf_ptr;
+       int adjust = 0;
 
        /* Only request alarms that trigger in the future.  Disable them
         * by writing another time, e.g. 0 meaning Jan 1 1970 UTC.
@@ -154,7 +170,15 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
                return retval;
        rtc_tm_to_time(&alm.time, &now);
 
-       alarm = simple_strtoul(buf, NULL, 0);
+       buf_ptr = (char *)buf;
+       if (*buf_ptr == '+') {
+               buf_ptr++;
+               adjust = 1;
+       }
+       alarm = simple_strtoul(buf_ptr, NULL, 0);
+       if (adjust) {
+               alarm += now;
+       }
        if (alarm > now) {
                /* Avoid accidentally clobbering active alarms; we can't
                 * entirely prevent that here, without even the minimal