[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1461707551-1337971-3-git-send-email-arnd@arndb.de>
Date: Tue, 26 Apr 2016 23:52:27 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
Cc: Arnd Bergmann <arnd@...db.de>, geert@...ux-m68k.org, deller@....de,
benh@...nel.crashing.org, mpe@...erman.id.au, dalias@...c.org,
dhowells@...hat.com, linux-alpha@...r.kernel.org,
a.zummo@...ertech.it, linux-kernel@...r.kernel.org,
linux-parisc@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-sh@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
rtc-linux@...glegroups.com, linux-arch@...r.kernel.org
Subject: [PATCH v2 2/6] rtc: m68k: provide ioctl for q40
The q40 platform is the only machine in the kernel that provides
RTC_PLL_GET/RTC_PLL_SET ioctl commands in its rtc through the
mach_get_rtc_pll/mach_set_rtc_pll callbacks.
However, this currenctly works only in the old-style genrtc
driver, not the (somewhat) modern rtc-generic driver replacing
it. This adds an ioctl implementation to the m68k generic_rtc_ops
in order to let both drivers provide the same API.
After this, we should be able to remove support for genrtc
from the m68k architecture.
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
arch/m68k/kernel/time.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index fe35890feede..5f0a5826a05e 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -100,7 +100,32 @@ static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
return 0;
}
+static int rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+ struct rtc_pll_info pll;
+ struct rtc_pll_info __user *argp = (void __user *)arg;
+
+ switch (cmd) {
+ case RTC_PLL_GET:
+ if (!mach_get_rtc_pll || mach_get_rtc_pll(&pll))
+ return -EINVAL;
+ return copy_to_user(argp, &pll, sizeof pll) ? -EFAULT : 0;
+
+ case RTC_PLL_SET:
+ if (!mach_set_rtc_pll)
+ return -EINVAL;
+ if (!capable(CAP_SYS_TIME))
+ return -EACCES;
+ if (copy_from_user(&pll, argp, sizeof(pll)))
+ return -EFAULT;
+ return mach_set_rtc_pll(&pll);
+ }
+
+ return -ENOIOCTLCMD;
+}
+
static const struct rtc_class_ops generic_rtc_ops = {
+ .ioctl = rtc_ioctl,
.read_time = rtc_generic_get_time,
.set_time = rtc_generic_set_time,
};
--
2.7.0
Powered by blists - more mailing lists