lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  2 Jan 2018 13:10:06 +0800
From:   Baolin Wang <baolin.wang@...aro.org>
To:     a.zummo@...ertech.it, alexandre.belloni@...e-electrons.com,
        corbet@....net
Cc:     arnd@...db.de, broonie@...nel.org, linux-rtc@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
        baolin.wang@...aro.org
Subject: [RFC PATCH 2/4] rtc: sysfs: Export the valid range supported by RTC hardware

We have introduced one interface to get the RTC range, so this patch
exports the valid range supported by RTC hardware to userspace.

Signed-off-by: Baolin Wang <baolin.wang@...aro.org>
---
 Documentation/rtc.txt   |    2 ++
 drivers/rtc/rtc-sysfs.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt
index c0c9774..4fe437b 100644
--- a/Documentation/rtc.txt
+++ b/Documentation/rtc.txt
@@ -164,6 +164,8 @@ offset		 The amount which the rtc clock has been adjusted in firmware.
 		 which are added to or removed from the rtc's base clock per
 		 billion ticks. A positive value makes a day pass more slowly,
 		 longer, and a negative value makes a day pass more quickly.
+range_max	 The maximum time values in seconds supported by RTC hardware.
+range_min	 The minimum time values in seconds supported by RTC hardware.
 */nvmem		 The non volatile storage exported as a raw file, as described
 		 in Documentation/nvmem/nvmem.txt
 ================ ==============================================================
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 92ff2ed..60e1f6c 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -248,6 +248,34 @@
 }
 static DEVICE_ATTR_RW(offset);
 
+static ssize_t
+range_max_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	ssize_t retval;
+	time64_t max_hw_secs, min_hw_secs;
+
+	retval = rtc_read_range(to_rtc_device(dev), &max_hw_secs, &min_hw_secs);
+	if (retval == 0)
+		retval = sprintf(buf, "%lld\n", max_hw_secs);
+
+	return retval;
+}
+static DEVICE_ATTR_RO(range_max);
+
+static ssize_t
+range_min_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	ssize_t retval;
+	time64_t max_hw_secs, min_hw_secs;
+
+	retval = rtc_read_range(to_rtc_device(dev), &max_hw_secs, &min_hw_secs);
+	if (retval == 0)
+		retval = sprintf(buf, "%lld\n", min_hw_secs);
+
+	return retval;
+}
+static DEVICE_ATTR_RO(range_min);
+
 static struct attribute *rtc_attrs[] = {
 	&dev_attr_name.attr,
 	&dev_attr_date.attr,
@@ -257,6 +285,8 @@
 	&dev_attr_hctosys.attr,
 	&dev_attr_wakealarm.attr,
 	&dev_attr_offset.attr,
+	&dev_attr_range_max.attr,
+	&dev_attr_range_min.attr,
 	NULL,
 };
 
-- 
1.7.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ