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: 102437 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1851511qge; Tue, 26 Apr 2016 14:54:49 -0700 (PDT) X-Received: by 10.98.76.22 with SMTP id z22mr6938562pfa.78.1461707689322; Tue, 26 Apr 2016 14:54:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ny6si1048258pab.59.2016.04.26.14.54.49; Tue, 26 Apr 2016 14:54:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753487AbcDZVym (ORCPT + 29 others); Tue, 26 Apr 2016 17:54:42 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.0 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); }