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: 102425 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2444574qge; Wed, 27 Apr 2016 15:36:05 -0700 (PDT) X-Received: by 10.98.28.84 with SMTP id c81mr15643717pfc.131.1461796565558; Wed, 27 Apr 2016 15:36:05 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si7549059paw.142.2016.04.27.15.36.05; Wed, 27 Apr 2016 15:36:05 -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 S1754116AbcD0Wfu (ORCPT + 29 others); 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-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 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, };