/* * NOTE: RTC times displayed in sysfs use the RTC's timezone. That's * ideally UTC. However, PCs that also boot to MS-Windows normally use * the local time and change to match daylight savings time. That affects * attributes including date, time, since_epoch, and wakealarm.
*/
err = kstrtoul(buf, 0, &val); if (err) return err;
if (val >= 4096 || val == 0) return -EINVAL;
rtc->max_user_freq = (int)val;
return n;
} static DEVICE_ATTR_RW(max_user_freq);
/** * hctosys_show - indicate if the given RTC set the system time * @dev: The device that the attribute belongs to. * @attr: The attribute being read. * @buf: The result buffer. * * buf is "1" if the system clock was set by this RTC at the last * boot or resume event.
*/ static ssize_t
hctosys_show(struct device *dev, struct device_attribute *attr, char *buf)
{ #ifdef CONFIG_RTC_HCTOSYS_DEVICE if (rtc_hctosys_ret == 0 &&
strcmp(dev_name(&to_rtc_device(dev)->dev),
CONFIG_RTC_HCTOSYS_DEVICE) == 0) return sysfs_emit(buf, "1\n"); #endif return sysfs_emit(buf, "0\n");
} static DEVICE_ATTR_RO(hctosys);
/* Don't show disabled alarms. For uniformity, RTC alarms are * conceptually one-shot, even though some common RTCs (on PCs) * don't actually work that way. * * NOTE: RTC implementations where the alarm doesn't match an * exact YYYY-MM-DD HH:MM[:SS] date *must* disable their RTC * alarms after they trigger, to ensure one-shot semantics.
*/
retval = rtc_read_alarm(to_rtc_device(dev), &alm); if (retval) return retval;
if (alm.enabled) return sysfs_emit(buf, "%lld\n", rtc_tm_to_time64(&alm.time));
/* Only request alarms that trigger in the future. Disable them * by writing another time, e.g. 0 meaning Jan 1 1970 UTC.
*/
retval = rtc_read_time(rtc, &alm.time); if (retval < 0) return retval;
now = rtc_tm_to_time64(&alm.time);
buf_ptr = buf; if (*buf_ptr == '+') {
buf_ptr++; if (*buf_ptr == '=') {
buf_ptr++;
push = 1;
} else {
adjust = 1;
}
}
retval = kstrtos64(buf_ptr, 0, &alarm); if (retval) return retval; if (adjust)
alarm += now; if (alarm > now || push) { /* Avoid accidentally clobbering active alarms; we can't * entirely prevent that here, without even the minimal * locking from the /dev/rtcN api.
*/
retval = rtc_read_alarm(rtc, &alm); if (retval < 0) return retval; if (alm.enabled) { if (push) {
push = rtc_tm_to_time64(&alm.time);
alarm += push;
} else return -EBUSY;
} elseif (push) return -EINVAL;
alm.enabled = 1;
} else {
alm.enabled = 0;
/* Provide a valid future alarm time. Linux isn't EFI, * this time won't be ignored when disabling the alarm.
*/
alarm = now + 300;
}
rtc_time64_to_tm(alarm, &alm.time);
/* The reason to trigger an alarm with no process watching it (via sysfs) * is its side effect: waking from a system state like suspend-to-RAM or * suspend-to-disk. So: no attribute unless that side effect is possible. * (Userspace may disable that mechanism later.)
*/ staticbool rtc_does_wakealarm(struct rtc_device *rtc)
{ if (!device_can_wakeup(rtc->dev.parent)) returnfalse;
if (grps) { for (groups = grps; *groups; groups++)
add_cnt++; /* No need to modify current groups if nothing new is provided */ if (add_cnt == 0) return 0;
} else { return -EINVAL;
}
groups = rtc->dev.groups; if (groups) for (; *groups; groups++)
old_cnt++;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.