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: 8946291 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 74AE79F1D3 for ; Tue, 26 Apr 2016 21:54:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96E182011E for ; Tue, 26 Apr 2016 21:54:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5D4120166 for ; Tue, 26 Apr 2016 21:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753389AbcDZVxb (ORCPT ); Tue, 26 Apr 2016 17:53:31 -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-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.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 | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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) {