From patchwork Tue Jul 24 21:36:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142832 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp65249ljj; Tue, 24 Jul 2018 14:36:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpebtmV8qLpfAlNhcxiHNTvc/XoKNX+gJTQkLtUy9UFFMS6i+uWwHs7PuIPrcLNOVaoAZj6p X-Received: by 2002:a63:5922:: with SMTP id n34-v6mr17921294pgb.113.1532468219527; Tue, 24 Jul 2018 14:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532468219; cv=none; d=google.com; s=arc-20160816; b=v8o9R5zzDNkO+Xqi6lZKhJuDvhoIWMHso2STIW4xVk/D2wWbRS/NELtvF0k5xOqlkj okgPcXbdL2nyjfhmt5eHod5k5/QFKgKc6s4ZmFrjfyk7a3I4oI+2hnraPxk+MedB/2WP NaYLRwVFMqnsqrk4PaaolJwdQDg7K1qWy6kV8X00slCGzEBPCfo2bBtaOkU3eV6XhI/d gfylcSYJrT9ioT6GM1X7Ax1T3Z/nNT60zVYOKI244QY3EUowO7PIbudgI/ShLTiQm9JF 4wxskHAmzIU+G5QWe1G85SpmPdYQiakEyGz2iPq4Uab21xY0bnwKED3sbF9N92Xzv0uT oB0w== 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=nXGhvgbtM2MVYnmUcBhRNm1HWv2dEUpncTRfWaB6YNs=; b=GL22ghyrRz7cqvxxD3S8mtJgrecylz4+zChS/eZ5lIkoJXJ2WmvPOPEAhsqfdejN7l vxYsVHP177h14Gj3lxHqVsfVFhME4DVCG832PYk4FuGdqt5x/Z+YXjAShyKgHYlO7EtV AqnsJ+eyK/PMj8PRHE7LrON2ZtjrI98D9gxPghQDWcvMqS7/EI854jkG93t8/kLkg0JQ +QdU1hPeewVGBdAx29jN9PvA6O9ZMuImVLTKqD2aG1BJ0IvskJYdyIHbKG4KAxSz4Cwp 6llDk0M7ULXFPJ/KTuX0/7cnAC0hviRjDRMQxc06tta2Z4OHwU/k/chK13IhXbSCynSO hNGA== 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 2-v6si12465873pgq.479.2018.07.24.14.36.59; Tue, 24 Jul 2018 14:36:59 -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 S2388838AbeGXWpW (ORCPT + 31 others); Tue, 24 Jul 2018 18:45:22 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:57848 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388608AbeGXWpV (ORCPT ); Tue, 24 Jul 2018 18:45:21 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue006 [212.227.15.129]) with ESMTPA (Nemesis) id 0LthuT-1g74Rb04mr-011BmG; Tue, 24 Jul 2018 23:36:34 +0200 From: Arnd Bergmann To: dalias@libc.org Cc: ysato@users.sourceforge.jp, baolin.wang@linaro.org, y2038@lists.linaro.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH v2 1/4] sh: dreamcast: rtc: push down rtc class ops into driver Date: Tue, 24 Jul 2018 23:36:21 +0200 Message-Id: <20180724213624.3899336-1-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 X-Provags-ID: V03:K1:7Uh8AsYkJMOjFM01VrXgDnXSbrDNz+LOZatv9aU/vPLtBX9TRwU E/uK2f+Hi7/H/2Uz3mJ9xlDK+IVFjfE6Z++qQbUs9KYqRtp18PO6DMqjCMBj8RjfkAp9fPC 5R730vBo6IYzv5xb9X6LS10ZqcGg60SznjdImIaivpkAfqB8IpWRHzog3kLhpqih6C7Qblm hu1HIJHr5+7NmNEDR+fYQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:zl42cKfB+Fg=:HJ61kPAGgHqO2PzTjPVUo+ 8Bnw2GE00aDnMlWsMM1rax08uLJu2J1ilkfDlCkthlEGiCcAHhjcwcFbGPZ3fz8F4THiswT7P TWH4VJvtWUlF31JJ+jWfCS4lcSNv1VRkaik2pikmjO/o+IlpdJKToXJPSzqULYoZB8WeIreEK TLCl9Ix+IZX5R1Ioc8IfgctoEhfnpUrHdqq40qoiLGhEecMuk/RSuQ85dghzgqV4uU4Ulth84 dLb4oZ72WYLlHW+QNYbz177EmKC1qh73iy+UVaeBTwz81jSX8MIfASRD3uoR3TedRfrERK9J4 2XuugufzB8lWGMUffcqsPunQ3XiWzIZbun+eSBjB2lHris42IYcefamrs6l2JXwRvvIb17j2Y RX7cUZ+D75LGsd7Wg5UhWyqXWdJ+QcDDEmmi392wJicLsqpoZaTkNJWbLWbPKllCd6KNi6Vc6 acqD71Eh9NANXyaCbWi0ntPoEiYj6Bx8oioEyH2nRaXrYDRUFZT7cureF3ge27kP8EGQSnKuz m3GWz7yr33RlDGvHo4OPverg7YrWFrXbG6pCzG6I2L4HhWa/TK47v4mGK/eXzgZCjmsRq/0T0 inWOZHdGK0Fo48XHYfsnLffxGZ/cp3RnJ8/v0zoBw8cct9RcfAqQR79XhyprmqulQowy7a1Pm lkoU82zO6uUM1kckG1YP2zJYLuQNlseWz8tI9S1KPJRhT+ZbLEIoDCqnfFoaKqRdlA08= 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.18.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 Tue Jul 24 21:36:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142831 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp65201ljj; Tue, 24 Jul 2018 14:36:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfHCU9jNd7b2pBGrz6lBSD9xojTN3mztpY3LyolP3EWVzhVrlXTkM1cplJo/86+yw5XCMCE X-Received: by 2002:a17:902:b81:: with SMTP id 1-v6mr18781155plr.164.1532468216471; Tue, 24 Jul 2018 14:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532468216; cv=none; d=google.com; s=arc-20160816; b=dncFjQo1aX6iS8HYyKaQtss8s4maMX3EwgLBDtOMRfCjrgrDS7MbvB50fnk0LVGbR2 SbJs+OFtWVujbyJhVrbGRwRQPdhAw8Cw4Gd52yjTxi/rJDiS8c/SIZqjwdxOIyTrqx+V D+mmMSf7v78D/RAHChF21u8JUgo8hBQyy5J1oI4RUJSM/z+vVBjsV0Xf3CsD6EMiYmTx 8jhDcrEiKyD0sKvgJTc8O66vF8UWX4eeNOqym9ryv9z6nECh2I00jXeaco+Ve+aeqL9E 8gzspk5WCzm5V70wsvWH8/d1Lt/mjgZ0PRZYKXomg9VF9wLglQZYaIZjXuilHX0vyowX o4cA== 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=QFtiX/dPbNH5sJ8noK8cQLqDO4F+yvANdQqWBdQZ2sU=; b=ZLjEcaOuG1ZGubaG3GoJhLzL7SXqJGSfM2m992txA3Diw7/FqFm+ZM0QGXs1gtzNQI j3gCUSoTHnAU8sESpKaWGG5Rfo39QcL7ZHtUWDIy0XScd0eQ2DnV4FkH8MqgKOqCdpG+ 8VTOyS8toMfOo7N4nDlVyXyhUiae3qH1zSg0oQGx79iQ0GqpEJpkuYbIlzF2hc2Pheiu dbM7m1HsRgvpY3SksSZSpwXcM81DnJYnra3tS8PbcIb0TeLxp3MrJKy/uc0nPAcMqQFH PyVdsGAjCy9vXicK/XhnrpJRBMIAY7bYp1qhyk3WBH0Xs062HIpzSHgXoFPkSkx6CBqS WlPQ== 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 t79-v6si11106038pfa.170.2018.07.24.14.36.56; Tue, 24 Jul 2018 14:36:56 -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 S2388804AbeGXWpS (ORCPT + 31 others); Tue, 24 Jul 2018 18:45:18 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:37493 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbeGXWpR (ORCPT ); Tue, 24 Jul 2018 18:45:17 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue006 [212.227.15.129]) with ESMTPA (Nemesis) id 0M6c40-1fu61m1O20-00wZ4X; Tue, 24 Jul 2018 23:36:34 +0200 From: Arnd Bergmann To: dalias@libc.org Cc: ysato@users.sourceforge.jp, baolin.wang@linaro.org, y2038@lists.linaro.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH v2 2/4] sh: sh03: rtc: push down rtc class ops into driver Date: Tue, 24 Jul 2018 23:36:22 +0200 Message-Id: <20180724213624.3899336-2-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180724213624.3899336-1-arnd@arndb.de> References: <20180724213624.3899336-1-arnd@arndb.de> X-Provags-ID: V03:K1:h963X9dmY9XTY2HqhC8hVhLcssisxD3pNLw3/Z1KnrlUy2xfwqf /81GD4arejQ3ih11VUinqWphDhbcZGv3LE7NVdsPo5XXsaAa0LEjtSeeWbl7DvET6334ZeP 5w3VUW7INLYClFc7ByJ4/TJimwBljVk0/1sMFOV9LRp48WnWfinD1k32hOXVfsZ35jLZRVh b+TAqKAvWW+2HJTMh7CLw== X-UI-Out-Filterresults: notjunk:1; V01:K0:D3mAgpKTJCs=:6W0Q2F/TtPgUr8aWgYXJtW x1wfxvql6U1wwsmiZwNpIWeAA7Z41u/ajSoK09E4A8FEj1X0qouXLF53PDVadF722lr2XGMMH 8mcT7TPx1o2H0uoEnEDBSC2523OaeneF80lexQEcDGL2qt60m90FqKRE6y2hJthKtV0j5QSWS QygE4nLjRRE/ja0w9dWqGtTp9F9R+PY9GfxAK0TFi/eAYZZbaombCSk9yU3dBljh911bHbd+q 4QuP0QzXys0zxjdzfrfND4dZv7z9cYkZAhlfnT2lgv9TYsDM7Y/WoYoaKx+QRGlzcKyQszUR7 6sTgWM9XzVJXcIn5SjDhM0mAsSp3g2EDY+7pGRp1m1+i0OWywVdxgXRgwnmzpbz9eFO3bQx7O kpgc5xZBS8+nzMMTbQt/N+aN7N/+h8S4ebtbb3tLgJRqJhR3qqiQBI6lfF7g6kGmRXsn1sjHq GdgCMdNVC0JA1wFmaKRBNXAy8Kmpgn+ol2lF0+rR/YGmtmW0IBcO87qMYla8A2PkmoudGKIfY 0DCrsw8Vm8u6nicDgVra6oMxa6oQxDHQJ7oR20gbeSkgOCqGr5J2WqCz0V6PGdDn0395wMdfI dE1NPeTEx592vfdu89chIwSfgwIJWuHegp+vqcYzJD/cDcEtqYwZUvPaOyv4RkT32DeUBKZr+ OdW03SponwZg3RLrRbvcuvJyzTgomO1cITKRbIIvrFXLG8FbomexUptJ5NJ/TabFdkew= 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.18.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 Tue Jul 24 21:36:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142830 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp65180ljj; Tue, 24 Jul 2018 14:36:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpczDU5VZiDRUmz/ROVVCL04e3/j+chLHDOJ97gMzEWj/ehNXjEKDY+ZLg+Jj8gHYpVt3dAZ X-Received: by 2002:a62:e106:: with SMTP id q6-v6mr19542255pfh.75.1532468215411; Tue, 24 Jul 2018 14:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532468215; cv=none; d=google.com; s=arc-20160816; b=hpkBHsFsXY3LV7gacEmow/E5Pgz64JVXw4CP5ShMtI/p/j/i1UzvgUznMTQwVVFEgr 3ClpoSVBjcsB0wGmV2oIhzpYWiNingx4YeGKB+xyYtNVVkCixdSPQiF9c4NUaPZu45BZ qgvjGiov2HhUtrjov4iyuQFLNcAxw0J9X5kAjBCyGSQOav7VcefD07D5ZpH6RQLzkLnl WHi9lvs5XkewC+NQGmn+26fvxebmv7VDkMojc0ugY034AJWhzxdgJt55lzi75/gPo0Ld x6dBMx91M24ZN0s36KqE7NaxdrltA1YbpswpJv+fdeKPynui16vijOXsHUw01xfPJ9JH nHdg== 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=zqvHEMytYhUEIaB0p8C+ZVDsQEV8RXY9eqvEpnkC3bE=; b=CDy5bUXXEKwWqdncPsH4z+biY265+2oNgapmWFsiBph9lKAdmZj9FDZrtjJRyhYYUf 1wAJKidF3zcvcFgsWiULiQnRdHIyNQBmkecXi7FfBj7gW+fVF2s1gSmAAQznXr8KHIdd iWNVYYDU/yIFPjdiO2JjIcoz0iUDODamuHhLBcgbzxbHaQjQpjRMOQYjnwGo3MdHolyV AZQaJjvhrr2oifJ2HvbKaZIAOhrXf57cT32183S7D3/RbZP4qotbRM93gg1hFITvUArd cqlQ2gFlbs4PqQYudqEr/V2ShMonoE4RmgfVtLIiFspLKJxu2FKReyg1X/MMSQiMBbSu F6JA== 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 p65-v6si12654050pga.401.2018.07.24.14.36.55; Tue, 24 Jul 2018 14:36:55 -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 S2388721AbeGXWpR (ORCPT + 31 others); Tue, 24 Jul 2018 18:45:17 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:36132 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727453AbeGXWpR (ORCPT ); Tue, 24 Jul 2018 18:45:17 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue006 [212.227.15.129]) with ESMTPA (Nemesis) id 0MgDvl-1fKlD52hBF-00NVMy; Tue, 24 Jul 2018 23:36:34 +0200 From: Arnd Bergmann To: dalias@libc.org Cc: ysato@users.sourceforge.jp, baolin.wang@linaro.org, y2038@lists.linaro.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH v2 3/4] sh: remove unused rtc_sh_get/set_time infrastructure Date: Tue, 24 Jul 2018 23:36:23 +0200 Message-Id: <20180724213624.3899336-3-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180724213624.3899336-1-arnd@arndb.de> References: <20180724213624.3899336-1-arnd@arndb.de> X-Provags-ID: V03:K1:U1Qrjj1bkxg0qF4o5IC8qmsI3joJaEm+yz4arZrc83Qq402sChO TuyW69VJb102RT0/BB13urqwiQkhI1cD4cM7GC9IxZaUEYO9PQ41tivMFlbfALICIELImAy 3dj5lSRuG9CJsO0T8qzSHrB1maMFUCHcbEFGpJCEVw3V/cbnjZADRq5xq6KKgCE6eWBsl9m dzklb5DVhoFBRJPwR5+Zw== X-UI-Out-Filterresults: notjunk:1; V01:K0:LmUWx6R57Z8=:E8k7JeGgQCLaJB5o8Etzif 3WGRy5abn8W1tu4EqaAFXrwmIvnkDWKmz4T0h+AeMNzblegzflllLxVxfnhdb0jh0qJFXVKr9 QuRukRMbBsvlYHzze9hmm+XvBQDz3p7mJ5h6IHk4651BBzATqoZvXnI5aXlzvJa7oO8vvsojt yQ/8S7+HgnEKGJ2f032gU3nfBExTnSBYB/P3DOBTsWdWdIl7tvJX1HAwywrVLfi9Xfrn4AxQO LN8Ahi5H9zQ8XvbZb0c9FCmIvV4+V9nDh3nzMN1xaNXNwielmm1vIMcZn/SH/r/ZkAI6Rt4pb T7ku/lAwcTJ9f8qm/ujee0yrXzSSQj6p1dwuOlNca64HOdgdYGpbqi6e/Ol7OCQBDKesEGEbM L0hh04kcDg59BcnlANw/mu64IMXqV9BvoYeMLvwl/8mny4d4tAfxEwPtGAJNG+Vo1DgkcANAm XNmbkgrAG8+qQvR2nPZQH0YP8J718Zn10Z1Ht/vFRx0wd4n1eR+pw4kJr0Abam5lFJ/B9il78 N09uZ/NL4YH40pU3haBDyuoEPLfuOaydjcxYap18jhLemhZl7YD2t0IUxPmscMYLvYWBKjeQ3 VCNyhS1iJeA7nZysWYffLFHPYZ6hyINwTCnKBufKeDwYuQVKIOf1tbzrO9SctWlcNRhnaJkpC qsToOxZ9Wn5NQ9CaK36rxBJWQhKSDLngsQCqACB5cDy9+aBiXHJbNAuDUfki4if+CsHo= 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.18.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 Tue Jul 24 21:36:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142833 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp65400ljj; Tue, 24 Jul 2018 14:37:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcWCNXG92Q/FcMRd92lxfffrj8jAdxiYd50gf8aJxcCtgbv8pHxK8RE+ufxyxXmONIXuXPb X-Received: by 2002:a63:6004:: with SMTP id u4-v6mr17803630pgb.441.1532468230144; Tue, 24 Jul 2018 14:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532468230; cv=none; d=google.com; s=arc-20160816; b=tOHLx1lkk6/G/6VVSVSxfnB0bziF6kycf8MpIXtneZGSXBtINZsUU3EH08bPyGSCG/ gSg0m1JjS3n6wXJ3WncNmkJcLBZNvkQ7JoEWkRhLsHDdzx5A1Sq+71Ua/rmsF2Rxk1F8 m8ZJLce+ZfO44rSXO08M5rNRKvptuaGJy9l59cv7tXFG9WXX7PCrPC0Ug5UngTKDfSuD tGIryRfeL2HJ/T196XOwXxiAQujl0DJC6hhVIBuzBW3pztHF5c3hpb/ae9MpGn9Zi2pq c16WMZSnrj1yz5ZSQNOsJy0YpCwHYLk8CUESbRAZGBO3pNvubbUED244YvIQ2VWuqoyg DNbw== 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=iFGrG2zKeV2/0tbporOfWcKIfSrSYd4/0zo5fdGCGpE=; b=UhDR+TS8ebN3Riz7dYOeJt6YO2HIBEWsD96V2DRwatHEPR/SZKF3Jme6PHgvMMit1N fz3RAH5KfIiY6z7Iv12d3dH6MwhE3naIOVPETXTjFR5ILSQ3MDGaVty80Jaespc5Vbel FZvJvjSitekFUXW3juAXyxu4eqtI7gUWJ9DxqXHXZwWTsi8HG4N8ZT6HgZi3+m0FgSmB MeCnsN+fdkxjwQjoAUqXJvYuN/8tlORf3HFfWhv6kAwEiwYa5fi8GS2IT+daq1A5WQEj gyEM39DwzvNjZN5ZLBr9gV0VdGxAmP4x2yucgpUbUx+Tpsxx51i7NOunH4FtHMP0ukQk Y/MA== 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 y5-v6si11723429pgc.493.2018.07.24.14.37.09; Tue, 24 Jul 2018 14:37:10 -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 S1727985AbeGXWpR (ORCPT + 31 others); Tue, 24 Jul 2018 18:45:17 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:50214 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727353AbeGXWpR (ORCPT ); Tue, 24 Jul 2018 18:45:17 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue006 [212.227.15.129]) with ESMTPA (Nemesis) id 0LaNXn-1gQExR41BX-00mGC6; Tue, 24 Jul 2018 23:36:35 +0200 From: Arnd Bergmann To: dalias@libc.org Cc: ysato@users.sourceforge.jp, baolin.wang@linaro.org, y2038@lists.linaro.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH v2 4/4] sh: remove board_time_init() callback Date: Tue, 24 Jul 2018 23:36:24 +0200 Message-Id: <20180724213624.3899336-4-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180724213624.3899336-1-arnd@arndb.de> References: <20180724213624.3899336-1-arnd@arndb.de> X-Provags-ID: V03:K1:ZIgKU6i9R1fUvipMJQ5XnC7WK7Kl7pHPhsRQgqorIIQraZm0/xW si+aR951mBzu8QwQg0Ljmmav1LriJa9x6ZaoFJTixhiZdRKEUNfviZ1+0TaM+XvOHU3jat/ ILB1740/tuT8v7ISq5RajA8Z7xD4xG6eLhtt9IMhUa/d0oWJkNvcBCWOB9cuQoEXqJgpQhq 9OmabJJGWUbSGHmCicXWA== X-UI-Out-Filterresults: notjunk:1; V01:K0:FOwVERHe538=:hha4BmIKFU6ccpw912TdQz cbJ+tA4AizkZqJ0ODpqiSR95yOL1QJdsE5uql7nRe4nacR5slhhPFch+W7U2ZEP6kOEwGr3Er cW2FnP5woxm3yYnTWAqAmtjLhKuYKtTJlLBKZ1OoDiOhIeO7ULcCLa+JhyGhcLQGBHyX9LPa4 QF79HOZ0XFPONs/KDcPnXc3J71IvGEJ1O3lq3B5YwETZ87/SiTc6GUfVujd9MsANP+PoiQgng nP/yo4LYkytzu2uKxFIvRw9raKLQdShYBlNsBQnnbHpYun5h6p43vGQUXBhkcMDyLLmtFZGYa t92cvST3wcO7jGe8nxXUaAsS2JMxIE4adqsNU9WsTryjC3hcWxLq8N6LzKAFwcBX16j1aK71Y W2yHT117+hfQkpCw+iH14jRtUlYGEtEazbdmUmpydNc1Ozr1Z2exTuV1G+ywUVXKf/DqM7YYT ENhWsXpnkkRe8Z47TNRdwhQhLiwoiRxb4xw8cjFECoi53kdCVI2X4giOoY83D6mqvj0SKfjrg V3x7Pz9Q46EDzrBLi6Lk/mZAP8dJP3wMYpfH7466tAJAbvzSRWtKpyF4HgU7YXaME2XuvU2dK gUisS1UxFZDLAd7TWg02vUREeqWgHWU/alG6K+ZsFCrxJTz9WYg6bOewaJFWeNMRP06QU4vub r/KZbj1nbjz34ny0IKEgbQZ4pmfwOMWmYzqTNMdxmtQ8QK3tJcyfczQu/ZciPM1aqYYc= 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 --- v2: fix a typo as pointed out by the kbuild bot --- 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.18.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 26789ad28193..04d9a666f924 100644 --- a/arch/sh/boards/of-generic.c +++ b/arch/sh/boards/of-generic.c @@ -117,18 +117,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..8a1c6c8ab4ec 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_probe(); clk_init();