From patchwork Tue Apr 26 21:52:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8946401 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 A7C869F54E for ; Tue, 26 Apr 2016 21:55:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B63A2011E for ; Tue, 26 Apr 2016 21:55:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58D07201EF for ; Tue, 26 Apr 2016 21:54:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753304AbcDZVyk (ORCPT ); Tue, 26 Apr 2016 17:54:40 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:52507 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753201AbcDZVxU (ORCPT ); Tue, 26 Apr 2016 17:53:20 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0Lu38g-1bsspO2x8Q-011UvY; Tue, 26 Apr 2016 23:52:45 +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 5/6] rtc: sh: provide rtc_class_ops directly Date: Tue, 26 Apr 2016 23:52:30 +0200 Message-Id: <1461707551-1337971-6-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:BGBndQUJDT4ES7CGY3X0lncK6SMTZ2yBdeOJdGvNqP8OkP22msP CtKnZ+eqec4Ac7wreZdyXxbf39JN1qgarqQ04P0DZwUJvNbKMV/m8MjxIY4Y27oBuZ8urQQ hUnMSyDfcjvMKsqrFeWJQlVO+lMh8Mub0lbrq2W4KeSJBmPbsXTbyCxQit1lcYJP5map3UA QujDbjZytXtBihyf+g8HA== X-UI-Out-Filterresults: notjunk:1; V01:K0:e7Fwf34aBf0=:vFnvpEKzXBDpHqhl8dbLNA ZuvsfCCeU8GLNFR+3WUpByYGlN8cgc7ExaT5p28VNEzQ+I7fHTT3QQ77VymCD5U2TaRJzhk1q G+XT2rXNqP+IQfvHXQRYtcPlQ2bYo2KiwSm6YRajLrAFHD/CIg/tYs3F6TxqxPZOe+uuIHuSF qh+GqQP1W9LbdrSxtIqIfW5fNpCceQ/xsU6zw3fNzEot/Xo36X+4vcmE6c1RvkD2OGS0zbnBY 31hVCES1izeRBqOJgbFNCMeFYqdJBxGIczg22hCoEWlWrK6ZIbXyqJXFazsmPopP0D/RHFTG3 8ceX8VVxzuIIUmCY1V2sjs76liJWe3IE9mfMe1h3JegraFL+VAXkhSuWUMOR9cFjV8Y7fGgSv fI/SkcGEQNVVIXc54DByyJ8VWsefRg33JX/s081futM14T/41KBR/ickX+CjYbyRyKNfShrWR bVJQ5N3b8pglVxPoufgQ/66RHzbVXPCLR3WOJs3rDxQATa+mKDMrASn3+FRFYTmLNdFtF9jA/ wPC0nvAAq6lurIXPBK8DTwwAuPzHZWoFlHtb0k4W7EK5ZFSJ6WZnLXe6IHUzZAcWWRMqbWZVy ounDgon1nZsw67XxeeqCwGWFXfhTzqw/doEipO6/1+pFEikAGj9DLiavWlwstp7afqUzXyKqD qkltLw36q0xJ5YGEK5RT4RqX2IgmIwtsFYapRGCs7pT8trb4HJSqkZBwoxteqOZlzuGs= 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 sh, that goes through another indirection using the rtc_sh_get_time/rtc_sh_set_time functions. This changes the sh rtc-generic device to provide its rtc_class_ops directly, skipping one of the abstraction levels. Signed-off-by: Arnd Bergmann --- arch/sh/kernel/time.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index d6d0a986c6e9..92cd676970d9 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c @@ -50,27 +50,30 @@ int update_persistent_clock(struct timespec now) } #endif -unsigned int get_rtc_time(struct rtc_time *tm) +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) { - if (rtc_sh_get_time != null_rtc_get_time) { - struct timespec tv; + struct timespec tv; - rtc_sh_get_time(&tv); - rtc_time_to_tm(tv.tv_sec, tm); - } - - return RTC_24H; + rtc_sh_get_time(&tv); + rtc_time_to_tm(tv.tv_sec, tm); + return 0; } -EXPORT_SYMBOL(get_rtc_time); -int set_rtc_time(struct rtc_time *tm) +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) { unsigned long secs; rtc_tm_to_time(tm, &secs); - return rtc_sh_set_time(secs); + if (!rtc_sh_set_time || rtc_sh_set_time(secs) < 0) + return -EOPNOTSUPP; + + return 0; } -EXPORT_SYMBOL(set_rtc_time); + +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_generic_init(void) { @@ -79,7 +82,10 @@ static int __init rtc_generic_init(void) if (rtc_sh_get_time == null_rtc_get_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); }