From patchwork Mon May 30 18:57:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9141973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4843D60757 for ; Mon, 30 May 2016 18:58:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CAD628066 for ; Mon, 30 May 2016 18:58:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FAC82819C; Mon, 30 May 2016 18:58:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE47328066 for ; Mon, 30 May 2016 18:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161918AbcE3S63 (ORCPT ); Mon, 30 May 2016 14:58:29 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60208 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161855AbcE3S6Z (ORCPT ); Mon, 30 May 2016 14:58:25 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MTxeT-1az2Cm3Bon-00QnVn; Mon, 30 May 2016 20:58:02 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.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 v4 10/16] rtc: m68k: provide ioctl for q40 Date: Mon, 30 May 2016 20:57:58 +0200 Message-Id: <1464634684-1248135-11-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:gHIkoH1ulTlAW4drwalu3Aq1cX6DSBjBf4x1GaEqfDQV4MjZbxe BZ3FDqtKMgsvGpnq4rKSdZhGKQtAMWsosbgn/hsZgPHOvoWraZ0pO2zrHWGqD3CTw03WrQu xErDHmJTQwbWTC0FPUH4eXPXIx2b21hzQrTMHv4tRZITHQE1RN7/7PfdHGq02oFnDmFJrZX AtYz9i19TAFsSpENXnF8Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:ur4YYMqA46w=:ogt8yCwt4e3TtUvZWALOV5 +BbjIa/KG8/A4+iG/d1AGaiEdb3WZRC3P6HkqNpH6W31ZhIpyuqjQ+RwShXEO32pNYlUYQi+Y htXnViT1nTw9hVRon2ukNB8sR0RHG36rwXtKbmTDMH2zwTJyoh7wlMFqTnb4fRM+2qunPv4Gf wxAu5toVkgkHNieYzHIloZkRs4fwv+JJGTsK3HnRjaBRzdw0CplFwRUGExIn12jAsDgyFmLKI Py8Y+5Lrc0Xl8m6lMqnPjVOg3JQRCiYWnFV/08xojaJNSsknkjUSHTIY16Ck3+eu4NiKcjd19 sqpBIHSxKQmWrowHmnN+Eq5fcTmjJsVEeXIMfxjKNLcEMeh4ScG0RLaVC1wBGeGkQREz7tLx/ 5YFFSdHZ2G6Gzt10ZwPMz6i2SYEGEp0Jo/NWRBoTCBEVsprnrt6aPBQ59DVmwQeZTJ5RLysJn BzRpTe5TMUZtzWJilQnepuu5Ggg1Um8JmVifxh4IVfBuvTKCklqksY4Q1juwD5/oQga0ZjJrK fH1mYfK13vb1jB2QuHBE1EAQrcHnHjMhcVUes1cFv9ijaPiC2VSwaZlSVD0VqmYOOXDy0okRx LjWb0dJggvyVbTqxaBzEjg4UCuH6ahr7k40oTCZLUgNvZm0wr8R4PTq1m8GZAB332LQ4yUFGB DiNhdBON+KHLJI+bHeVAtfE2CjHuMdeMjaCQTnhZUyvopXa0ex3JRvW+IkXx6TtEW52Q= Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.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 bd6417d38d5a..4e5aa2f4f522 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, };