From: Matthew Garrett <mjg@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com,
Matthew Garrett <mjg@redhat.com>
Subject: [PATCH 2/2] rtc: Add boot_timesource sysfs attribute
Date: Fri, 4 Sep 2009 12:26:08 -0400 [thread overview]
Message-ID: <1252081568-6000-2-git-send-email-mjg@redhat.com> (raw)
In-Reply-To: <1252081568-6000-1-git-send-email-mjg@redhat.com>
CONFIG_RTC_HCTOSYS allows the kernel to read the system time from the RTC
at boot and resume, avoiding the need for userspace to do so. Unfortunately
userspace currently has no way to know whether this configuration option
is enabled and thus cannot sensibly choose whether to run hwclock itself or
not. Add a boot_timesource sysfs attribute which indicates whether a given
RTC set the system clock.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
Documentation/rtc.txt | 2 ++
drivers/rtc/rtc-sysfs.c | 14 ++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt
index 216bb8c..a086cad 100644
--- a/Documentation/rtc.txt
+++ b/Documentation/rtc.txt
@@ -142,6 +142,8 @@ The sysfs interface under /sys/class/rtc/rtcN provides access to various
rtc attributes without requiring the use of ioctls. All dates and times
are in the RTC's timezone, rather than in system time.
+boot_timesource: 1 if the RTC provided the system time at boot via the
+ CONFIG_RTC_HCTOSYS kernel option, 0 otherwise
date: RTC-provided date
max_user_freq: The maximum interrupt rate an unprivileged user may request
from this RTC.
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 2531ce4..dbd6af8 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -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(boot_timesource, S_IRUGO, rtc_sysfs_show_hctosys, NULL),
{ },
};
--
1.6.4.1
next prev parent reply other threads:[~2009-09-04 16:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-04 16:26 [PATCH 1/2] rtc: Document the sysfs interface Matthew Garrett
2009-09-04 16:26 ` Matthew Garrett [this message]
2009-09-04 16:25 ` [rtc-linux] [PATCH 2/2] rtc: Add boot_timesource sysfs attribute Alessandro Zummo
2009-09-04 16:30 ` Matthew Garrett
2009-09-04 16:38 ` [rtc-linux] " Alessandro Zummo
2009-09-04 16:41 ` Matthew Garrett
2009-09-04 16:52 ` Alessandro Zummo
2009-09-04 16:55 ` Matthew Garrett
2009-09-04 17:03 ` Alessandro Zummo
2009-09-04 17:09 ` Matthew Garrett
2009-09-05 21:11 ` Alessandro Zummo
2009-09-06 1:34 ` Mark Brown
2009-09-14 22:59 ` Karel Zak
2009-09-04 16:26 ` [rtc-linux] [PATCH 1/2] rtc: Document the sysfs interface Alessandro Zummo
2009-09-04 16:35 ` Mark Brown
2009-09-04 16:39 ` Matthew Garrett
2009-09-04 16:52 ` [rtc-linux] " Mark Brown
2009-09-04 23:23 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1252081568-6000-2-git-send-email-mjg@redhat.com \
--to=mjg@redhat.com \
--cc=a.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox