From patchwork Mon May 30 18:58: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: 9142039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3E08860757 for ; Mon, 30 May 2016 19:01:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32C1428066 for ; Mon, 30 May 2016 19:01:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2790F2819E; Mon, 30 May 2016 19:01:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C24A828066 for ; Mon, 30 May 2016 19:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161893AbcE3TBz (ORCPT ); Mon, 30 May 2016 15:01:55 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:60709 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161877AbcE3S60 (ORCPT ); Mon, 30 May 2016 14:58:26 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0LdEZd-1bpcpH3e8f-00iSt5; Mon, 30 May 2016 20:58:03 +0200 From: Arnd Bergmann To: Alexandre Belloni Cc: Arnd Bergmann , geert@linux-m68k.org, gregkh@linuxfoundation.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 v4 12/16] rtc: powerpc: provide rtc_class_ops directly Date: Mon, 30 May 2016 20:58:00 +0200 Message-Id: <1464634684-1248135-13-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1464634684-1248135-1-git-send-email-arnd@arndb.de> References: <1464634684-1248135-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:y9giqI9oWgAwg+FAFlGiUy9EsT2tk43+dnKBHuox8q3+0+aju8+ LQmSB6slNbf3i4Gx44ZOvtliVa5VBKQkaGgB37Klk/tRYsG+VK9gjwhmmDE5aJBacdCmrBU MEmg6Aoq7wVAAAgof+1WGVXGME53eSZeK8BQvhlUvslycdzhNwCk5vLKMpv+pHNAHUsjWbo FTEpC/kKvKqWLSMZZGetA== X-UI-Out-Filterresults: notjunk:1; V01:K0:yWWyvcKKDXU=:2oq+kNvSH8AMg3X7l5fe+w 2P16czcsLPuPjO+x5RJj42l732E87HE1GFWpF6SHXlVph83XXr3A3YZbdk+jzqFxgs0RBDKgn by/kuwL9ZvEHeqULjZ6gmNCNrFTLMPiKvtoRW3xtIx5Qh+tJ58BfxKVPs7zVM2/tM1jtEDA4k p0FAp7mMU26MJFBOUE6VqIOv4lJC1w0xgzFPRaoAwzHRm7eVMeaw65hKsUcr97kghJUVqbN6I ZQWn/IV5TywkXEyZpejZ4pkUjc9+7wFHgIleNSev8muEmWsNLpsBBKESClcLffW7a9eD/0o5e 4K6OJAXuilpoRnBLTpgy7lwazHll6eptD5gUG8S9lczOrZYRE7Dxw15vc6xNNiRaFmeKJ82by jzFHjSMQsojQjckEEcoJzXbJVo/XiPe6batV2MuqU8kT0qbQmwJq/Dz7Q9lvdfqzqfuXHU31J SHO/YxGxDUGFLcHCXrh5+1ArzHKzGBTmIMmy3VKOTG0wHBC2bKdvOzSVo3tcNuOa/3YLItYAE e+38eXc8hdx54J6cK9NtFHIHSh/rpXN2bv6CAZS4hXrvq5+7CiFpcC/MoQGn9+DSx7kJfXb52 tpqFkdq9eOk9l3Pcb0sZqvS5Hoon2RIZ3FJBejMcz7JPZALlN82jjROS97pfW9eLP2rb9gQq7 MItKy0v/N6fpwViuZtSpMJNojcGRDYPxLNpMeWN4VrEpdOl09kao5HG7JCU4fPHmOE0o= Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.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 ++++++++++++++++++++++++++++- drivers/rtc/rtc-generic.c | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 3ed9a5a21d77..7a482a7f4d8d 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; } +#if IS_ENABLED(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 diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index 5c82bae73b9c..efcb9833cac8 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,7 +9,7 @@ #include #include -#if defined(CONFIG_PPC) +#if 0 #include static int generic_get_time(struct device *dev, struct rtc_time *tm)