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: 8946321 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F17BDBF29F for ; Tue, 26 Apr 2016 21:54:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 235382011E for ; Tue, 26 Apr 2016 21:54:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41A2920107 for ; Tue, 26 Apr 2016 21:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753336AbcDZVxZ (ORCPT ); Tue, 26 Apr 2016 17:53:25 -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-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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, };