From patchwork Tue Apr 26 21:52:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102441 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1851034qge; Tue, 26 Apr 2016 14:53:31 -0700 (PDT) X-Received: by 10.98.3.133 with SMTP id 127mr6936572pfd.93.1461707611492; Tue, 26 Apr 2016 14:53:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j186si895067pfb.136.2016.04.26.14.53.30; Tue, 26 Apr 2016 14:53:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753384AbcDZVx1 (ORCPT + 29 others); Tue, 26 Apr 2016 17:53:27 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:53165 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753304AbcDZVxX (ORCPT ); Tue, 26 Apr 2016 17:53:23 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0LzHnN-1bps9y0mDB-014Xax; Tue, 26 Apr 2016 23:52:43 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, dalias@libc.org, dhowells@redhat.com, linux-alpha@vger.kernel.org, a.zummo@towertech.it, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-m68k@lists.linux-m68k.org, rtc-linux@googlegroups.com, linux-arch@vger.kernel.org Subject: [PATCH v2 2/6] rtc: m68k: provide ioctl for q40 Date: Tue, 26 Apr 2016 23:52:27 +0200 Message-Id: <1461707551-1337971-3-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1461707551-1337971-1-git-send-email-arnd@arndb.de> References: <1461707551-1337971-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:bZrkVoRWw85RJj0mzAeNVRe2/3m37ZaxKL3N7wP0lTIeb9YygL7 eTBPheQFllo6mIbjVkaUbMgCQZeHlw1pMRsMNHc3NT6vhw4jWb+RFbIe1pjSEvnYLh/ilxz Zz6wAAoSHZlaaaW1FJRCktAG7Bmye88pOWr5xht91U+gI3ribdJEvrNz7mYVDC5Acca301G giMaPuHshqCpFRXIf7HRQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:rr7j+HUTrbY=:WuR09wj7egjikmSEB9LDEw 7/EV922Ee6IsqtpICqno/Q/OmlyXNkW9KhZF3WZKRF1gARCyOe2fNEnelYz1vy3zyDVp1tPSL ZlzMUM54LQGNw++4wVVmGujfkXM0zYyopHG8vPZ8G3P4aRimNfJQwFmri6cNvbOBMDcchaScm GXldqTP91TbBoGyGdZxDUqnBqR+Zp93BIn2VLkpTt6pIcvmHjR3TnRiHo7NHTVjVAyv5bBGy1 zvelYGrqo2DlUpelIg0z15pCmTagXr3MpImRTXfKTYJ8LPc88CzU3U+Pb1yXuqsB/Jlqkaie6 JIEl+puXZbxvRH/3BM9rDYfTThO7fAC7WzPAIn+D/a6ryHTL4Zq4UbKmQqTU70TTh3f43Ywax tGD2n2DN8uxFPfbf1/goiperdaokqZdf+nmbJM0JlbnNYdQyoF11hB3aZ1zqeGPkm5YszFI23 MFDxipMfizdEZH4GU5ymly97i1BGm6zlH+jcF0gw9nGs4kK0igwNO5JbUztXXE4O8gZ2TOzni i5i4yPhWJfRoZsecUhyRLFkC+72F7oR7fHcRtShzKsLqy19nMVE0+EuK3FLZhD1mi5k32YF9i zwBKo/86NFUS+n4IPD+0CSNJN2mKuDltSrEV/6HLZMUPmeGnF4ucvoQ8ViDC9j4usakqpW74b 52pso2Pii83QoZoOxObFZME7h4dcVLt1DIjHHZ5z46l3GgqdsyyNTWMoGZHRKyD7ljwU= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/m68k/kernel/time.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 2.7.0 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, };