summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2017-09-23 10:30:24 +0100
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2024-03-26 12:20:53 +0000
commit41afca166c28e4056e9e859102660d1b1df6aa38 (patch)
tree085b78410be47471ac71a95a6d72594295fd2d6e /drivers
parente8f897f4afef0031fe618a8e94127a0934896aba (diff)
rtc: export RTC setting offset via sysfs
Export the RTC time set offset via sysfs so the value can be read and tweaked as necessary. This is useful when determining the correct setting for a RTC, as it eliminates the need to rebuild/install/reboot from the test cycle. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/sysfs.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/rtc/sysfs.c b/drivers/rtc/sysfs.c
index e3062c4d3f2c..2255e7c3da71 100644
--- a/drivers/rtc/sysfs.c
+++ b/drivers/rtc/sysfs.c
@@ -244,6 +244,31 @@ offset_store(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR_RW(offset);
static ssize_t
+set_offset_nsec_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%ld\n", to_rtc_device(dev)->set_offset_nsec);
+}
+
+static ssize_t
+set_offset_nsec_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t n)
+{
+ struct rtc_device *rtc = to_rtc_device(dev);
+ long val;
+ int err;
+
+ err = kstrtol(buf, 0, &val);
+ if (err)
+ return err;
+
+ rtc->set_offset_nsec = val;
+
+ return n;
+}
+static DEVICE_ATTR_RW(set_offset_nsec);
+
+static ssize_t
range_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "[%lld,%llu]\n", to_rtc_device(dev)->range_min,
@@ -260,6 +285,7 @@ static struct attribute *rtc_attrs[] = {
&dev_attr_hctosys.attr,
&dev_attr_wakealarm.attr,
&dev_attr_offset.attr,
+ &dev_attr_set_offset_nsec.attr,
&dev_attr_range.attr,
NULL,
};