From patchwork Tue Apr 26 21:52:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8946331 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 E5CD89F1D3 for ; Tue, 26 Apr 2016 21:54:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A0362011E for ; Tue, 26 Apr 2016 21:54:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3682C20107 for ; Tue, 26 Apr 2016 21:54:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753301AbcDZVxW (ORCPT ); Tue, 26 Apr 2016 17:53:22 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:63640 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752483AbcDZVxT (ORCPT ); Tue, 26 Apr 2016 17:53:19 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0MCfv0-1b3O6S2sks-009Oq4; Tue, 26 Apr 2016 23:52:42 +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 1/6] rtc: m68k: provide rtc_class_ops directly Date: Tue, 26 Apr 2016 23:52:26 +0200 Message-Id: <1461707551-1337971-2-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:umHbvw3BrrmVGhUeJRiTj40axPEgiQYTRd8evKw0atZKkXncTLy Zlprx1JQdwFocxBJH2grNRZHRSDNddfESyvAHvMcxbiUjNK1dP/rDjiuFzUxeG7flpFuiq3 BMlYm30AU1gIgoyAbxS6SlyGxgW5FQydt2w9U5EF4gDBqZ6kBmwwBMQjYOuzAn5UuseKuWi TG73vsH+B3ixHp1wsxVfw== X-UI-Out-Filterresults: notjunk:1; V01:K0:PA50AUbxmHY=:iUPUTWnWNrKQOkR34aFdEX 7ZYpR0qefsIkqIOFUbm5CVYN5YwnG4JfVrpt7d02HuhCSV0a8NV7ikF7sqi0DEpnaVUTz744I 97j94MFaGXSgc/n3bBnI3VA/rN/EgymuDjSIWBREXIkQuHI3ZSxYB1Oen63sz0Q2UbF7PjNvQ aocjIWYxJ62chmLcQaL1Ax34l8MFLusdcwbAYY1fGUZ7iaIOGla517HDy8DLln/2OOD51Feey nUnSn3Z2os4p5laVhDesSDCwGtdkWipGbX4kqeWv+ySP+Jo1vbFSO6E2Bm2TKVFxhPkOaFCBT 2hpMmcR3tFzlBDqkIRoBTcDSOPkTv5xbilt+ulVNl8ZtezZoKGq0iMTSnOnSeo1CzApc2XgK6 QidnzkkpBUugteWYp3YcQfCvpvW8D8/KPvkFOKPN03kr7ISNavAttkP2fH0Svm0C1Vu7C6fN4 vo46/KZmjE5BHSQVDuw4UXg4eqDx8d5sjop9rU6oYxnJotj1dpA1TQmPgQpHCOIz898P/Lwr8 ZKYbd0q+nrsa9O+A/3wYvZmtbrrynEkYIlgEGbPHp0vmldvxTtZl3nXaOZS2GcnSkvax0d3/c 1EhR984RTgPkiyGuyCeFUTtP7BU7FM5tGGlAOoN59WCpqIdOJAzlgeo4pptVm33nTXrYtpj+l oydXm5gnOcgB9sAEgELdRWMSbetfbsX5wluvMWRn+nZyyfKZBc2mdOiu/b4fp8MkQo8Y= 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=ham 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 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c index 3857737e3958..fe35890feede 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) && defined(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); }