summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-s35390a.c
diff options
context:
space:
mode:
authorFabien Lahoudere <fabien.lahoudere@collabora.co.uk>2017-07-05 10:02:30 +0200
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-07-31 00:17:44 +0200
commit7a1fe407fc2a4bbe32a8473c92e2988bc9d25fc3 (patch)
tree38141c826d827dd7204d8af99caa67b69e89f61d /drivers/rtc/rtc-s35390a.c
parent16486d0c1c659d4ab502c5bea408654287edcb74 (diff)
downloadlinux-7a1fe407fc2a4bbe32a8473c92e2988bc9d25fc3.tar.bz2
rtc: s35390a: implement ioctls
Implements RTC_VL_READ and RTC_VL_CLR ioctls. Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc/rtc-s35390a.c')
-rw-r--r--drivers/rtc/rtc-s35390a.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 3aec3b225bc4..7067bca5c20d 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -404,12 +404,42 @@ static int s35390a_rtc_set_time(struct device *dev, struct rtc_time *tm)
return s35390a_set_datetime(to_i2c_client(dev), tm);
}
+static int s35390a_rtc_ioctl(struct device *dev, unsigned int cmd,
+ unsigned long arg)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct s35390a *s35390a = i2c_get_clientdata(client);
+ char sts;
+ int err;
+
+ switch (cmd) {
+ case RTC_VL_READ:
+ /* s35390a_reset set lowvoltage flag and init RTC if needed */
+ err = s35390a_read_status(s35390a, &sts);
+ if (err < 0)
+ return err;
+ if (copy_to_user((void __user *)arg, &err, sizeof(int)))
+ return -EFAULT;
+ break;
+ case RTC_VL_CLR:
+ /* update flag and clear register */
+ err = s35390a_init(s35390a);
+ if (err < 0)
+ return err;
+ break;
+ default:
+ return -ENOIOCTLCMD;
+ }
+
+ return 0;
+}
+
static const struct rtc_class_ops s35390a_rtc_ops = {
.read_time = s35390a_rtc_read_time,
.set_time = s35390a_rtc_set_time,
.set_alarm = s35390a_rtc_set_alarm,
.read_alarm = s35390a_rtc_read_alarm,
-
+ .ioctl = s35390a_rtc_ioctl,
};
static struct i2c_driver s35390a_driver;