mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: a.zummo@towertech.it, alexandre.belloni@free-electrons.com,
	corbet@lwn.net
Cc: arnd@arndb.de, broonie@kernel.org, linux-rtc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	baolin.wang@linaro.org
Subject: [RFC PATCH 2/4] rtc: sysfs: Export the valid range supported by RTC hardware
Date: Tue,  2 Jan 2018 13:10:06 +0800	[thread overview]
Message-ID: <2f0fb91c39534ecc2e94148a1a6998ba32ab90cf.1514869622.git.baolin.wang@linaro.org> (raw)
In-Reply-To: <9ab56bdcaeb52241e22b738d6babe7b01728f64c.1514869621.git.baolin.wang@linaro.org>
In-Reply-To: <9ab56bdcaeb52241e22b738d6babe7b01728f64c.1514869621.git.baolin.wang@linaro.org>

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@linaro.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

  reply	other threads:[~2018-01-02  5:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-02  5:10 [RFC PATCH 1/4] rtc: Introduce one interface to save the RTC hardware time range Baolin Wang
2018-01-02  5:10 ` Baolin Wang [this message]
2018-01-02  5:10 ` [RFC PATCH 3/4] rtc: Add one offset seconds to expand RTC range Baolin Wang
2018-01-02  9:50   ` Alexandre Belloni
2018-01-02 12:16     ` Baolin Wang
2018-01-02  5:10 ` [RFC PATCH 4/4] rtc: sc27xx: Add the get_range interface Baolin Wang
2018-01-02  7:47 ` [RFC PATCH 1/4] rtc: Introduce one interface to save the RTC hardware time range Alexandre Belloni
2018-01-02  8:26   ` Baolin Wang

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=2f0fb91c39534ecc2e94148a1a6998ba32ab90cf.1514869622.git.baolin.wang@linaro.org \
    --to=baolin.wang@linaro.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®