From patchwork Tue Mar 1 17:00:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8467451 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 29EB99F9A0 for ; Tue, 1 Mar 2016 17:03:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55EA620125 for ; Tue, 1 Mar 2016 17:03:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7587120266 for ; Tue, 1 Mar 2016 17:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752094AbcCARDJ (ORCPT ); Tue, 1 Mar 2016 12:03:09 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:59644 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751992AbcCARDH (ORCPT ); Tue, 1 Mar 2016 12:03:07 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MXp03-1aMlDc1JkF-00WpZW; Tue, 01 Mar 2016 18:02:07 +0100 From: Arnd Bergmann To: Alexandre Belloni Cc: linux-arm-kernel@lists.infradead.org, Kyle McMartin , rtc-linux@googlegroups.com, Alessandro Zummo , linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-parisc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Arnd Bergmann , Yoshinori Sato , Rich Felker , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] sh: rtc: provide rtc_class_ops directly Date: Tue, 1 Mar 2016 18:00:01 +0100 Message-Id: <1456851608-3374907-6-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456851608-3374907-1-git-send-email-arnd@arndb.de> References: <1456851608-3374907-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:oEdmIlpywmQ/D/bcXlpK5yo8Xbh9n3ycZpVQ/8YUqcfZ9RSRA0G NBrHakqeLi58GD8bFiyxQvwHBnkZH/3QBKy65QI5SNXy+6xkWq3hwg7n/BJQeTGm9HCVX9d cRcCcjbRkc38Sosm1/rM7GSqrleIflSsECqUNNX/VACJouBYOQf55aHGxGvSrRGkWRHV1al qW1EVj/KUDGD2Tgi+KVEA== X-UI-Out-Filterresults: notjunk:1; V01:K0:5QFN1KL1W4s=:WXpwvFF9XXIpToMqebFR3l ovw8AFQAb4k6pta/iZ/L+9XyL7HcE7G8+8L132kKcGUMo91/m6/xFvWZiyak0j7khfDkjwfdh Nz6DbAv5OUNA8c2i4ouNEQNSv5RNhKSnP+TMS0Hnw0uZvk/IfJjTYfU53thIp2ZOnPx6uSnVC 5RE5McD2gf9kFmF/Cu4+fHsP5d9EnOTwsHOLUSAx3DQgwOC2YqU66DPXVc9aZgKvYwaApQ9yp s0Vfc8Vmo5wNmDWUzV5IQDwc4qf90AAmdMDWI523UZgblcyknAJpUJSb0rsNQ9lEtDdGdWnTZ zrbVVuSXd84uvr9wJc2GgjrCqdx5nWNx7hAR5HL4o4ZIIDtluWntCBzEZjUF9CmrSQ/KFY/4i sjbjNSmHpclvB258yARwDXMZs7s1YqC24ae714DtF7Sm+Sb49Eayt5ZS1GhzfQejDjU8gjsVc NRJecpePjJ5kM6mN4B8v0yPJjcGjrRuGRUNQ70OiVKspT2I7r8UxrqU6uV4ru7/EO1WNoPvZS 3TiVJfFKJeY4ab+2QGhtd+oc/T+NF/nNNQ/VCUpZBl9+yUYURpTE5HDxqmX3Y5YPVbaTldzGE QDQzdrLloIVagN/SZ1OXp1nixY+cBFAoEESr+YrDR4bAG/CHulbGdbxzKTsL0ifdcXgbHoms7 3TAByiKRByCGCmDdhgXjFdyI3hOkCWLiWw+cXC+ueJ5j0fVbm4Aqgrq19luXnORRNSxY= Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.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); }