From patchwork Tue Apr 26 21:52:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8946351 Return-Path: X-Original-To: patchwork-linux-parisc@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 828D89F1D3 for ; Tue, 26 Apr 2016 21:54:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 958C020166 for ; Tue, 26 Apr 2016 21:54:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2B312011E for ; Tue, 26 Apr 2016 21:54:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752344AbcDZVyX (ORCPT ); Tue, 26 Apr 2016 17:54:23 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:60488 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753267AbcDZVxW (ORCPT ); Tue, 26 Apr 2016 17:53:22 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0MHrNV-1arc0M2tDR-003Zfv; Tue, 26 Apr 2016 23:52:43 +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 3/6] rtc: powerpc: provide rtc_class_ops directly Date: Tue, 26 Apr 2016 23:52:28 +0200 Message-Id: <1461707551-1337971-4-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:wB9ArzOGllSfulVAKWkmyatGDRl47pDaaj1TChyrTT2PUtm/B5L 1SChGDj9DYuHylhLqcdHGvKL2b76VaE+ISm9PxiSGWtAZUefe/ROLRpih8YV9gGDYo+PqU0 0jmtOBNi4f7xfyQuBFEU47QkxuH4XOjkd7xtGy0gKsn07zxH89qVfe3iulmqsnCtQegNmX7 zYUmT6eWiv/iez9aQnDJw== X-UI-Out-Filterresults: notjunk:1; V01:K0:e1L+zIgEn98=:28KExmvohc9Ieoz54LvN91 tt8q5ozlhfmwmagItWyfwFYR8aWknIewVvRZhQe4Nua9tW5BCdKwvfJnMFAF9JabuobAIaK/U 09BYk8P23aiwyVbrz8GDnqdt79b5mFNn66nF8pemXtv2gQ+EdvVSqzTJRAHotLKuGmNklSirz ufawckvp99DS8nlVqrBjVFHNYPdybUCF3IiNGXzZ+UZpj16iFbHdB4aDoDoW1x2vsk4gzNbgu ldvfXmZkZWR1Yn9JTjN+bAnZPLWslWY23k3xr0v1dF05KNN4fCqd1goFtwRmWl1DfoxDlvGFB KaavSE5hyrt+XZLg6xgDAz7zLJyx5PtoaQPOM9FEplHkTNVBAQiwlYVxCBADajQiiu04hm6iz PEmSjpsUHi667hTLS7J5a5pVaA9dM2OjiMv8xpsLsX01M18VFVWEIMNZ5lDdC+C8xZj52L6WU g4z7L63M9vzndlV2PRgzZmcm5Z8BF9AKKZjv/neTibRoZjbC1FeYivOL6cEBMzyKRL9kxs344 7aJH8IJ8cBOsSOkiX9gJxFNCzEmrQobNhg6n3PVflKkzbim89DFOTyr8fM51ZPOzN3R8XKnGj Rq3BJCKQPsAfSb0QPM5987BBoRg0UDhIUV6KqsvGwfbNCfn9rjvumQViEGrRjYdbEei7IbHmQ PXS8vaWKNzlP4/YkHSI5pB+easJNaJXE5qehtZgqLe7WdAjcemX1QSBKTXYvHAvL7M/E= Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@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=ham 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 powerpc has another abstraction on top, which is a bit silly. This changes the powerpc rtc-generic device to provide its rtc_class_ops directly, to reduce the number of layers by one. Signed-off-by: Arnd Bergmann --- arch/powerpc/kernel/time.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 3ed9a5a21d77..aeac4d9591f9 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -1081,6 +1082,29 @@ void calibrate_delay(void) loops_per_jiffy = tb_ticks_per_jiffy; } +#ifdef CONFIG_RTC_DRV_GENERIC +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) +{ + ppc_md.get_rtc_time(tm); + return rtc_valid_tm(tm); +} + +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) +{ + if (!ppc_md.set_rtc_time) + return -EOPNOTSUPP; + + if (ppc_md.set_rtc_time(tm) < 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; @@ -1088,9 +1112,12 @@ static int __init rtc_init(void) if (!ppc_md.get_rtc_time) return -ENODEV; - 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