From patchwork Mon May 30 18:57:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9142035 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 904A460757 for ; Mon, 30 May 2016 19:01:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84C4E280B2 for ; Mon, 30 May 2016 19:01:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77E25281B4; Mon, 30 May 2016 19:01:48 +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=unavailable 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 1591B280B2 for ; Mon, 30 May 2016 19:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162061AbcE3TBE (ORCPT ); Mon, 30 May 2016 15:01:04 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:59219 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161879AbcE3S61 (ORCPT ); Mon, 30 May 2016 14:58:27 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MSa4i-1axel81ydA-00RcSQ; Mon, 30 May 2016 20:57:58 +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 04/16] rtc: sh: provide rtc_class_ops directly Date: Mon, 30 May 2016 20:57:52 +0200 Message-Id: <1464634684-1248135-5-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:uVTqh3HX7XO1GXHsHwf+L8Hy8iEKa56O5vgNcF1lBoE+Jt/jfab +ZKhioDvxQFESaH0HAQ9dJeh++0GQlzVtxut3v1P0CNuKzj7vtcjkJdiCy8hum3y9R8n/Hu t7aFJLtGPyCbQJA7Y1oKgQ2L+sg5NKDmeeaEMBh77BNF0RpGw2AMdtsyg1vPGJUMSuwBzXP PDPgwQXTYhzufSqVxQz3A== X-UI-Out-Filterresults: notjunk:1; V01:K0:FJ7KZKNcXt4=:bemJvfnJse1mPGm9r2UkAB j1sHYDNBtRFclAwLLbsVwciDlIGdIsaV73JF3SUkzoibAv2T+AMrl6GDquzQcaM/CDcuzSQFY I5ZGQLrJJtFf7oHox35AGD/R2pY1xauCYS7mQhdg+c556StiwcGK+NwfYgWG2RHzkOCoCmcnO LTHhTNQdaG3qbEhLGW3XB7n4qg+HXUQyZCFWxpagJt6Au6cQge7VHiAljcag8KSkEm84HVov1 wovSzwnl7WbyIh+u81R7+iEJGZgMi8xsc6Ub2Ckzupp9ZlJYZHZUYROyl90bdwBSf9YkzN7Oy 8cahDSAXFbyBCQ6m4RAxfqsfvhja3tR9/JQcwWEZ6NFrPMkTLmAN1ArhGTDLpFlW6+hWTHonL uPKwIXccjZ3CydxmMI/yxLVlTQQSIgQBr2y+FqbdB4U0cE0QsNe2/U9iEb+W/QMlAx9ftMy4Q iz6u3cmBmPrbhMAIFP2hBGf1e6w1ZGjiUCpvgrvwQ+TSwNlSnXQOkfJ/QRERAe6QdoEF34i7t MWH3wl8ivxexFSUsltqxGF1IBBdpcyV5jcJya24hZRYZCsezJas8nrBeEqJPtou/p1ZXsK914 hLan8yBNqzn3f4goohx4N+N2nFMjaes6CnGu7ik9K2iMhjcJFYYxUXVLn6QhAfduRq93rgwgr dTkDCBgyDzuYjHE4bXB1GeGFdAkChMY7BbSk8oU1IBUW6gR1tQ2UnXl6mijPlG9rnIKI= 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 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 Acked-by: Rich Felker --- arch/sh/include/asm/rtc.h | 11 ----------- arch/sh/kernel/time.c | 33 ++++++++++++++++++++------------- drivers/rtc/rtc-generic.c | 2 +- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/arch/sh/include/asm/rtc.h b/arch/sh/include/asm/rtc.h index 52b0c2dba979..f7b010d48af7 100644 --- a/arch/sh/include/asm/rtc.h +++ b/arch/sh/include/asm/rtc.h @@ -6,17 +6,6 @@ extern void (*board_time_init)(void); extern void (*rtc_sh_get_time)(struct timespec *); extern int (*rtc_sh_set_time)(const time_t); -/* some dummy definitions */ -#define RTC_BATT_BAD 0x100 /* battery bad */ -#define RTC_SQWE 0x08 /* enable square-wave output */ -#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ -#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ -#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ - -struct rtc_time; -unsigned int get_rtc_time(struct rtc_time *); -int set_rtc_time(struct rtc_time *); - #define RTC_CAP_4_DIGIT_YEAR (1 << 0) struct sh_rtc_platform_info { diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index d6d0a986c6e9..a4a7862b489a 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c @@ -50,27 +50,31 @@ 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 == null_rtc_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 +83,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); } diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index d726c6aa96a8..3958e87a05fa 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -10,7 +10,7 @@ #include #if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \ - defined(CONFIG_PPC) || defined(CONFIG_SUPERH32) + defined(CONFIG_PPC) #include static int generic_get_time(struct device *dev, struct rtc_time *tm)