From patchwork Fri Apr 20 15:48:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133894 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp435455ljf; Fri, 20 Apr 2018 08:50:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/oUmKk8iLIn6Qwb1IQg6VnQoyHWQ3XNRagBBGf5cpRCdjQlq1gB0IQT6DlS5IH0uA68f1y X-Received: by 10.98.189.14 with SMTP id a14mr10017009pff.30.1524239402454; Fri, 20 Apr 2018 08:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524239402; cv=none; d=google.com; s=arc-20160816; b=PCBYkINFQ+N6gf9iZ8QNvPRQ1qgMsW+RFAmcuhY78ntsDIqWzWFH3JpLF8ocnERmoB Qa9Iw3Unjsn5tlS7rZgRbF76oSD1i4puJLs70xE7JYvvwCsQ1mxIcr5QB63sUeuNXPlP XwPnCzjosbcAHPTMnrmZcUKwY1h7sTDFACiwhahA0azYuRU5T4qE3DQT92d+xk1N/VKE 6Bg6uB4iE8pU52vc82+PQWJLv62RsKMXyq/t/xPSTPkJZTSg1aXNh5Nk/SY9pxaiKzSg xTKimbc41rRfQupzgfcfaN9aj5NIrGKFotQV1WwK0YTlZjuI8fs/rfHG7+hKKRZe14Eo yaEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1dP9qM7QFblfmWAHelQl0npvKfYIaiBNH9KJGV3tGuM=; b=M8zV7QF4ocPsAJpcjB7F9DBuwFSlILt8F1vwk7bN0x6EKvwqHBiYjfQYJI/eJka/Yd dTPXOXagiRKuB2hfN2rD/+er/F5+vKKlJMVo3/LmAugWGDDcvEqJTOVo9ocKtV469OHf 2KTBc6pDa6MuZQpDLUZy+/bbEgVSgspR3cFUx+AAyM7VvvfCcu1kOOj+QW1ccsF6cKFZ llyqlgXIM32fGynM5IthTR/o5UhkKBFgsLdftJ3oXOM5BbJL1vSQjvWOplaQ7bqTMzGW FnfJH9Lj0Xu61SOQv3WJ8RpxsMF/G9xGTjILvn+Qz5EvbsEbHLvhIJMnsEp8+b+G5hg8 9OzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n128si4990994pgn.15.2018.04.20.08.50.01; Fri, 20 Apr 2018 08:50:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755875AbeDTPt7 (ORCPT + 29 others); Fri, 20 Apr 2018 11:49:59 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:42093 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755849AbeDTPt5 (ORCPT ); Fri, 20 Apr 2018 11:49:57 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0MUjgO-1evMQn3DUS-00Y8sQ; Fri, 20 Apr 2018 17:49:37 +0200 From: Arnd Bergmann To: Rich Felker Cc: Baolin Wang , Yoshinori Sato , linux-sh@vger.kernel.org, broonie@kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] sh: dreamcast: rtc: push down rtc class ops into driver Date: Fri, 20 Apr 2018 17:48:53 +0200 Message-Id: <20180420154933.3235131-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:BO28J4T9sfoTD3A/5F9+J6y+qVnhQctspbP9B8h2lLDhesVLGOO NfPZKpxZjMJPuxw6YsCxvIssopQfX06TeEDpxNoPS1k8aF+UABXmM9Gij3ODCfgRfj9/GHg oUmYqYRJiKrvS4ps8ifSpf3DXx4fl+nc9ZKY8VLuCircKzDcTjApS30J2RFDvdhCxgTLZoj QX2kNUCwKBfWQmma/+u2A== X-UI-Out-Filterresults: notjunk:1; V01:K0:imd5xLKD8yw=:FjSs905GC/hm6SC7YMxOrz AxZxbqA2L3/RpqxSe51KdwUA0m/Zr2H6pZFzErVLzdGaRAULC0lweflSumcDLEcU0LDMTRSKx lWg5l2k4WSS8jb/KqczhOwtsQALC0hKW462JRqgnzKAhcO6UFZTkg9VkW+V3/o/GH5rQmHqWI IQfgyIacVEkbP4LxkWHp+CtSOKYG15AubC5NeAEnr3rLi73RRnKWocqxm2kUs+/0EvWS6i7B4 n1oCJ4VC+SlVj1S28jcVpMnQJ5xj7seDi8s68PWUV7hNzcx+zQZSgJ92y7dtiZsAQA2dKctBB KqxEjuXf0iGmmg3thd630tnBUC9t7mcjbYwy0Z+85UOJmIpzUmIj1FR69z0Hp3B9LTbZsGnsg xBh9gxt4d0+PBECUyF+1zBRjhTOh//k3nDFiylNknpSeqMggrVqwP2OC4qXutjVZ/mVx+BTno sGyqvG6TJZOZmN7CmriGoIct6na8sPGd4HO/62rtsJeJyjZ4AOrnnOVjGbNexeHekkrubRoxM gu3MIoPceUegSy9nF0cvsmEsJ1p3DvWjijOM1yIcPfJTjRJCKy6sYTIae+upNMW3hWT3o33pi SKZ4hZ8st0MKfgawQCSzX4rPZM/8B1bg3XKKtkPTTj7/iP5P/xz/cdctvku6fK4gBFZinH8Kt 57XmJFNeXqHZqJd5AfmgkbvAOzhJClpFnEW+GHG7l02QAjNuklO/SruQE6aKVeNlgGarm/S6y 3KBjqOJ1GrcYsVVfuMM0+4TljfJ0RzXYfitgQA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dreamcast RTC support has an extra level of indirection to provide either the old read_persistent_clock/update_persistent_clock interface or the rtc-generic device for hctosys/systohc. Both do the same thing here, so we can do away with the abstraction and simply enable the RTC core code to take care of it. Signed-off-by: Arnd Bergmann --- arch/sh/boards/mach-dreamcast/Makefile | 4 +-- arch/sh/boards/mach-dreamcast/rtc.c | 39 ++++++++++++++++++--------- arch/sh/boards/mach-dreamcast/setup.c | 1 - arch/sh/configs/dreamcast_defconfig | 2 ++ arch/sh/include/mach-dreamcast/mach/sysasic.h | 1 - 5 files changed, 31 insertions(+), 16 deletions(-) -- 2.9.0 diff --git a/arch/sh/boards/mach-dreamcast/Makefile b/arch/sh/boards/mach-dreamcast/Makefile index 7b97546c7e5f..62b024bc2a3e 100644 --- a/arch/sh/boards/mach-dreamcast/Makefile +++ b/arch/sh/boards/mach-dreamcast/Makefile @@ -2,5 +2,5 @@ # Makefile for the Sega Dreamcast specific parts of the kernel # -obj-y := setup.o irq.o rtc.o - +obj-y := setup.o irq.o +obj-$(CONFIG_RTC_DRV_GENERIC) += rtc.o diff --git a/arch/sh/boards/mach-dreamcast/rtc.c b/arch/sh/boards/mach-dreamcast/rtc.c index 061d65714fcc..4f168d8d2951 100644 --- a/arch/sh/boards/mach-dreamcast/rtc.c +++ b/arch/sh/boards/mach-dreamcast/rtc.c @@ -11,8 +11,9 @@ */ #include -#include -#include +#include +#include +#include /* The AICA RTC has an Epoch of 1/1/1950, so we must subtract 20 years (in seconds) to get the standard Unix Epoch when getting the time, and add @@ -30,9 +31,10 @@ * * Grabs the current RTC seconds counter and adjusts it to the Unix Epoch. */ -static void aica_rtc_gettimeofday(struct timespec *ts) +static int aica_rtc_gettimeofday(struct device *dev, struct rtc_time *tm) { unsigned long val1, val2; + time64_t t; do { val1 = ((__raw_readl(AICA_RTC_SECS_H) & 0xffff) << 16) | @@ -42,10 +44,12 @@ static void aica_rtc_gettimeofday(struct timespec *ts) (__raw_readl(AICA_RTC_SECS_L) & 0xffff); } while (val1 != val2); - ts->tv_sec = val1 - TWENTY_YEARS; + /* normalize to 1970..2106 time range */ + t = (u32)(val1 - TWENTY_YEARS); - /* Can't get nanoseconds with just a seconds counter. */ - ts->tv_nsec = 0; + rtc_time64_to_tm(t, tm); + + return 0; } /** @@ -54,10 +58,11 @@ static void aica_rtc_gettimeofday(struct timespec *ts) * * Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter. */ -static int aica_rtc_settimeofday(const time_t secs) +static int aica_rtc_settimeofday(struct device *dev, struct rtc_time *tm) { unsigned long val1, val2; - unsigned long adj = secs + TWENTY_YEARS; + time64_t secs = rtc_tm_to_time64(tm); + u32 adj = secs + TWENTY_YEARS; do { __raw_writel((adj & 0xffff0000) >> 16, AICA_RTC_SECS_H); @@ -73,9 +78,19 @@ static int aica_rtc_settimeofday(const time_t secs) return 0; } -void aica_time_init(void) +static const struct rtc_class_ops rtc_generic_ops = { + .read_time = aica_rtc_gettimeofday, + .set_time = aica_rtc_settimeofday, +}; + +static int __init aica_time_init(void) { - rtc_sh_get_time = aica_rtc_gettimeofday; - rtc_sh_set_time = aica_rtc_settimeofday; -} + struct platform_device *pdev; + + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &rtc_generic_ops, + sizeof(rtc_generic_ops)); + return PTR_ERR_OR_ZERO(pdev); +} +arch_initcall(aica_time_init); diff --git a/arch/sh/boards/mach-dreamcast/setup.c b/arch/sh/boards/mach-dreamcast/setup.c index ad1a4db72e04..672c2ad8f8d5 100644 --- a/arch/sh/boards/mach-dreamcast/setup.c +++ b/arch/sh/boards/mach-dreamcast/setup.c @@ -30,7 +30,6 @@ static void __init dreamcast_setup(char **cmdline_p) { - board_time_init = aica_time_init; } static struct sh_machine_vector mv_dreamcast __initmv = { diff --git a/arch/sh/configs/dreamcast_defconfig b/arch/sh/configs/dreamcast_defconfig index 3f08dc54480b..1d27666c029f 100644 --- a/arch/sh/configs/dreamcast_defconfig +++ b/arch/sh/configs/dreamcast_defconfig @@ -70,3 +70,5 @@ CONFIG_PROC_KCORE=y CONFIG_TMPFS=y CONFIG_HUGETLBFS=y # CONFIG_CRYPTO_ANSI_CPRNG is not set +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_GENERIC=y diff --git a/arch/sh/include/mach-dreamcast/mach/sysasic.h b/arch/sh/include/mach-dreamcast/mach/sysasic.h index 58f710e1ebc2..59effd1ed3e1 100644 --- a/arch/sh/include/mach-dreamcast/mach/sysasic.h +++ b/arch/sh/include/mach-dreamcast/mach/sysasic.h @@ -42,7 +42,6 @@ /* arch/sh/boards/mach-dreamcast/irq.c */ extern int systemasic_irq_demux(int); extern void systemasic_irq_init(void); -extern void aica_time_init(void); #endif /* __ASM_SH_DREAMCAST_SYSASIC_H */ From patchwork Fri Apr 20 15:48:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133895 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp436740ljf; Fri, 20 Apr 2018 08:51:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+9e/F+ksCKThBW8/3NI3MZidXdSWN+yGUbMROrdB8zNrROMCp2gT7fR9qhS6gsq9I56K1V X-Received: by 2002:a17:902:a50d:: with SMTP id s13-v6mr10604335plq.228.1524239473853; Fri, 20 Apr 2018 08:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524239473; cv=none; d=google.com; s=arc-20160816; b=iouTFlvnwgn0+CUaBtH9a3dtDqP/cYGRCU6AnUSBSHndPWT6zauIaNs6c+HxcgZiTf 4VwU+7VVY52zodLs6c5nqlixlbh+9aUD/kNVH+Gd5qvQ8zWrGJFNz7eHKVzQQmcpLP35 7Ou09QnNer2r1QWidLk0rmEmSTSareKGbLb0bhFEBNhdTMqu2gac/4SNvi9tSFqhLXHq kIeTk+VeJEh+pb/arf/pedGBPqjzi5O/M2k8TgClekqSsy//oos405mEpok0qlK+YysQ Jip7GaobUh4En+awd/aXzBiPOvDgYDmLcEFfY2OIyslEgs0l+a+9sTpyE0qlihc9OYej ndGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=EsK6LyzV0fr0aDJFTBiFQ02SHTd19QbRHmO0j5rKt0o=; b=LUiaA16uoqkdlN5yXsSZyYs6CPVX0Gaf4LyC/dsAv8FIZTdoEqRr5BdWd0UPzziVt7 FIVHQtuDv3PCkKIqE3y+ciAT2vDfRoroTMQZT6YGPBTxvUbK9cVBXAEHx+KO/JpEeBAa pWvGVo0rjP4R1aPuHIuTvNxDdrP/WS+KpktveaKsQopwDazz+tcUouIKVmWUhy6lmC54 QrWNufteU9RZVmngcTe6x4SlKEl9C7UUzImX/TaD0J+HFgARd6OLO0yplvLyOuydeaH6 DkkBtrwpSu9RmdRPmiCVvi9a77BHuqe+NjhQy7uzqfM5jPr9ZizW4fnU0k/G3tXY8CP9 RFUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33-v6si2456180pli.275.2018.04.20.08.51.13; Fri, 20 Apr 2018 08:51:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755914AbeDTPvJ (ORCPT + 29 others); Fri, 20 Apr 2018 11:51:09 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:53235 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755472AbeDTPvH (ORCPT ); Fri, 20 Apr 2018 11:51:07 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0MJYS7-1f74XF2lxL-0037kX; Fri, 20 Apr 2018 17:50:54 +0200 From: Arnd Bergmann To: Rich Felker Cc: Baolin Wang , Yoshinori Sato , linux-sh@vger.kernel.org, broonie@kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 2/4] sh: sh03: rtc: push down rtc class ops into driver Date: Fri, 20 Apr 2018 17:48:54 +0200 Message-Id: <20180420154933.3235131-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180420154933.3235131-1-arnd@arndb.de> References: <20180420154933.3235131-1-arnd@arndb.de> X-Provags-ID: V03:K1:1xeHnmiXMDG2DTaWNflZwqpgh543RPem6gKyN8LmpPBjRBn7EzH /gN++41156NmEPTyqkSWp3+TFLATbUJ0em9Gy415v+zji5vf6glGIncF85pl5brwKMTSPDZ KpELVTt9RM3b4ux1MvpoAY7K70IIxXX9Q5i6VYGWveTXORUwFjOh1RxdtbRcLK5NkXkuR13 6hAAdLZzqMa1RF03uJKZQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:vMx0ryBC2ls=:48s+U6voPXjmOWlQZOFwh2 hxkIpquGhB8Z9rO9USwEjdNN86btNQAgEVNFLmCSizVhd8dxL+nN2tkAyflOu+OXTjTxj2GQf ZUlYrvlKZNf4LWGMjzqs2R0PhZkNVgh7hwwnS8ckpA5V2X8SibiZcAu/h9UEeQ0qn4mI03yLp 8zcgJDWVIlKM67kmR7IcAUa3v3PNFLTshLnxFa69g33EkK+lvyYn0X5/BTNSl62+V5NURvxwD emKkzMT+he48WYORvVZsoy0t34rhcXTK6OXlaazEg1Jf6sFbmUqDaKp5wkyXwl0BI1Ku4V2pz 3tgasT8/vUWjoHprLhuIn10KPDaRVhckNmryvxhVDggvrj0pwz3CdX98gtfgDU7r/kbu4ttFv SHKi7TP4Ea2TEzwlOvyx8YVkCZ+QsD/0qCgtisYVEsf5oJBMPnIz9lTab/JntgUZv/Mn06wJR H/wA68fB5s18BWq/J8myhYa9LIq6Gt5YfcSBPs0hzuQFHSuhbul9EsuLDJG6hmsf7WGkfB6dy ot0wHHZ3FoWUly3Faw9G0NkI/yeE+rLaTcwaK+ljAstxwFxQrNPzNTBYw+EXHV/O5GubABjim B+uW8JB0tM8uRQ0LgbFlYCK9CJwoqvYpLoiy0sk6YSl7UOnxA9c6eAXOQKDGhjqIBBoNmTDn1 Sz96TQpYhA1O+uWvSbPQpPg9anW897T3BW7rbb2ZiWgq4Q6WDTnsbNMI+L9qniGUksqH2RjUj c0IncDigGRDIHecBOgszCTOwquQr7qRhjHPqug== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dreamcast RTC support has an extra level of indirection to provide either the old read_persistent_clock/update_persistent_clock interface or the rtc-generic device for hctosys/systohc. By removing the indirection and always using the RTC_CLASS interface, we can avoid the lossy double conversion between rtc_time and timespec, so we end up supporting the entire range of 'year' values, and clarifying the rtc_set_time callback. I did not change the behavior of sh03_rtc_settimeofday(), which keeps just updating the seconds/minutes by calling set_rtc_mmss(), this could be improved if anyone cares. Also, the file should ideally be moved into drivers/rtc and not use rtc-generic. Signed-off-by: Arnd Bergmann --- arch/sh/boards/mach-sh03/Makefile | 3 ++- arch/sh/boards/mach-sh03/rtc.c | 51 ++++++++++++++++++++++++--------------- arch/sh/boards/mach-sh03/setup.c | 9 ------- arch/sh/configs/sh03_defconfig | 2 ++ 4 files changed, 35 insertions(+), 30 deletions(-) -- 2.9.0 diff --git a/arch/sh/boards/mach-sh03/Makefile b/arch/sh/boards/mach-sh03/Makefile index 400306a796ec..47007a3a2fc8 100644 --- a/arch/sh/boards/mach-sh03/Makefile +++ b/arch/sh/boards/mach-sh03/Makefile @@ -2,4 +2,5 @@ # Makefile for the Interface (CTP/PCI-SH03) specific parts of the kernel # -obj-y := setup.o rtc.o +obj-y := setup.o +obj-$(CONFIG_RTC_DRV_GENERIC) += rtc.o diff --git a/arch/sh/boards/mach-sh03/rtc.c b/arch/sh/boards/mach-sh03/rtc.c index dc3d50e3b7a2..8b23ed7c201c 100644 --- a/arch/sh/boards/mach-sh03/rtc.c +++ b/arch/sh/boards/mach-sh03/rtc.c @@ -13,8 +13,9 @@ #include #include #include -#include -#include +#include +#include +#include #define RTC_BASE 0xb0000000 #define RTC_SEC1 (RTC_BASE + 0) @@ -38,7 +39,7 @@ static DEFINE_SPINLOCK(sh03_rtc_lock); -unsigned long get_cmos_time(void) +static int sh03_rtc_gettimeofday(struct device *dev, struct rtc_time *tm) { unsigned int year, mon, day, hour, min, sec; @@ -75,17 +76,18 @@ unsigned long get_cmos_time(void) } spin_unlock(&sh03_rtc_lock); - return mktime(year, mon, day, hour, min, sec); -} -void sh03_rtc_gettimeofday(struct timespec *tv) -{ + tm->tm_sec = sec; + tm->tm_min = min; + tm->tm_hour = hour; + tm->tm_mday = day; + tm->tm_mon = mon; + tm->tm_year = year - 1900; - tv->tv_sec = get_cmos_time(); - tv->tv_nsec = 0; + return 0; } -static int set_rtc_mmss(unsigned long nowtime) +static int set_rtc_mmss(struct rtc_time *tm) { int retval = 0; int real_seconds, real_minutes, cmos_minutes; @@ -97,8 +99,8 @@ static int set_rtc_mmss(unsigned long nowtime) if (!(__raw_readb(RTC_CTL) & RTC_BUSY)) break; cmos_minutes = (__raw_readb(RTC_MIN1) & 0xf) + (__raw_readb(RTC_MIN10) & 0xf) * 10; - real_seconds = nowtime % 60; - real_minutes = nowtime / 60; + real_seconds = tm->tm_sec; + real_minutes = tm->tm_min; if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1) real_minutes += 30; /* correct for half hour time zone */ real_minutes %= 60; @@ -112,22 +114,31 @@ static int set_rtc_mmss(unsigned long nowtime) printk_once(KERN_NOTICE "set_rtc_mmss: can't update from %d to %d\n", cmos_minutes, real_minutes); - retval = -1; + retval = -EINVAL; } spin_unlock(&sh03_rtc_lock); return retval; } -int sh03_rtc_settimeofday(const time_t secs) +int sh03_rtc_settimeofday(struct device *dev, struct rtc_time *tm) { - unsigned long nowtime = secs; - - return set_rtc_mmss(nowtime); + return set_rtc_mmss(tm); } -void sh03_time_init(void) +static const struct rtc_class_ops rtc_generic_ops = { + .read_time = sh03_rtc_gettimeofday, + .set_time = sh03_rtc_settimeofday, +}; + +static int __init sh03_time_init(void) { - rtc_sh_get_time = sh03_rtc_gettimeofday; - rtc_sh_set_time = sh03_rtc_settimeofday; + struct platform_device *pdev; + + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &rtc_generic_ops, + sizeof(rtc_generic_ops)); + + return PTR_ERR_OR_ZERO(pdev); } +arch_initcall(sh03_time_init); diff --git a/arch/sh/boards/mach-sh03/setup.c b/arch/sh/boards/mach-sh03/setup.c index 85e7059a77e9..3901b6031ad5 100644 --- a/arch/sh/boards/mach-sh03/setup.c +++ b/arch/sh/boards/mach-sh03/setup.c @@ -22,14 +22,6 @@ static void __init init_sh03_IRQ(void) plat_irq_setup_pins(IRQ_MODE_IRQ); } -/* arch/sh/boards/sh03/rtc.c */ -void sh03_time_init(void); - -static void __init sh03_setup(char **cmdline_p) -{ - board_time_init = sh03_time_init; -} - static struct resource cf_ide_resources[] = { [0] = { .start = 0x1f0, @@ -101,6 +93,5 @@ device_initcall(sh03_devices_setup); static struct sh_machine_vector mv_sh03 __initmv = { .mv_name = "Interface (CTP/PCI-SH03)", - .mv_setup = sh03_setup, .mv_init_irq = init_sh03_IRQ, }; diff --git a/arch/sh/configs/sh03_defconfig b/arch/sh/configs/sh03_defconfig index 2156223405a1..489ffdfb1517 100644 --- a/arch/sh/configs/sh03_defconfig +++ b/arch/sh/configs/sh03_defconfig @@ -130,3 +130,5 @@ CONFIG_CRYPTO_SHA1=y CONFIG_CRYPTO_DEFLATE=y # CONFIG_CRYPTO_ANSI_CPRNG is not set CONFIG_CRC_CCITT=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_GENERIC=y From patchwork Fri Apr 20 15:48:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133897 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp437083ljf; Fri, 20 Apr 2018 08:51:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+1vzL1Amj8u30yAMlpNp3rRT79kwLjNKr50WgT4ksGEV/XNdX9GCTKqpZGUPEMfaWN5avJ X-Received: by 10.99.181.30 with SMTP id y30mr7237722pge.279.1524239494266; Fri, 20 Apr 2018 08:51:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524239494; cv=none; d=google.com; s=arc-20160816; b=cy7RSddo14nDbyBu7ltS0idwEd2VRTtm7scVcLzmsesKUSxEpeUjJr2Pr03yt7nhXT Rdj7wmByFPH1NFwwycq2wFUTVPhY3vKqwTBXIBWrqrg7N+LWOhMGIdlHbRMKAJU0W/+W XgaW3uyxvuTYd0x5Eshr7N8jPbkq5vCH8hIaIjdbd5tJH0OngAbO4g9inq/x1SVc4Fsx Dv1lZe/CuftviQ1hP7P7SkF5K3560W+zmJkeQkNef7zGGD4S4JUeAKYUGaX4Q/J3MGoA 3kkEtPXuwbFsfHJzWitzDdDG08YWZ5pDFkou/VeMivxCxjnHYLmlKX60HVhkUWCyzSJb gA0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=SffeirJbJmPmHAQJXrsj9JFB+bUM9jQckq76iFNuAnU=; b=pd64lJ/fx+LfQ6qZ9GMfyfaRNsS06Wv0YXrH7XRPmEY+tE+t2i/75+OGhqlQaxWhcW X74BgSQvqsP5qYqGwsjCdSX6DNVmJ46BaZUBIoxUvcOLPkAQahbfHudga4+uT0oGNQES Rbt7yHJov5HSNNPtw85m5OkH5TeZYDzaNCiyAUCqJ2p6obl3seBhvwoMp1S9RDzR7TK/ 025PaJGBYJtlsRNqnlazkez5wocCmXzaCPAHUz1MGp1nwcFK5LupmdStF1qbpwfajR+a rqa5m/q1zLqJbTWLRpKxMRkmPh9+U5Pwl6sN1HW7UuH8+a5Y1PZakjhFuGZ+Bm8SY2wT mMYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33-v6si2456180pli.275.2018.04.20.08.51.33; Fri, 20 Apr 2018 08:51:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755808AbeDTPvb (ORCPT + 29 others); Fri, 20 Apr 2018 11:51:31 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:37953 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755318AbeDTPva (ORCPT ); Fri, 20 Apr 2018 11:51:30 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0LlrG8-1eaUc90ydU-00ZQYs; Fri, 20 Apr 2018 17:51:17 +0200 From: Arnd Bergmann To: Rich Felker Cc: Baolin Wang , Yoshinori Sato , linux-sh@vger.kernel.org, broonie@kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 3/4] sh: remove unused rtc_sh_get/set_time infrastructure Date: Fri, 20 Apr 2018 17:48:55 +0200 Message-Id: <20180420154933.3235131-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180420154933.3235131-1-arnd@arndb.de> References: <20180420154933.3235131-1-arnd@arndb.de> X-Provags-ID: V03:K1:0p2jbzaKK86D9LBfxKuJsFlRNChEero7sqL8EGIydd+q3C6j1Va bLs3qQ5wQa1IZWmiJGVqQjVh5pLh1jfQD/nah2jhby1BDQeI0Qgd6Oz9A7XaOMYIzhBW2M1 pqnyivoRRXVYKt8l7q9uSWqD3+MwQs5ifpcumth14R8LocJVwanSpf/474QGAWS3ftIWn6L rHXdTGUihaH1d5zT4Ps2w== X-UI-Out-Filterresults: notjunk:1; V01:K0:74k1vNT1t9I=:E6fIL2ZdQC4ELA6Jr3LSEP dsoju3wmLg6y9qbQ6t7dDAxrj99VZI3k6eCmAyfTB7fGjDkkdNVc+yyr4I+N/2OAy/wU0ek1C vNf3NvAg12mCWsVEE0IhemRprHIrzaFzZN8Shf7bTBNlux4kgP5TpAxvMieo8hG0AM64ZfRZv qAaqmiMUMmroasdNXxwNBBdprojybibFixUTKbeUjHnebOsG8M7f0avNOMzslwTzO5+oaonhx FiOl3XR58E9FjKCVSMeYYEDSLaaUz7OJCPEAtdRZ5vnrKwXRzgyskMy755Nfdkb7dDPT823+f nKyYfw9T71bmmXRwYfemb+mILExxASbNMFq0DQwSRSNKf2zxQapxFfVCKgGpcHnuxsmUcAmlg W7oO71v8epwUwa54+k76gM+LdIKb/klQ4fIFvNwCMvelUXX0Lrp4SCVNK5fQWaxt4QgZJLIPN QoJEXabGSmZH0bo1u1prU1qM5OFZQQskNfyF/k3IdNdrYvTaejD3pTijS2wGafMfYmNhM+GTQ dIkye7m4sXh3JNOGDaPq4wvVHu7y5KvwqrriUWTMz3FPqCsaRWBtnhPGFisyJ+jelV9hrCJIJ FbSYWxPaXQoHi39xEXvPkXUJwCt+WOw+utIqJvSHGbj/6X+CQvIZMZf9/YlLC0RbWluLscmZb oFdRXZih+wRPUFUi/b40huYg7FT4Wxx91yYMIUnNmy2B3U9jRFDxaq71TUsAtlwAd+Jly7yh1 M72ZQJbQ6DXfIOuavMnGT2X2TFWfQKbyX5nmzA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All platforms are now converted to RTC drivers, so this has become obsolete. The board_time_init() callback still has one caller, but could otherwise also get killed. This removes one more usage of the deprecated timespec structure, which overflows in y2038. Signed-off-by: Arnd Bergmann --- arch/sh/include/asm/rtc.h | 2 -- arch/sh/kernel/time.c | 69 ----------------------------------------------- 2 files changed, 71 deletions(-) -- 2.9.0 diff --git a/arch/sh/include/asm/rtc.h b/arch/sh/include/asm/rtc.h index c63555ee1255..fe55fbb181aa 100644 --- a/arch/sh/include/asm/rtc.h +++ b/arch/sh/include/asm/rtc.h @@ -4,8 +4,6 @@ void time_init(void); extern void (*board_time_init)(void); -extern void (*rtc_sh_get_time)(struct timespec *); -extern int (*rtc_sh_set_time)(const time_t); #define RTC_CAP_4_DIGIT_YEAR (1 << 0) diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index fcd5e41977d1..eb0a91270499 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c @@ -22,75 +22,6 @@ #include #include -/* Dummy RTC ops */ -static void null_rtc_get_time(struct timespec *tv) -{ - tv->tv_sec = mktime(2000, 1, 1, 0, 0, 0); - tv->tv_nsec = 0; -} - -static int null_rtc_set_time(const time_t secs) -{ - return 0; -} - -void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time; -int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time; - -void read_persistent_clock(struct timespec *ts) -{ - rtc_sh_get_time(ts); -} - -#ifdef CONFIG_GENERIC_CMOS_UPDATE -int update_persistent_clock(struct timespec now) -{ - return rtc_sh_set_time(now.tv_sec); -} -#endif - -static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) -{ - struct timespec tv; - - rtc_sh_get_time(&tv); - rtc_time_to_tm(tv.tv_sec, tm); - return 0; -} - -static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm) -{ - unsigned long secs; - - rtc_tm_to_time(tm, &secs); - if ((rtc_sh_set_time == null_rtc_set_time) || - (rtc_sh_set_time(secs) < 0)) - return -EOPNOTSUPP; - - return 0; -} - -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) -{ - struct platform_device *pdev; - - if (rtc_sh_get_time == null_rtc_get_time) - return -ENODEV; - - pdev = platform_device_register_data(NULL, "rtc-generic", -1, - &rtc_generic_ops, - sizeof(rtc_generic_ops)); - - - return PTR_ERR_OR_ZERO(pdev); -} -device_initcall(rtc_generic_init); - void (*board_time_init)(void); static void __init sh_late_time_init(void) From patchwork Fri Apr 20 15:48:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133898 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp438027ljf; Fri, 20 Apr 2018 08:52:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+tKE/tzC2oqIdswYM6syw3Ds6+myH2QxHTjORYwTCVa4Erzw9fqdhi9EBbJeJHB2PGDbj7 X-Received: by 10.99.113.80 with SMTP id b16mr9000850pgn.326.1524239552687; Fri, 20 Apr 2018 08:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524239552; cv=none; d=google.com; s=arc-20160816; b=YK8OOtNNjaWpzpq74cfvsd8EyZEy+2+SgXa+nEe/qvuK+8jRR8XFM76/3075p1fX+Y tYNk4NojHw92IiivVwqwbxM2ouyD5gcABDMm6OnEdz9TwxU4I63lGAigwplYpADJwtCU JVrm2apy6oqTtTVg9tneDXjta6x3JZ8Xv7BS52uMmJIa+GZd2nkuyjBhVQrpGe08Dg8m l0zjPQUlOsEsGPHD41PVNyRzK0VliiuyryZzdxHUXKT4ZfN9SWx0MkXoCIFY+4ARCIX5 yBuA4A8Nr6Dry0WbU6TB8pyK1LB3BMqucql7WLqGFHZZQQT/apkjk9T8+kNRlnYCF7so WxRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fROyTn2cWhg8li5kxJLH6vtHr432FKOVi4cguxI3EKY=; b=KI2B5juNgAkDMi5y67JLuOfVWjIRflvckCmdXrvKsjJU0+TcqhUhxjpclpPUVqMsb6 BBekDzzz4PJIK0Kpu0VbFnAmXMF7O02yDC4XfschhhlEQhO9QSvQZZgfsczYHnE4xjR+ AIaOjUrVnjColJ5xI9dwp3jHEL3nzq+ZSP+cu+b5HvU7Hk9+e/a5rb6Rg5dYVz+loR8R ozny4K2IH7mrQh8m536NBFeh2nWiENxS2RbWWz1NV7yHYyQ6JWwb1o0hyyzlX4URD3Y8 gpmpczVxAlOVFfN0xx3cXHkRUJTRr/GufZl8ffvFBC/3ziGsfnLnAehPCGe3cXOIzQP1 NuvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg7-v6si6021808plb.537.2018.04.20.08.52.32; Fri, 20 Apr 2018 08:52:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755872AbeDTPw3 (ORCPT + 29 others); Fri, 20 Apr 2018 11:52:29 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:45881 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755390AbeDTPw1 (ORCPT ); Fri, 20 Apr 2018 11:52:27 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0MSmoL-1f2EDB2PXJ-00RpLT; Fri, 20 Apr 2018 17:52:12 +0200 From: Arnd Bergmann To: Rich Felker Cc: Baolin Wang , Yoshinori Sato , linux-sh@vger.kernel.org, broonie@kernel.org, Arnd Bergmann , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] sh: remove board_time_init() callback Date: Fri, 20 Apr 2018 17:48:56 +0200 Message-Id: <20180420154933.3235131-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180420154933.3235131-1-arnd@arndb.de> References: <20180420154933.3235131-1-arnd@arndb.de> X-Provags-ID: V03:K1:E6aI9z5mOwSy8SUT+nQPwhJTVsiqKC1upruTVpvUf7i5xfZa28r 9WFRFG0OqOFj5Q0KqreXb95HyRaThOJ9p5jPI4cy4BBHXOXhNHQIde7QbV/ypboG1BfZz5K wtYGpKyLrVnMPYGRTL8Mb2WKQyQK32WXQGdfWoOuOX7th9aT0OsMU0qpP/2NFZ5vhvtwieD ehAw3H5vdXGN7Y7ksXr0A== X-UI-Out-Filterresults: notjunk:1; V01:K0:ElrQUGIjCBE=:2k0JXKUI3TfS6+wJX04xVE xjFFE77GXbNZomgqIjl3a7fmFUEgGo47LC7TUygFJYu2JfMe5VJYAeHAoKG5PtW7Wfmu+x7Ib kwkBmqzxZvmIw3poNO6XyiHEBXCehrpYQMW38k/w6BztJAvV3qKWlbyKeYRT6/B6xyL6N8vYh QLyUS1OsMnvhrA2atXcBOxDcTiJH6RsagTX0u5xhOWcfQk8T/nKRDP2X6ae44xjvGd7EN4pHJ TYEJiX5PUZoMFTAakznzHD1SzCJUm3FfccIIq6PB8CaGtHHFf9eFZUceBFqobylLvaCTYK977 1MIgZRKBCTZ/dDnRhl4/a1C80+2rzB/+1mq5DyxVk6PD5Srb8CTKYyV1FSKgRokwJeOm3k1vz Znpi27AIwu46O6Z6Qna5Ntoh/zvpRUr0cCyWz/MJx4nn26S2wKlKs7NLTMwQh0zbMwdmle+p7 54gLWC2FQeHFqRcvQX+/XdkfxS9bN0ihupSPKJOoSU2GptL2qxJvsYpwzNPhb/AQTW8TY8Oa6 GePg4uITNfz5kmBGcl9zWB2Bcekrph4s8jGKi2Ggvxx1YAUeIR7dn8kOnCqIGbHUFsMlsKhZg 08AIHodjtaupj4AIcAfxWarW7PhjBbUvLFpBtvYprIXwv12o18JGypsToHKjOtbr1B9pE+g0x 5wRn8wFbphnah56nP7DdPc4bra/7Sg1DBLoP02Rg7re1CwFVOLifE+nuCVF2hKLDKs93R+/dS FtM5qe+8x+/O3zSqjMWBRcaD/9yqhdarsf3hAw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The only remaining user of board_time_init() is the of-generic machine, and that just calls the global timer_init() function. Calling that one has no effect on non-DT platforms, so we can simply call it unconditionally in place of board_time_init(). Signed-off-by: Arnd Bergmann --- Documentation/sh/new-machine.txt | 8 -------- arch/sh/boards/of-generic.c | 8 -------- arch/sh/include/asm/rtc.h | 1 - arch/sh/kernel/time.c | 5 +---- 4 files changed, 1 insertion(+), 21 deletions(-) -- 2.9.0 diff --git a/Documentation/sh/new-machine.txt b/Documentation/sh/new-machine.txt index f0354164cb0e..e0961a66130b 100644 --- a/Documentation/sh/new-machine.txt +++ b/Documentation/sh/new-machine.txt @@ -116,7 +116,6 @@ might look something like: * arch/sh/boards/vapor/setup.c - Setup code for imaginary board */ #include -#include /* for board_time_init() */ const char *get_system_type(void) { @@ -132,13 +131,6 @@ int __init platform_setup(void) * this board. */ - /* - * Presume all FooTech boards have the same broken timer, - * and also presume that we've defined foo_timer_init to - * do something useful. - */ - board_time_init = foo_timer_init; - /* Start-up imaginary PCI ... */ /* And whatever else ... */ diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c index 46b2481eec90..ee74ff1e7721 100644 --- a/arch/sh/boards/of-generic.c +++ b/arch/sh/boards/of-generic.c @@ -116,18 +116,10 @@ static void __init sh_of_mem_reserve(void) early_init_fdt_scan_reserved_mem(); } -static void __init sh_of_time_init(void) -{ - pr_info("SH generic board support: scanning for clocksource devices\n"); - timer_probe(); -} - static void __init sh_of_setup(char **cmdline_p) { struct device_node *root; - board_time_init = sh_of_time_init; - sh_mv.mv_name = "Unknown SH model"; root = of_find_node_by_path("/"); if (root) { diff --git a/arch/sh/include/asm/rtc.h b/arch/sh/include/asm/rtc.h index fe55fbb181aa..69dbae2949b0 100644 --- a/arch/sh/include/asm/rtc.h +++ b/arch/sh/include/asm/rtc.h @@ -3,7 +3,6 @@ #define _ASM_RTC_H void time_init(void); -extern void (*board_time_init)(void); #define RTC_CAP_4_DIGIT_YEAR (1 << 0) diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c index eb0a91270499..a29eb989d81b 100644 --- a/arch/sh/kernel/time.c +++ b/arch/sh/kernel/time.c @@ -22,8 +22,6 @@ #include #include -void (*board_time_init)(void); - static void __init sh_late_time_init(void) { /* @@ -41,8 +39,7 @@ static void __init sh_late_time_init(void) void __init time_init(void) { - if (board_time_init) - board_time_init(); + timer_init(); clk_init();