From patchwork Tue Apr 26 21:52:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102442 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1851023qge; Tue, 26 Apr 2016 14:53:30 -0700 (PDT) X-Received: by 10.66.253.68 with SMTP id zy4mr6874219pac.81.1461707610899; Tue, 26 Apr 2016 14:53:30 -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:30 -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 S1753330AbcDZVxX (ORCPT + 29 others); Tue, 26 Apr 2016 17:53:23 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:63640 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752483AbcDZVxT (ORCPT ); Tue, 26 Apr 2016 17:53:19 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0MCfv0-1b3O6S2sks-009Oq4; Tue, 26 Apr 2016 23:52:42 +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 1/6] rtc: m68k: provide rtc_class_ops directly Date: Tue, 26 Apr 2016 23:52:26 +0200 Message-Id: <1461707551-1337971-2-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:umHbvw3BrrmVGhUeJRiTj40axPEgiQYTRd8evKw0atZKkXncTLy Zlprx1JQdwFocxBJH2grNRZHRSDNddfESyvAHvMcxbiUjNK1dP/rDjiuFzUxeG7flpFuiq3 BMlYm30AU1gIgoyAbxS6SlyGxgW5FQydt2w9U5EF4gDBqZ6kBmwwBMQjYOuzAn5UuseKuWi TG73vsH+B3ixHp1wsxVfw== X-UI-Out-Filterresults: notjunk:1; V01:K0:PA50AUbxmHY=:iUPUTWnWNrKQOkR34aFdEX 7ZYpR0qefsIkqIOFUbm5CVYN5YwnG4JfVrpt7d02HuhCSV0a8NV7ikF7sqi0DEpnaVUTz744I 97j94MFaGXSgc/n3bBnI3VA/rN/EgymuDjSIWBREXIkQuHI3ZSxYB1Oen63sz0Q2UbF7PjNvQ aocjIWYxJ62chmLcQaL1Ax34l8MFLusdcwbAYY1fGUZ7iaIOGla517HDy8DLln/2OOD51Feey nUnSn3Z2os4p5laVhDesSDCwGtdkWipGbX4kqeWv+ySP+Jo1vbFSO6E2Bm2TKVFxhPkOaFCBT 2hpMmcR3tFzlBDqkIRoBTcDSOPkTv5xbilt+ulVNl8ZtezZoKGq0iMTSnOnSeo1CzApc2XgK6 QidnzkkpBUugteWYp3YcQfCvpvW8D8/KPvkFOKPN03kr7ISNavAttkP2fH0Svm0C1Vu7C6fN4 vo46/KZmjE5BHSQVDuw4UXg4eqDx8d5sjop9rU6oYxnJotj1dpA1TQmPgQpHCOIz898P/Lwr8 ZKYbd0q+nrsa9O+A/3wYvZmtbrrynEkYIlgEGbPHp0vmldvxTtZl3nXaOZS2GcnSkvax0d3/c 1EhR984RTgPkiyGuyCeFUTtP7BU7FM5tGGlAOoN59WCpqIdOJAzlgeo4pptVm33nTXrYtpj+l oydXm5gnOcgB9sAEgELdRWMSbetfbsX5wluvMWRn+nZyyfKZBc2mdOiu/b4fp8MkQo8Y= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rtc-generic driver provides an architecture specific wrapper on top of the generic rtc_class_ops abstraction, and m68k has another abstraction on top, which is a bit silly. This changes the m68k rtc-generic device to provide its rtc_class_ops directly, to reduce the number of layers by one. Signed-off-by: Arnd Bergmann --- arch/m68k/kernel/time.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) -- 2.7.0 diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c index 3857737e3958..fe35890feede 100644 --- a/arch/m68k/kernel/time.c +++ b/arch/m68k/kernel/time.c @@ -86,7 +86,24 @@ void read_persistent_clock(struct timespec *ts) } } -#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET +#if defined(CONFIG_ARCH_USES_GETTIMEOFFSET) && defined(CONFIG_RTC_DRV_GENERIC) +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) +{ + mach_hwclk(0, tm); + return rtc_valid_tm(tm); +} + +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) +{ + if (mach_hwclk(1, tm) < 0) + return -EOPNOTSUPP; + return 0; +} + +static const struct rtc_class_ops generic_rtc_ops = { + .read_time = rtc_generic_get_time, + .set_time = rtc_generic_set_time, +}; static int __init rtc_init(void) { @@ -95,7 +112,10 @@ static int __init rtc_init(void) if (!mach_hwclk) return -ENODEV; - pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); + /* or just call devm_rtc_device_register instead? */ + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &generic_rtc_ops, + sizeof(generic_rtc_ops)); return PTR_ERR_OR_ZERO(pdev); } 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, }; From patchwork Tue Apr 26 21:52:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102438 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1851356qge; Tue, 26 Apr 2016 14:54:26 -0700 (PDT) X-Received: by 10.67.8.100 with SMTP id dj4mr7024543pad.88.1461707666451; Tue, 26 Apr 2016 14:54:26 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xz4si1018163pab.139.2016.04.26.14.54.26; Tue, 26 Apr 2016 14:54:26 -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 S1753091AbcDZVyY (ORCPT + 29 others); Tue, 26 Apr 2016 17:54:24 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:60488 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753267AbcDZVxW (ORCPT ); Tue, 26 Apr 2016 17:53:22 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0MHrNV-1arc0M2tDR-003Zfv; 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 3/6] rtc: powerpc: provide rtc_class_ops directly Date: Tue, 26 Apr 2016 23:52:28 +0200 Message-Id: <1461707551-1337971-4-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:wB9ArzOGllSfulVAKWkmyatGDRl47pDaaj1TChyrTT2PUtm/B5L 1SChGDj9DYuHylhLqcdHGvKL2b76VaE+ISm9PxiSGWtAZUefe/ROLRpih8YV9gGDYo+PqU0 0jmtOBNi4f7xfyQuBFEU47QkxuH4XOjkd7xtGy0gKsn07zxH89qVfe3iulmqsnCtQegNmX7 zYUmT6eWiv/iez9aQnDJw== X-UI-Out-Filterresults: notjunk:1; V01:K0:e1L+zIgEn98=:28KExmvohc9Ieoz54LvN91 tt8q5ozlhfmwmagItWyfwFYR8aWknIewVvRZhQe4Nua9tW5BCdKwvfJnMFAF9JabuobAIaK/U 09BYk8P23aiwyVbrz8GDnqdt79b5mFNn66nF8pemXtv2gQ+EdvVSqzTJRAHotLKuGmNklSirz ufawckvp99DS8nlVqrBjVFHNYPdybUCF3IiNGXzZ+UZpj16iFbHdB4aDoDoW1x2vsk4gzNbgu ldvfXmZkZWR1Yn9JTjN+bAnZPLWslWY23k3xr0v1dF05KNN4fCqd1goFtwRmWl1DfoxDlvGFB KaavSE5hyrt+XZLg6xgDAz7zLJyx5PtoaQPOM9FEplHkTNVBAQiwlYVxCBADajQiiu04hm6iz PEmSjpsUHi667hTLS7J5a5pVaA9dM2OjiMv8xpsLsX01M18VFVWEIMNZ5lDdC+C8xZj52L6WU g4z7L63M9vzndlV2PRgzZmcm5Z8BF9AKKZjv/neTibRoZjbC1FeYivOL6cEBMzyKRL9kxs344 7aJH8IJ8cBOsSOkiX9gJxFNCzEmrQobNhg6n3PVflKkzbim89DFOTyr8fM51ZPOzN3R8XKnGj Rq3BJCKQPsAfSb0QPM5987BBoRg0UDhIUV6KqsvGwfbNCfn9rjvumQViEGrRjYdbEei7IbHmQ PXS8vaWKNzlP4/YkHSI5pB+easJNaJXE5qehtZgqLe7WdAjcemX1QSBKTXYvHAvL7M/E= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rtc-generic driver provides an architecture specific wrapper on top of the generic rtc_class_ops abstraction, and powerpc has another abstraction on top, which is a bit silly. This changes the powerpc rtc-generic device to provide its rtc_class_ops directly, to reduce the number of layers by one. Signed-off-by: Arnd Bergmann --- arch/powerpc/kernel/time.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) -- 2.7.0 diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 3ed9a5a21d77..aeac4d9591f9 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -1081,6 +1082,29 @@ void calibrate_delay(void) loops_per_jiffy = tb_ticks_per_jiffy; } +#ifdef CONFIG_RTC_DRV_GENERIC +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) +{ + ppc_md.get_rtc_time(tm); + return rtc_valid_tm(tm); +} + +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) +{ + if (!ppc_md.set_rtc_time) + return -EOPNOTSUPP; + + if (ppc_md.set_rtc_time(tm) < 0) + return -EOPNOTSUPP; + + return 0; +} + +static const struct rtc_class_ops rtc_generic_ops = { + .read_time = rtc_generic_get_time, + .set_time = rtc_generic_set_time, +}; + static int __init rtc_init(void) { struct platform_device *pdev; @@ -1088,9 +1112,12 @@ static int __init rtc_init(void) if (!ppc_md.get_rtc_time) return -ENODEV; - pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &rtc_generic_ops, + sizeof(rtc_generic_ops)); return PTR_ERR_OR_ZERO(pdev); } device_initcall(rtc_init); +#endif From patchwork Tue Apr 26 21:52:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102440 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1851166qge; Tue, 26 Apr 2016 14:53:54 -0700 (PDT) X-Received: by 10.98.50.67 with SMTP id y64mr6965467pfy.128.1461707634785; Tue, 26 Apr 2016 14:53:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u62si5629509pfi.150.2016.04.26.14.53.54; Tue, 26 Apr 2016 14:53:54 -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 S1753422AbcDZVxc (ORCPT + 29 others); Tue, 26 Apr 2016 17:53:32 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:56441 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753304AbcDZVx3 (ORCPT ); Tue, 26 Apr 2016 17:53:29 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0MPIxM-1aqnCG0qDQ-004QkQ; Tue, 26 Apr 2016 23:52:44 +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 4/6] rtc: parisc: provide rtc_class_ops directly Date: Tue, 26 Apr 2016 23:52:29 +0200 Message-Id: <1461707551-1337971-5-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:WlTkuSTQSHUlLPprVN7JK58BrCvA9LgbFxoy1J1z98L5fcfGLMP Yc6W3bZEVgimLFx6cMd6DP15XAWi/4hrXIpJj1SaarsjyabJLpcnSlrp7z90/5qRTq/WvXw l93EMw2CFZfulRg4euKUoLVLZvR5kuZ6kw7Yu0BLOsNYNxmVrZQ5e5rZ81oE3y2J8rOPtqa Oyd8MVnWHvKJwnzQZzKjw== X-UI-Out-Filterresults: notjunk:1; V01:K0:NrSy3YNUJKw=:es1xgngTj9Xi6+luLSdDts JLIZZSDrCxWiZYswsYbPw/4XHPazWlVQNHYkMF6WPl9kA5k27AOLAlcrszoHeuSxGleijgBCN iYlvpPQWATDU/SplFRnOsSaAhXSVV0rEV37ua1qK5uAR1pvVP0scuTXi+K+zEj3ngBAhakP2E QnVqPXJCMWT3H+Yziof76R/2dSCKIY97MjL2YMnA39i+lA8rFDo0Dq1X1yJntseeQSEYO8RUo WKfTvBl+OiT73UaC6RuyVbm/j37ZvenS7B7yjQ/4ppa1/lpgurB8oxF9Yc4vuLPy+5Ka8FHzs dx31w+hffzuhOnmUCn+r8tCVL8JFkMwrRSgOfO7kIXciitLPpUz+OUCEtxXM71eR8KRHlohOR xX/+GrmLguEZE8IC47Ew+ov5Lx6FLMSnCXROKGrzLMKsZHAfF5Xw1vO9WUkuM8p/Or1EpSumO LVtutEjhK45r5lhSqnHBLyHp7WAoJRJDMyodaBDM1o2ezyUoPrm/cmaCOU7OajzkwMkUlpD6S 2Xoh2elrc75ZsPNL7pAFb3P2pXUiGVe+skOJz7Kq3t8hLLldQCsvODUX5lsDnSjOjXXLRfFnS 6zTkVXuIBRc3Ae6VW9TJgxU+HvkqpKe1tL8K+/ThYL5AzHA8sgq2MRWNicG6s41s3JxgSTsv+ hQ6/tQmKhCyhoHzbfo2TF8RZhmL37z6gmJO85klclcQ9b3CZzmg6ZZ/5NChqd0GvCuRU= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rtc-generic driver provides an architecture specific wrapper on top of the generic rtc_class_ops abstraction, and on pa-risc, that is implemented using an open-coded version of rtc_time_to_tm/rtc_tm_to_time. This changes the parisc rtc-generic device to provide its rtc_class_ops directly, using the normal helper functions, which makes this y2038 safe (on 32-bit) and simplifies the implementation. Signed-off-by: Arnd Bergmann --- arch/parisc/kernel/time.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) -- 2.7.0 diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c index 58dd6801f5be..1338d92fc87b 100644 --- a/arch/parisc/kernel/time.c +++ b/arch/parisc/kernel/time.c @@ -12,6 +12,7 @@ */ #include #include +#include #include #include #include @@ -248,14 +249,47 @@ void __init start_cpu_itimer(void) per_cpu(cpu_data, cpu).it_value = next_tick; } +#ifdef CONFIG_RTC_DRV_GENERIC +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) +{ + struct pdc_tod tod_data; + + memset(tm, 0, sizeof(*tm)); + if (pdc_tod_read(&tod_data) < 0) + return -EOPNOTSUPP; + + /* we treat tod_sec as unsigned, so this can work until year 2106 */ + rtc_time64_to_tm(tod_data.tod_sec, &tm); + return rtc_valid_tm(tm); +} + +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) +{ + time64_t secs = rtc_tm_to_time64(tm); + + if (pdc_tod_set(secs, 0) < 0) + return -EOPNOTSUPP; + + return 0; +} + +static const struct rtc_class_ops rtc_generic_ops = { + .read_time = rtc_generic_get_time, + .set_time = rtc_generic_set_time, +}; + static int __init rtc_init(void) { struct platform_device *pdev; - pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &rtc_generic_ops, + sizeof(rtc_generic_ops)); + return PTR_ERR_OR_ZERO(pdev); } device_initcall(rtc_init); +#endif void read_persistent_clock(struct timespec *ts) { From patchwork Tue Apr 26 21:52:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102437 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1851511qge; Tue, 26 Apr 2016 14:54:49 -0700 (PDT) X-Received: by 10.98.76.22 with SMTP id z22mr6938562pfa.78.1461707689322; Tue, 26 Apr 2016 14:54:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ny6si1048258pab.59.2016.04.26.14.54.49; Tue, 26 Apr 2016 14:54:49 -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 S1753487AbcDZVym (ORCPT + 29 others); Tue, 26 Apr 2016 17:54:42 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:52507 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753201AbcDZVxU (ORCPT ); Tue, 26 Apr 2016 17:53:20 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0Lu38g-1bsspO2x8Q-011UvY; Tue, 26 Apr 2016 23:52:45 +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 5/6] rtc: sh: provide rtc_class_ops directly Date: Tue, 26 Apr 2016 23:52:30 +0200 Message-Id: <1461707551-1337971-6-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:BGBndQUJDT4ES7CGY3X0lncK6SMTZ2yBdeOJdGvNqP8OkP22msP CtKnZ+eqec4Ac7wreZdyXxbf39JN1qgarqQ04P0DZwUJvNbKMV/m8MjxIY4Y27oBuZ8urQQ hUnMSyDfcjvMKsqrFeWJQlVO+lMh8Mub0lbrq2W4KeSJBmPbsXTbyCxQit1lcYJP5map3UA QujDbjZytXtBihyf+g8HA== X-UI-Out-Filterresults: notjunk:1; V01:K0:e7Fwf34aBf0=:vFnvpEKzXBDpHqhl8dbLNA ZuvsfCCeU8GLNFR+3WUpByYGlN8cgc7ExaT5p28VNEzQ+I7fHTT3QQ77VymCD5U2TaRJzhk1q G+XT2rXNqP+IQfvHXQRYtcPlQ2bYo2KiwSm6YRajLrAFHD/CIg/tYs3F6TxqxPZOe+uuIHuSF qh+GqQP1W9LbdrSxtIqIfW5fNpCceQ/xsU6zw3fNzEot/Xo36X+4vcmE6c1RvkD2OGS0zbnBY 31hVCES1izeRBqOJgbFNCMeFYqdJBxGIczg22hCoEWlWrK6ZIbXyqJXFazsmPopP0D/RHFTG3 8ceX8VVxzuIIUmCY1V2sjs76liJWe3IE9mfMe1h3JegraFL+VAXkhSuWUMOR9cFjV8Y7fGgSv fI/SkcGEQNVVIXc54DByyJ8VWsefRg33JX/s081futM14T/41KBR/ickX+CjYbyRyKNfShrWR bVJQ5N3b8pglVxPoufgQ/66RHzbVXPCLR3WOJs3rDxQATa+mKDMrASn3+FRFYTmLNdFtF9jA/ wPC0nvAAq6lurIXPBK8DTwwAuPzHZWoFlHtb0k4W7EK5ZFSJ6WZnLXe6IHUzZAcWWRMqbWZVy ounDgon1nZsw67XxeeqCwGWFXfhTzqw/doEipO6/1+pFEikAGj9DLiavWlwstp7afqUzXyKqD qkltLw36q0xJ5YGEK5RT4RqX2IgmIwtsFYapRGCs7pT8trb4HJSqkZBwoxteqOZlzuGs= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rtc-generic driver provides an architecture specific wrapper on top of the generic rtc_class_ops abstraction, and on sh, that goes through another indirection using the rtc_sh_get_time/rtc_sh_set_time functions. This changes the sh rtc-generic device to provide its rtc_class_ops directly, skipping one of the abstraction levels. Signed-off-by: Arnd Bergmann --- arch/sh/kernel/time.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) -- 2.7.0 diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index d6d0a986c6e9..92cd676970d9 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c @@ -50,27 +50,30 @@ int update_persistent_clock(struct timespec now) } #endif -unsigned int get_rtc_time(struct rtc_time *tm) +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) { - if (rtc_sh_get_time != null_rtc_get_time) { - struct timespec tv; + struct timespec tv; - rtc_sh_get_time(&tv); - rtc_time_to_tm(tv.tv_sec, tm); - } - - return RTC_24H; + rtc_sh_get_time(&tv); + rtc_time_to_tm(tv.tv_sec, tm); + return 0; } -EXPORT_SYMBOL(get_rtc_time); -int set_rtc_time(struct rtc_time *tm) +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) { unsigned long secs; rtc_tm_to_time(tm, &secs); - return rtc_sh_set_time(secs); + if (!rtc_sh_set_time || rtc_sh_set_time(secs) < 0) + return -EOPNOTSUPP; + + return 0; } -EXPORT_SYMBOL(set_rtc_time); + +static const struct rtc_class_ops rtc_generic_ops = { + .read_time = rtc_generic_get_time, + .set_time = rtc_generic_set_time, +}; static int __init rtc_generic_init(void) { @@ -79,7 +82,10 @@ static int __init rtc_generic_init(void) if (rtc_sh_get_time == null_rtc_get_time) return -ENODEV; - pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &rtc_generic_ops, + sizeof(rtc_generic_ops)); + return PTR_ERR_OR_ZERO(pdev); } From patchwork Tue Apr 26 21:52:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102439 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1851171qge; Tue, 26 Apr 2016 14:53:55 -0700 (PDT) X-Received: by 10.98.13.77 with SMTP id v74mr6960183pfi.162.1461707635478; Tue, 26 Apr 2016 14:53:55 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u62si5629509pfi.150.2016.04.26.14.53.55; Tue, 26 Apr 2016 14:53:55 -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 S1753463AbcDZVxi (ORCPT + 29 others); Tue, 26 Apr 2016 17:53:38 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:55356 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753304AbcDZVxf (ORCPT ); Tue, 26 Apr 2016 17:53:35 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0MZfLS-1b8rlz0vh0-00LWKe; Tue, 26 Apr 2016 23:52:45 +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 6/6] rtc: generic: remove get_rtc_time/set_rtc_time wrappers Date: Tue, 26 Apr 2016 23:52:31 +0200 Message-Id: <1461707551-1337971-7-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:xSq1apOFai+E8rPcQ2vsGmssfzkD3EPj5d7fz21wqQDmd5QQxfm /lNc3Kia39EiZ2SQjTyhUhp7OsHzTw0urlHoLC9qP5IkS6pfCUKzHMttxkymCbgEcmam2LV S7VRZ0nZU5a8RX2zTfKfI8GtGUyu4gEhx10pvxyIAg9gaOag8MwK5oS7TSz63cPIpALuVW/ gfUkEjpA5Llk1Z5h/lWRg== X-UI-Out-Filterresults: notjunk:1; V01:K0:6KiIxAL+yE0=:GB4FWe+tOWAbvD3yXws+Uk SRiTEOPMxqwS9bAf1HMX7ZAH9S8/kA1zAlKQEIjzxnJM7KXFiRU+qvVkKawJx/f3kTBIVyqLf StYweWCin/xRHi2AYCUibMPEHVRS9rOC1fA6hmNxXaKfRnXMfVynvlab36zpvLdSGD1O3k0LD r08n8iUNIpAL9t2luK6nLIIOKtgxnGR3LGfb58j5FwWCZqMqzfba2rYQtuYZ1cMHEBjvpGrGQ vmo27TIYQBArENnvCoxZCmoIsLmog3hpPHDcHX8r7JN60f9xn04IF2kjbJEkhvdPBGDTdXq1I HHD0lqWeJFav1HvfnTBb35Ht1v+SP3yvNi+h5dXjcfdKlWC89P91I/sO/uSiYKCSJv3tzzR8W bWBnxIn4573s2ZJT7sQqYagRRKLg4fIF/OEV7OnUJWCnYtfF3FuqkGT9EsM7x11UbryR7bP4Y BtNDhmmieJVt44JnxUGzwJAZZpbhRu/ul73jC0RGqYQZN43LRZ1SRfyvkpd5AFzTmaY4vrZfY VQzZK71PKzSa3VhAtyrgpMaHkhjdiAnzfMI3rPIhCtsRc5u4m2KXIZnWxsvIwEU9P6ZUcaKUA 4Zp7PRPC7mQYR7TM1tsZ3axjAg2wz7aRUX1sKAM6QkOFYWWRzDZRVOJV/0vnQTFAiujl6fUpr 2OSvFpoBGSWBwmk0N0O2ZlStD5iFVBXsufwoTKJyXodZTMQT3e1lAXAy3FU+mfyAm3DU= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All architectures using this driver are now converted to provide their own operations, so this one can be turned into a trivial stub driver relying on its platform data. Signed-off-by: Arnd Bergmann --- drivers/rtc/rtc-generic.c | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) -- 2.7.0 diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index d726c6aa96a8..1bf5d2347928 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,44 +9,10 @@ #include #include -#if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \ - defined(CONFIG_PPC) || defined(CONFIG_SUPERH32) -#include - -static int generic_get_time(struct device *dev, struct rtc_time *tm) -{ - unsigned int ret = get_rtc_time(tm); - - if (ret & RTC_BATT_BAD) - return -EOPNOTSUPP; - - return rtc_valid_tm(tm); -} - -static int generic_set_time(struct device *dev, struct rtc_time *tm) -{ - if (set_rtc_time(tm) < 0) - return -EOPNOTSUPP; - - return 0; -} - -static const struct rtc_class_ops generic_rtc_ops = { - .read_time = generic_get_time, - .set_time = generic_set_time, -}; -#else -#define generic_rtc_ops *(struct rtc_class_ops*)NULL -#endif - static int __init generic_rtc_probe(struct platform_device *dev) { struct rtc_device *rtc; - const struct rtc_class_ops *ops; - - ops = dev_get_platdata(&dev->dev); - if (!ops) - ops = &generic_rtc_ops; + const struct rtc_class_ops *ops = dev_get_platdata(&dev->dev); rtc = devm_rtc_device_register(&dev->dev, "rtc-generic", ops, THIS_MODULE);