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: 8467401 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 22C36C0553 for ; Tue, 1 Mar 2016 17:03:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3277020125 for ; Tue, 1 Mar 2016 17:03:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E563202FF for ; Tue, 1 Mar 2016 17:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752791AbcCARCp (ORCPT ); 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-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);