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: 590660 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6EDDA1401E7 for ; Wed, 2 Mar 2016 04:07:43 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 543861A175B for ; Wed, 2 Mar 2016 04:07:43 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.73]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 6E90F1A0BE0 for ; Wed, 2 Mar 2016 04:02:43 +1100 (AEDT) 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 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= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alessandro Zummo , linux-parisc@vger.kernel.org, rtc-linux@googlegroups.com, linux-sh@vger.kernel.org, Helge Deller , "James E.J. Bottomley" , linux-kernel@vger.kernel.org, Kyle McMartin , linux-m68k@lists.linux-m68k.org, Arnd Bergmann , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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(-) 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);