From patchwork Tue Mar 1 16:59:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102642 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1940691lbc; Tue, 1 Mar 2016 09:01:19 -0800 (PST) X-Received: by 10.66.124.226 with SMTP id ml2mr31554309pab.90.1456851679075; Tue, 01 Mar 2016 09:01:19 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ah10si12486428pad.118.2016.03.01.09.01.18; Tue, 01 Mar 2016 09:01:19 -0800 (PST) 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 S1752350AbcCARBQ (ORCPT + 30 others); Tue, 1 Mar 2016 12:01:16 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:53682 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbcCARBN (ORCPT ); Tue, 1 Mar 2016 12:01:13 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0Lj2nG-1a36jS25y2-00dDNH; Tue, 01 Mar 2016 18:00:28 +0100 From: Arnd Bergmann To: Alexandre Belloni Cc: linux-arm-kernel@lists.infradead.org, Kyle McMartin , rtc-linux@googlegroups.com, Alessandro Zummo , linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-parisc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] rtc: generic: allow building on all architectures Date: Tue, 1 Mar 2016 17:59:57 +0100 Message-Id: <1456851608-3374907-2-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456851608-3374907-1-git-send-email-arnd@arndb.de> References: <1456851608-3374907-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:B5ShExoSe/LlQlS4gFHKon++T3ysRIeZ5LX7fOS2CMdtJMJu+Gm rFi442YkW+4dzmYYTxx4rK10HjwKEeDMRQOtSYt31Jxe08Oe2iZ/RYEcD8Ok6xUhuMUQ3if nKrz7UXZ4C8gaD2I6lOBwkoERCYNPTkoLlOstoLmvS/Vd5U4C1Ib90n3KJjb0SWfEY5T25J WmRer+SpF06tQh4aS9I+g== X-UI-Out-Filterresults: notjunk:1; V01:K0:dAaVFL2LliI=:YiWRw9Jn45IpXzTqC+hu2I op4laaKXZ0XrwNeLhvjZUTSy08eJ9aDiPYYzJSmmyrGODS5OoVag8qCrZIAmU06IBq0pNUmz+ KF+XSH0EQk2siirNYtqRR/q0wxrW/biUdXIwzZVb+TZ+qpPq5JmkGofb7SElQYb2vDR5dw7Ka x4tnGmkYJbeRs3ZtXdZpbijoK50PCF7qwLgXsC2jaSqZTGCM2AppEak6WxXBd6TEuWSoiAEqG TKWeKbYuott2CkEbUPDN4Pjhkj2lYarL/oQakwcHHwdxY1TE5Xtxrm45X4GkqcD/ItLAXI4xP 9ZaFHHYzKWPokf2p8bOfwI78YuKDg/VM5FyQOOs6lbmctFC25xgRqfJFA0O8cxxaBpXIaDfxc z/Hi4tidA56pdqayu7PNLYmQ9C9rnO8Hhw3ivDi4g89yIjdxmW0mc+WxUpc3EiJvrHxmWZ7M+ jwc9dAvTS5tYwqX1jPL2AdmlDB3TZIrPfVai33LJZairG4rN1Di/vcETv3g74HiN/PfceTdTd pzCiwJdS48kmy61YTcM/RW6kHWFYm4YTlHi1/3BvlGhddd664onfYZxKqq+7zr5FBRsFlvOyv 6hO4OQFf2qQf5unkC45VFYpRrF7AhG60bvb1un4fEQNi3K5cLcL7w4j7ynS24ZW5v8xNvFDSh yu5X6lkwG+/YBEwKuKsufJfm4P9GxdG6VV+oggRa1/fNOXgGMz2cETRpTMwYgcmBu7+Y= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are four architectures using this driver, but since we can build it with COMPILE_TEST, we should try dealing with the absence of the asm/rtc.h header file, to avoid getting a build error: drivers/rtc/rtc-generic.c:12:21: fatal error: asm/rtc.h: No such file or directory This creates an alternative use of the driver, allowing architectures to pass a set of rtc_class_ops in platform data. We can convert the four architectures to use this and then remove the original code. Signed-off-by: Arnd Bergmann --- drivers/rtc/rtc-generic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.7.0 diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index e782ebd719b2..d726c6aa96a8 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,6 +9,8 @@ #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) @@ -33,13 +35,21 @@ 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; rtc = devm_rtc_device_register(&dev->dev, "rtc-generic", - &generic_rtc_ops, THIS_MODULE); + ops, THIS_MODULE); if (IS_ERR(rtc)) return PTR_ERR(rtc); From patchwork Tue Mar 1 16:59: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: 102641 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1940862lbc; Tue, 1 Mar 2016 09:01:32 -0800 (PST) X-Received: by 10.66.147.103 with SMTP id tj7mr31916117pab.72.1456851692153; Tue, 01 Mar 2016 09:01:32 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ra2si11862806pab.209.2016.03.01.09.01.31; Tue, 01 Mar 2016 09:01:32 -0800 (PST) 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 S1752596AbcCARBW (ORCPT + 30 others); Tue, 1 Mar 2016 12:01:22 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:59802 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752364AbcCARBT (ORCPT ); Tue, 1 Mar 2016 12:01:19 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MD8ge-1agLYe41oy-00GY0b; Tue, 01 Mar 2016 18:00:37 +0100 From: Arnd Bergmann To: Alexandre Belloni , Geert Uytterhoeven Cc: linux-arm-kernel@lists.infradead.org, Kyle McMartin , rtc-linux@googlegroups.com, Alessandro Zummo , linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-parisc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 2/6] m68k: rtc: provide rtc_class_ops directly Date: Tue, 1 Mar 2016 17:59:58 +0100 Message-Id: <1456851608-3374907-3-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456851608-3374907-1-git-send-email-arnd@arndb.de> References: <1456851608-3374907-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:72JdRVEGitKHvXWvzoUbUvWzkk0q4J7xZt9OzT7M86DI8fe6GRL nX3K5A7ygjO5go06JAgV9gVIC6ntoDVVHd28Leuix83+zyUSmztoDjaDoCLbdY24AqwpE4S SirTpTE/uCX8D8g7B+l44BtGcAeY6AYbuWhUZBJIZQ4DIw1nLsk8a+MH0YMbYWJSxjTMCzT DKpkaNqQx0xC7rghSULXA== X-UI-Out-Filterresults: notjunk:1; V01:K0:ggtaDl2HJPI=:ppgIny8OngYdgGpOFhV6SZ jNzcTHdaALXsRBlIhTsgVkavdsF+FYMJpccVKX5SwG95XdoAHuMK7XnwOd4/Dlk8cOrzjU+Eb rL2Zol3jeYANV7QMXaXUifuhCxyPaQWJj4n3hqhNpz7eHTxAMI48DC7ixhzaLx4MusrBwL7QW oR5LHFIbfwnXAFpNz/2nNJL2npm8NzRv3Xsv2a+6/4eC6tn5MRcXRynllmK4zMQK6xS+dkQ1l ARMsBdSH77lZB3ECv76wYELNgoFnyH3w5d7tincCn9oEVRT5WctLXhvLeYcp+WzKdOFSRnudm XH/0OEjWtd991PXeO95hB8ImMNDAv50jedW2bAN003U6OmZOuzZcyXEqWvs6+BR//GsZRBxol Eayn/XXHI+UxUexPj1UK0UDFUi0ZMg2Iq+pMIwNDGwHxUbbyvwtXBkHtvoI1oOs/OxOOqynjw LDQKQb5liGbqIeYWu/pZtXBQl4+yMd614Gb337bFUg1F+7GaVkrxpraFDDXw/AjN4L7RduZOh iXeM9gHcejbn78Ia+XBbUPMc6HnXcxbPoMS/rt6qjG3WPILePbBBBl3AqJYeds8EL/IDN3R0y lHMvG2roFV8pZCzrLtCN/Jb9WHhQf6QH4PGKRlj0GAO/y2QBa8Bse6MumHy8VnmyKe82zo3Gi v3ux/As4AQJJ9ha9Ryi+7kJC3tykYaEHZyRaVmU51LEy6MNW9PwzNBp6gHnlhFV1Yn4w= 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 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) -- 2.7.0 diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c index 3857737e3958..773b2187210d 100644 --- a/arch/m68k/kernel/time.c +++ b/arch/m68k/kernel/time.c @@ -87,6 +87,23 @@ void read_persistent_clock(struct timespec *ts) } #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET +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 Mar 1 16:59:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102639 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1941610lbc; Tue, 1 Mar 2016 09:02:48 -0800 (PST) X-Received: by 10.98.15.67 with SMTP id x64mr778003pfi.60.1456851768204; Tue, 01 Mar 2016 09:02:48 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ke7si51489594pab.183.2016.03.01.09.02.47; Tue, 01 Mar 2016 09:02:48 -0800 (PST) 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 S1752765AbcCARCd (ORCPT + 30 others); Tue, 1 Mar 2016 12:02:33 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:55337 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699AbcCARCa (ORCPT ); Tue, 1 Mar 2016 12:02:30 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MUEV8-1aSVv304cU-00R4HT; Tue, 01 Mar 2016 18:01:35 +0100 From: Arnd Bergmann To: Alexandre Belloni , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-arm-kernel@lists.infradead.org, Kyle McMartin , rtc-linux@googlegroups.com, Alessandro Zummo , linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-parisc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 3/6] powerpc: rtc: provide rtc_class_ops directly Date: Tue, 1 Mar 2016 17:59:59 +0100 Message-Id: <1456851608-3374907-4-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456851608-3374907-1-git-send-email-arnd@arndb.de> References: <1456851608-3374907-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:la+hdd4yyrAyAuTGf3L+LeKdPaCifD6D8XqLDyUlhsKqIEwIoff C5xlTnYSE2EjfpCImWOoOxN8PkrKOm8kdfLICSkh13J9dCj1DJZ68mzJZ87Hb3x8PjoHqqV SUn7udi2BMMKOyMNRgV1uBBE7RXtyvPK5ACOFV8Tj6Yl4oNpmdi/VKdSWQ1TmCJKTuk3uuf ML4h9pAHONzpSq/oAxwoA== X-UI-Out-Filterresults: notjunk:1; V01:K0:Kd/sbDg0XAM=:to6/p9T1Fh9uQzN8pHVeN2 5ZI0qfEiZLnDhsJyAs4xptq/cq7qkD0ZG+miFY80gpXD9+JSC86rFHQW6zibLZtsmyvGJKRSw FpuBbyER8vumI7TvooIahdg2LBVO7C5KClZKQKReFMNihcYT65ZQMeIMJFndid5NVBkRF6cVn MFfVOpCmdL3PiP9xNhwk2s9XJekZo0qmvf6ZLOOszi0u0BVPuAAiafqPZBZh40A2hmGnMyyFI Z/rLriZ17+UnszbDLgonYSFmVe/5W2joU/WFxK6LHdcC00himLI0z4w5xbQATNUzaArBFo1o/ c7IIgDyOmNVyrwupxBu/NooA1xVWei1xypc66gZ4NnkWAAkObpPxagAyxhZ8dBG5Ljo4Z3Azz ag2BVAzVz5HE08CqAZNk6CqX14gqVbxBvODB0KfYRP36cRP8a1uqRppHZ1fp7GmP1uGdkrZG4 yDVcs6Fypz5fNLb7shYUL0uVDc9m4u3SKSe6GHpZvGU9RIpbazeBc5cztwAO9v8cMiYCggZ+P 0C6S43HXWvSexOaslqI1Htwjf/f2ul+jqFYc0J+Jsn9JY4VBCD98pkVkih1uasmtKB19uBptv n9KruFSa9T+ztg6mXdMnCSPdV+OiosuhT6AcKbjNFso/CKAeO0nEkDw367b8MDbJABJX9Hrv3 nAXyXKTh0IrC9P+x0UWFejDVWJO3ZBfO2NsXtPhCZMXUIYmXpQ/lpg3ZFXlzmrIz7vzs= 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 | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) -- 2.7.0 diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 81b0900a39ee..84a1228be617 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -1080,6 +1080,28 @@ void calibrate_delay(void) loops_per_jiffy = tb_ticks_per_jiffy; } +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; @@ -1087,7 +1109,9 @@ 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); } From patchwork Tue Mar 1 17:00:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102638 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1941621lbc; Tue, 1 Mar 2016 09:02:49 -0800 (PST) X-Received: by 10.66.235.9 with SMTP id ui9mr31645507pac.135.1456851768634; Tue, 01 Mar 2016 09:02:48 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ke7si51489594pab.183.2016.03.01.09.02.48; Tue, 01 Mar 2016 09:02:48 -0800 (PST) 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 S1752820AbcCARCp (ORCPT + 30 others); Tue, 1 Mar 2016 12:02:45 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:53403 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751808AbcCARCk (ORCPT ); Tue, 1 Mar 2016 12:02:40 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MhDBR-1aETZE0oZF-00MLRI; Tue, 01 Mar 2016 18:01:49 +0100 From: Arnd Bergmann To: Alexandre Belloni Cc: linux-arm-kernel@lists.infradead.org, Kyle McMartin , rtc-linux@googlegroups.com, Alessandro Zummo , linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-parisc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Arnd Bergmann , "James E.J. Bottomley" , Helge Deller , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] parisc: rtc: provide rtc_class_ops directly Date: Tue, 1 Mar 2016 18:00:00 +0100 Message-Id: <1456851608-3374907-5-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456851608-3374907-1-git-send-email-arnd@arndb.de> References: <1456851608-3374907-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:XucN0ecKQ4795Vy8Z0hAiGyXFgqMxKrBEXSzFhzwS5/snV6I2fA X54K7xRcs2BSayBggu8OoWJ62yUYXYD3dqH+JxgNYKRdtRYr8YS2NMy6XqUH4qrNSRRCRHa 8fACXlzbozcCUH3NdTwLwk0MgbiRt0ihOGZ/3wv1GaC2ebOxS0gnrd/SyuVDEO6jm7F9Phv pc0MLW5akgGjMrubqze6g== X-UI-Out-Filterresults: notjunk:1; V01:K0:00wNTH54c8Q=:bsomeAVocG+s5obBHvLUb0 RHBdlysACWX+rdn8uLfp0UrW94BIzZDWF3BB0yJPmegopXsDQlR4mpr3IlhHlPgCZfW93Ggic Ymd9gTPwz/HMAtX3PLE07gmK07nxKxrY55rXIzsQT2aCrWk+nF2O7YozKREAujJNFcD9UD6ew O6xL5LBAIrgeBnwOQBh3kRzEUzj0V5m8e3nPlhF4LAra0SDg54wS1Y0RQ5N9j6O6WbAWJOqm/ XYGt8IQNdjHDfnYo0gCbcM1JlTo7Hn//MSibsuh9xJgozTUwM8Yt6NtMxlgbJ5i9Fku4AUY+7 X5ray/U+OKF1VtpyQsuLbIuxi8Nfk5LojwhhN51WYJoAfLZxF+8PR6rKRWTrrq3E6X0f/NT1g SCDhBrgfxcK1eO6UZr4gElS41HIOe51dhxrhxnMYxiltStXnviH5qYrcvbERDb6T8TB48xcXp V2OzSbjmkatcgyxsDboC07YsLn79WBPgpymrvdksJHYuyMD+V0E7iWXsNsF2+os5QMoT7yIiu I1G8omu+Q1RnhTFb8MOaqHrubs98XdvInnvbCa/3WncaO1Biv/MrtdupTXQHDP4m/xtkD8KJW e8RGHlltjMPDZXilLwvacQykq8J2DpQEo+mT+AoYM/Q+hoHistrO0g8esKtoj5jvFoHhgLqxF hivoI9ifi9b+XvJtreDcGwsTiesXoM6xNxn227cxCWyOuX35sbpaO37yuMQSucElLln4= 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 | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) -- 2.7.0 diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c index 400acac0a304..176ef5c2aa82 100644 --- a/arch/parisc/kernel/time.c +++ b/arch/parisc/kernel/time.c @@ -12,6 +12,7 @@ */ #include #include +#include #include #include #include @@ -224,11 +225,43 @@ void __init start_cpu_itimer(void) per_cpu(cpu_data, cpu).it_value = next_tick; } +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) +{ + struct pdc_tod tod_data; + + memset(wtime, 0, sizeof(*wtime)); + 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); From patchwork Tue Mar 1 17:00:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102637 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1941874lbc; Tue, 1 Mar 2016 09:03:13 -0800 (PST) X-Received: by 10.98.65.14 with SMTP id o14mr31567938pfa.151.1456851793553; Tue, 01 Mar 2016 09:03:13 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ez9si2640742pab.20.2016.03.01.09.03.13; Tue, 01 Mar 2016 09:03:13 -0800 (PST) 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 S1752859AbcCARDK (ORCPT + 30 others); Tue, 1 Mar 2016 12:03:10 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:59644 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751992AbcCARDH (ORCPT ); Tue, 1 Mar 2016 12:03:07 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MXp03-1aMlDc1JkF-00WpZW; Tue, 01 Mar 2016 18:02:07 +0100 From: Arnd Bergmann To: Alexandre Belloni Cc: linux-arm-kernel@lists.infradead.org, Kyle McMartin , rtc-linux@googlegroups.com, Alessandro Zummo , linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-parisc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Arnd Bergmann , Yoshinori Sato , Rich Felker , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] sh: rtc: provide rtc_class_ops directly Date: Tue, 1 Mar 2016 18:00:01 +0100 Message-Id: <1456851608-3374907-6-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456851608-3374907-1-git-send-email-arnd@arndb.de> References: <1456851608-3374907-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:oEdmIlpywmQ/D/bcXlpK5yo8Xbh9n3ycZpVQ/8YUqcfZ9RSRA0G NBrHakqeLi58GD8bFiyxQvwHBnkZH/3QBKy65QI5SNXy+6xkWq3hwg7n/BJQeTGm9HCVX9d cRcCcjbRkc38Sosm1/rM7GSqrleIflSsECqUNNX/VACJouBYOQf55aHGxGvSrRGkWRHV1al qW1EVj/KUDGD2Tgi+KVEA== X-UI-Out-Filterresults: notjunk:1; V01:K0:5QFN1KL1W4s=:WXpwvFF9XXIpToMqebFR3l ovw8AFQAb4k6pta/iZ/L+9XyL7HcE7G8+8L132kKcGUMo91/m6/xFvWZiyak0j7khfDkjwfdh Nz6DbAv5OUNA8c2i4ouNEQNSv5RNhKSnP+TMS0Hnw0uZvk/IfJjTYfU53thIp2ZOnPx6uSnVC 5RE5McD2gf9kFmF/Cu4+fHsP5d9EnOTwsHOLUSAx3DQgwOC2YqU66DPXVc9aZgKvYwaApQ9yp s0Vfc8Vmo5wNmDWUzV5IQDwc4qf90AAmdMDWI523UZgblcyknAJpUJSb0rsNQ9lEtDdGdWnTZ zrbVVuSXd84uvr9wJc2GgjrCqdx5nWNx7hAR5HL4o4ZIIDtluWntCBzEZjUF9CmrSQ/KFY/4i sjbjNSmHpclvB258yARwDXMZs7s1YqC24ae714DtF7Sm+Sb49Eayt5ZS1GhzfQejDjU8gjsVc NRJecpePjJ5kM6mN4B8v0yPJjcGjrRuGRUNQ70OiVKspT2I7r8UxrqU6uV4ru7/EO1WNoPvZS 3TiVJfFKJeY4ab+2QGhtd+oc/T+NF/nNNQ/VCUpZBl9+yUYURpTE5HDxqmX3Y5YPVbaTldzGE QDQzdrLloIVagN/SZ1OXp1nixY+cBFAoEESr+YrDR4bAG/CHulbGdbxzKTsL0ifdcXgbHoms7 3TAByiKRByCGCmDdhgXjFdyI3hOkCWLiWw+cXC+ueJ5j0fVbm4Aqgrq19luXnORRNSxY= 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 Mar 1 17:00:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102636 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1942096lbc; Tue, 1 Mar 2016 09:03:36 -0800 (PST) X-Received: by 10.98.93.1 with SMTP id r1mr31367056pfb.57.1456851816557; Tue, 01 Mar 2016 09:03:36 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21si18955331pfj.62.2016.03.01.09.03.36; Tue, 01 Mar 2016 09:03:36 -0800 (PST) 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 S1752862AbcCARDe (ORCPT + 30 others); Tue, 1 Mar 2016 12:03:34 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:65078 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbcCARDI (ORCPT ); Tue, 1 Mar 2016 12:03:08 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0LmcE7-1a1jmh2tmN-00aB6I; Tue, 01 Mar 2016 18:02:12 +0100 From: Arnd Bergmann To: Alexandre Belloni Cc: linux-arm-kernel@lists.infradead.org, Kyle McMartin , rtc-linux@googlegroups.com, Alessandro Zummo , linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-parisc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] rtc: generic: remove get_rtc_time/set_rtc_time wrappers Date: Tue, 1 Mar 2016 18:00:02 +0100 Message-Id: <1456851608-3374907-7-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456851608-3374907-1-git-send-email-arnd@arndb.de> References: <1456851608-3374907-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:M0HuYRnTCbrvYLti1pa0k8aFFtSiplAm/YV3vqyUeCG0tmXFiqe 9mvFywh5ahvQH+wTqCyZ+v1QWnP4p7Fk/F940WUZUTM4CppBmnDZkPzAHzbughbWNvhvsQ5 RKjNvcj5MCMEaKZ7xVM1JwmoX6ZEU7yEI8ylGpAs9N9avhDeiOFMHtNR+ueOyl08E5rwtpK gzH3031x/Dd1AuhVJSSdQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:NFJfdB1/Brs=:i+AKZ8vwz95evOZyp4GwhC zbVhpPLydja3eNY9EAA5PxhQf/I1BUW81XyEr+kdFoAc4O+syKAz1Q9rrmEyqcp3Yr3kj2GE7 XEZd29W7/OKktY/VxGIEGYB4LBA0mO1qUW/6I+qYW78ys6blAamhYfAfVbrjQotQfMCqRAHWF 8X1XeJt8XZwYMIFkfQvblTFipSxJrVE9xQxahlzV2BT8s8sIXlV4nOH6DFr0dot5zociHyBZp s352y0gS057YP6OPf3rha3JZdwaqICLGEoDNvhH9N1dlMdIZG9QEr1fPAmBJmFQmQjjCjdu9d D0FEsHZHiS6RExr34eJXv8dccrDj12K0n0p6kgCdxqrN0OaTG292Z2ovgly3GfXYsw9zOa+wZ S2XQofeDbjuJYqzHyNxY0eDe/J2h8iQ92Tf1Glg89NWTE+bMTeqMuKod5ovGDW+Dxexev2rg3 sHuZsJ+sS5pnPHEcBxo4mZn7Dvcziw76mj/NjQqlo4OXiE4hOiV93vreAutso6I2mWG+i49Ok RKFccSSDmEiamC2vxEIqKdk6sQQiKA6i1DQyhG9wzny6K07F1FKPTkF7cvbqY2d4y2wL+uSk+ M9rggmZsB2uk0QDrAWTnvr01Dx2TyKP4hZFG4TLwo5BPhsBBxZPJHEX8hmRVBB3bwF86QCtoY qBGOkqYwRaPBCphb5riyLWZoOC9m//F1fM+ZRiD5vuX9xx9si2gwO8Jbne9t9UpMPV4c= 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);