From patchwork Wed Apr 27 22:34:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 615887 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 3qwFFZ6wR4z9sCY for ; Thu, 28 Apr 2016 08:37:06 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3qwFFZ63H6zDqCJ for ; Thu, 28 Apr 2016 08:37:06 +1000 (AEST) 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.75]) (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 3qwFCt1hmMzDqB3 for ; Thu, 28 Apr 2016 08:35:37 +1000 (AEST) Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0M5xcn-1bsqnb3ynZ-00xtDt; Thu, 28 Apr 2016 00:34:51 +0200 From: Arnd Bergmann To: Alexandre Belloni Subject: [PATCH v3 07/16] rtc: parisc: provide rtc_class_ops directly Date: Thu, 28 Apr 2016 00:34:21 +0200 Message-Id: <1461796470-1291527-8-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1461796470-1291527-1-git-send-email-arnd@arndb.de> References: <1461796470-1291527-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:62x2aIdnKqPcbygSy2sENMpJcKWeNB/mTUpBKKJ/eLubsRKZxZT vgqeOFbyF4Ow5fAHeDVhHoNROE+VX/3I4SOo7G7BRLud94NFThUvY67uDxb0KUw6D12Ut94 JVLlhePLyZCK4Mx8LVPFkQzrP0/XaTEewLMXRILfglf7djYnMY/tRWZWxpBtDEzkpuX0cDT BmPlvG3HDiv8dHINrhYjw== X-UI-Out-Filterresults: notjunk:1; V01:K0:TwoCPQQjntU=:3KW+cYvH1Kjlv23f/GpgTZ VrwjEOpbV5drQoa1MkdlY2tNqNDXinDw2Wjj+T6VGqyE3umtt9am/W/rcugvgm7QKryMRLC11 57CMrtVF2mUNLrYuTvGaPm0BdVE0UKZ7UOtBEHt68bKOfIFXwl9NlupI6UovXGE0gh1tqpNbh 8iDYQPHQfEyZB8z6ozGgrRkK6fOVLrylUKLUe0F757r5kfUKQO1g43hoiIFNuPwp4vM3t9qBh pIXZ+3Dk4ewzP6JGgY2gxCx2d1daHXjoJoSpgbQpKqKmsVXKqDYbmc6QwRun4A6k/Bb8JyrOf wQryd5YD3feaeOjmbV1YfUYxkHM5FTLKR3NVg10fXSgON92K/8XkD5vDrlaYUiIq3i79KCAo2 smTXna8COSOANqJRCAY9mVccUFam8rVguxCbfY1SQbqILLDywmi4mbCnvi/GCe5ixrTO9gNn4 pWRRnp7T88A9qY8Z1vVd0PIdYLJjDFCoMzVb6d/dorfh9XTQf/7l3HeKAp5Pepb2DY5tEfw/M PsRDYsJAWNXuoFxPpABaE3h9TwsltYwCiQqVmiPh42Xv8Y+Rq93HOyZLW/2QtigkUmONNHg+3 uzjWFb9sBIrVE7hWtuKiH5M4wVAdkg+3GNujHM38dGV3lObUHay090fml6a+DNv7tRtPErt9T QGTqA0+AFdDKyElbrPwggev1AKNaWzxWjSA03MgHZxbCSQQm8O5stfna7HgwGARaXF/w= 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: linux-arch@vger.kernel.org, a.zummo@towertech.it, dalias@libc.org, linux-parisc@vger.kernel.org, Arnd Bergmann , linux-sh@vger.kernel.org, deller@gmx.de, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, linux-m68k@lists.linux-m68k.org, geert@linux-m68k.org, rtc-linux@googlegroups.com, linuxppc-dev@lists.ozlabs.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 | 36 +++++++++++++++++++++++++++++++++++- drivers/rtc/rtc-generic.c | 3 +-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c index 58dd6801f5be..744878789752 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; } +#if IS_ENABLED(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) { diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index 3958e87a05fa..92b5e02a3750 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,8 +9,7 @@ #include #include -#if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \ - defined(CONFIG_PPC) +#if defined(CONFIG_M68K) || defined(CONFIG_PPC) #include static int generic_get_time(struct device *dev, struct rtc_time *tm)