From patchwork Wed Apr 27 22:34:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8963421 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 1119FBF29F for ; Wed, 27 Apr 2016 22:36:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3903720155 for ; Wed, 27 Apr 2016 22:36:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 195E5201F5 for ; Wed, 27 Apr 2016 22:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754052AbcD0Wfu (ORCPT ); Wed, 27 Apr 2016 18:35:50 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:56918 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754057AbcD0Wfq (ORCPT ); Wed, 27 Apr 2016 18:35:46 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MRlnN-1b6Idh2Zez-00T0Rl; Thu, 28 Apr 2016 00:34:52 +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 v3 10/16] rtc: m68k: provide ioctl for q40 Date: Thu, 28 Apr 2016 00:34:24 +0200 Message-Id: <1461796470-1291527-11-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1461796470-1291527-1-git-send-email-arnd@arndb.de> References: <1461796470-1291527-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:RktldUwS981WlONpG3MYrdX4r9/s9FgSDFmAYbARkPS9smtyIce tj/NDTJgmp2mwyZiYaNDsNltY0ZXwIQ6ucGTOhDBzyVn/boVshUzsBHRb6/YX/N3uLQZ5Fs R1fWYkmqNtA7xQ+ygp1V4OjqphfRlDUCxecGFE+GQuDPPt/yvJqjNd4MfyE/vCvLwBZN5ep /JTCFqb5HZELk4U3YnYbA== X-UI-Out-Filterresults: notjunk:1; V01:K0:fKb2ZsotwuI=:8vNhchmTrtfiAVvpOuxvik dpxccZGVODooPBmpxeQjeyf3VLL1P+5WnY0k00O2lEDUFI9PIYbqnaE7YRAdwX0cspafuXCNi GjIX32qvEFyPMMgWhDxALOWFwTK25gCrq0cRvySBSGo9UVhdQWmayLy+A76/7jTy8zTseZ5v/ C76dA3U9BzxEHkMIroWDgz6UDi7VOguWC4+uAfJTzHmlAxZLTRszZOv5jTBNO6VyNVctGnQVm 7jZ3418VMciK3jxOYzroGavflwd77nvta+RH1s8tqNZY11ga6LDPm8C9m47QtYg3VoWEHrvh/ RCevsfYRSJvqIZ9tyPeNRct/xnxDZq196yfiNnAarufNqLexEVnH2YMW4RAs/kmAbN4pNe03L srBkipsTpYwp11oxT1xVHEiatizM0HCu+RAIFydt1fdxiLinpU/HbZZoWlTtyk0Xqsozw6Ivz hJmueEY+BSmwaEeRjicoVCZr5z3fFbOEeA9z+7voV9Lhu7NGeJLmA7VjHWFfP3jCEOiBLmHtX bbQlMYR+/Q1HouPVpcpro5l7sbQ9eOWklwLozYMNTuE7kSDgqDr7MFyWsmVlMEmS9Yun7g3C0 IqSrpuwspAGoFjKnNc5gadIgjeev+pv9EwQSdslnLgFz2sB8Qetyo6+jsd4rYfFeYuBfozJLt yoZbqgVYH6R3R161w4ub6oJn4SlNj5kE3jCAiAeFo5l7wbxHGtAoPdDDoMGAhoXyDrG4= 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 80e024a10115..465423c07a92 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, };