From patchwork Wed Apr 27 22:34:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8963511 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 47072BF29F for ; Wed, 27 Apr 2016 22:38:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60366201F5 for ; Wed, 27 Apr 2016 22:38:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6344D20155 for ; Wed, 27 Apr 2016 22:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753649AbcD0Wfg (ORCPT ); Wed, 27 Apr 2016 18:35:36 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:50172 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753921AbcD0Wfc (ORCPT ); Wed, 27 Apr 2016 18:35:32 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0M6lu8-1bs1r31Q1s-00wVFU; Thu, 28 Apr 2016 00:34:49 +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 v3 04/16] rtc: sh: provide rtc_class_ops directly Date: Thu, 28 Apr 2016 00:34:18 +0200 Message-Id: <1461796470-1291527-5-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1461796470-1291527-1-git-send-email-arnd@arndb.de> References: <1461796470-1291527-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:3mgPSE3SDOSGAPnsP2hm0JPweUgYtF3hmNHddu5lFI7Vgzep5rl VDnzLqBtUp/QWQ3a5cHvmTFVwY0WJxaoNoZvo6tiotT0HytAZq1NoTBmoQY3Dn5oYCYiDgc 7BQA1q/wy9ux4qiRU7IQTr15Pmp8laDylx/T4Qlb02iE5Ou6Pn3/WRMvTWEACYk7W2uEolE KQY4wphBB/JxvTn5r3P+g== X-UI-Out-Filterresults: notjunk:1; V01:K0:9+H6nzp0bnE=:I4z+ErcfYMVaYZB6MzPdgd kMTXKYKpAxz64oMUweemdNBZXo8k3NBRxXhopVoa6Fxbz3n8G+IoAjIatJrcUUIcBnTxUzlcb F3i/nOY8scMagFv15deoFN0F/Vum9XSngmheNnXs/Ho3fr3a1kkzPnKB1JnX6bygFOV8KEyze D7Y1NZJ78b/My1N8GqdKSGsoGDeuIRbfOfVwwIX9c65l0P76RNpzNJOn6W8D+lePVSU71qmtK Im2nE56Q4ChFWLJlDBwYRqWw9MeN2N/hrtUtjDyojHKWutUo0OWlmAYNbzyI6kC077AOZHDgV Cz5zv2dJj+0k8yh0Lpsob9aXv9GROQMARThocmhIcFg4Uu3PsU5Fk0Jrf3voy7+Bbnp+gEqqr oWgGlq/aPXigYF/Z8waCWEKtqPONM1opw/aomlUcEL+b2OcYO0nbNbooLTmlcxx0cI8BNTeDx UXnJbgGWHPcNTyeUIT/25kyFztjM9qZuNSZrysYu/2Knro9vynCFJG8bmn2QWcRsqBi9OPXH0 LO89yQzmLgcOyAW+ykJmhDSfwR1E/a7APNZFsGPCV6Okowqcv8ihWb5201ELtMz8OSbXgKB2A hrQWeMlYqyJz3c5jwwjfY+OIUAGYsFUZ962dJgwXcYaFxdwJ6woMu5J9EjEslJydwtWCaPw3T KulUxt7k1mVYkov79Dkqzwwls00DOC8oNjSuw2L201quR0Rbhk8WKvc3tjCVZqPefurI= 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/include/asm/rtc.h | 11 ----------- arch/sh/kernel/time.c | 32 +++++++++++++++++++------------- drivers/rtc/rtc-generic.c | 2 +- 3 files changed, 20 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..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); } 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)