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);