From patchwork Wed Apr 27 22:34:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8963871 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 0A592BF29F for ; Wed, 27 Apr 2016 22:52:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 261652024D for ; Wed, 27 Apr 2016 22:52:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3935620295 for ; Wed, 27 Apr 2016 22:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753588AbcD0Wvu (ORCPT ); Wed, 27 Apr 2016 18:51:50 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:59797 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753452AbcD0Wvr (ORCPT ); Wed, 27 Apr 2016 18:51:47 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0LsywU-1bgSL00CeA-012cRm; Thu, 28 Apr 2016 00:34:52 +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 09/16] rtc: m68k: provide rtc_class_ops directly Date: Thu, 28 Apr 2016 00:34:23 +0200 Message-Id: <1461796470-1291527-10-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:gEd2LWA4cgbBbC2AaK4LnxKv5LHzeMKq6B5eAUBz2OxAYSbZNeT 5vqs631zkyGU+QhTdTk3PfxMgF9LqhXz9ynaY+NwHVF6xEqGj+G0o0FQ4FGpdFOOjFNN6bw NQK2RzmgajRQ8hZwnKJI5hnpRlfCKIMKB9l2XbToC/sonTtjTpehmgNt0WAwFBUBFWZEMAP /Nq15rf2eoMXgCDuC/s8g== X-UI-Out-Filterresults: notjunk:1; V01:K0:NRFZ4jWArYE=:5z2lcgI8LiliwEXqpNb0ym Qz8vRNah1J32hJb46JnsWIEpAO9QV0FybDI26sg7Sb/rMoMWcQlLG8EbhaP3qxNiugEOE3VC0 Y5Bpl/qNHfd23WDJYbq+Oxze8XAWYto4QUtBCq1NrZrUqeWjpxm7w5wREslbhvBV1AJZ8ReH8 eP/kvFl5cKoAH1+HSa+K2dsEP3IXUT4eOs5qFv89s6MLwOA8435cAjwjouotTQzxzwxJAf4xB JQHIeW4VZLlqtr0D+aY+CaFFgcsvhMf4KBIMoLNVfKYgb8fDK0PskBC70BTvA09b05Xs5WLUE GsT8C5c88yWba0nRlMFBDxEmY0OX6koqjQ2604yBI26xQI3OttFQb/o6JkAksXnU7uyvP2IVl xj2WEUqTtOXxDf5rzzAOKZzU8LcFyvHK8V5rnCglbseWEg+5vgehQxFcLymUC6QV7o70SPAEl 621Nk56gAjaOADz50nOcBPvXfzRcqA0DfX6uGSG7bJhOkwTKVCxjoox+UhONuBh8G5vVEepFg seXf672GxDela/+4gGE78/qCswMUcRAIAlR1tEdniH+cpi9p4xiW/p8QN086BHSEPbYG6lKF7 V7t3N3CeaHuJWPmeeaYxNkOZWyxCjRErsBOpnc1H1lJOVJD/GbF1NU9j+LkroSQ3Q5DHH0stT GvotIFD6wXyWUJBuz51dbAefsvVF+gAylC1yd0S4Tsdksp2t0MDCwppjSRw5c6taoX6w= 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 m68k has another abstraction on top, which is a bit silly. This changes the m68k rtc-generic device to provide its rtc_class_ops directly, to reduce the number of layers by one. Signed-off-by: Arnd Bergmann --- arch/m68k/kernel/time.c | 24 ++++++++++++++++++++++-- drivers/rtc/rtc-generic.c | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c index 3857737e3958..80e024a10115 100644 --- a/arch/m68k/kernel/time.c +++ b/arch/m68k/kernel/time.c @@ -86,7 +86,24 @@ void read_persistent_clock(struct timespec *ts) } } -#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET +#if defined(CONFIG_ARCH_USES_GETTIMEOFFSET) && IS_ENABLED(CONFIG_RTC_DRV_GENERIC) +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) +{ + mach_hwclk(0, tm); + return rtc_valid_tm(tm); +} + +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) +{ + if (mach_hwclk(1, tm) < 0) + return -EOPNOTSUPP; + return 0; +} + +static const struct rtc_class_ops generic_rtc_ops = { + .read_time = rtc_generic_get_time, + .set_time = rtc_generic_set_time, +}; static int __init rtc_init(void) { @@ -95,7 +112,10 @@ static int __init rtc_init(void) if (!mach_hwclk) return -ENODEV; - pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); + /* or just call devm_rtc_device_register instead? */ + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &generic_rtc_ops, + sizeof(generic_rtc_ops)); return PTR_ERR_OR_ZERO(pdev); } diff --git a/drivers/rtc/rtc-generic.c b/drivers/rtc/rtc-generic.c index 92b5e02a3750..5c82bae73b9c 100644 --- a/drivers/rtc/rtc-generic.c +++ b/drivers/rtc/rtc-generic.c @@ -9,7 +9,7 @@ #include #include -#if defined(CONFIG_M68K) || defined(CONFIG_PPC) +#if defined(CONFIG_PPC) #include static int generic_get_time(struct device *dev, struct rtc_time *tm)