From patchwork Mon Jun 18 14:05:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 138950 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3997169lji; Mon, 18 Jun 2018 07:07:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKqPP6Xixwu5Pu3LYHK7eiYzF3eWND6tWgEjh5VVqBJjliPyjtYGkepe2tIf8/xj3RrPP0l X-Received: by 2002:a63:778b:: with SMTP id s133-v6mr10896887pgc.400.1529330833223; Mon, 18 Jun 2018 07:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529330833; cv=none; d=google.com; s=arc-20160816; b=jnecLx3OM0flKBoAzhG7VVGhHXHUrm3VfpOOAYdOJTYBEn1pLYtznt3jRgOzGFSJwv oB7ZbDtyZ7mIMlbsyTl86MyT3dAP+D8rVwjuEE42OWJ2M54p7szwZksFA+tZWM57ssDZ lKYxVfyc0Uvga9lpiem0DUtfUILFjuU2obnRAOrIURoqLro70afHd7dhAubW3RhcSZjE 7hBRgNsCy3iEyyrlqFGrSDECDuu3LyE2resi9pqGy2HKYo+Uqsjl9IMWienCfLo/KGEV JTJ8HRHGzgSWoLSF83ew7zcdb2lXnjgT6Zq2UMwkSWsBcTugQY898LjyMBlhH6vVbihs 0lIQ== 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=H0zPgmokE0PO6kzILqbM0IvUfjD7eD1/G3DIPyR+UX8=; b=UihE7ssKyIenohF9BDyXyywfsQOE6tqiukHGkgZxCvb5h9Zl5p2AGrJNmGEB1VuYIv VN8Ldh0DowMrobIK42rSVTlyuMpz/G+lETE6aOGOClV8FC5X0tWAOep0kAe/UEx1/K+r NBYcZUmD8+b89COgUUhggjKD1S5qC/ce/I46E48afB3BKlTRd58JEIolD1bZckJh1S21 JDDDFPJKkyvXaoJTOo+1F/HeGMIju9fQpVKy+H01h+JXtSc9GmvJ5XWZ+tE6OdS3LIWc oXK18OFCDIFKzJfcfcJB3kmAb5CG73aH69WOUx+XVOGfZh4OxKybxvJTWYSEH4TZfMbO zfwA== 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 g17-v6si14607043plo.355.2018.06.18.07.07.12; Mon, 18 Jun 2018 07:07: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 S934657AbeFROHL (ORCPT + 30 others); Mon, 18 Jun 2018 10:07:11 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:50317 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932860AbeFROHH (ORCPT ); Mon, 18 Jun 2018 10:07:07 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0MfDvq-1fsbnv22xO-00OkyB; Mon, 18 Jun 2018 16:05:37 +0200 From: Arnd Bergmann To: Paul Mackerras , Michael Ellerman , Geert Uytterhoeven , Joshua Thompson Cc: Mathieu Malaterre , Benjamin Herrenschmidt , Greg Ungerer , linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, Meelis Roos , Arnd Bergmann Subject: [PATCH 1/3] powerpc: mac: fix rtc read functions Date: Mon, 18 Jun 2018 16:05:16 +0200 Message-Id: <20180618140518.2920804-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:qw0DyR+gpzEw843/ptQGa6wwShb3h3BNudQco/SiKzF5yUUk/IY qLziZsVSYqGEmXJhRnsl+nqnUSUXsPoJhZuK7yspQcug116WrWM5y1EHSKdSKC0aNmcr0UR tD5srfzkiG86sOFeQQnmXsscuB7Wi28ZopYvaISyXZJxxOLLvGkATk7F8eowWB+MHuf4j+x xaboq2b4YaX6JCbXeRKMw== X-UI-Out-Filterresults: notjunk:1; V01:K0:d1MntMH0Q9U=:LGB6oG6CgQZPSS4MEd5lMO doL8NURgPUXBDkYnarAjASTHF5fiFbYKxQFQFVUuuOzRWBPoFbCGrQNKmQmMiYZ03xje467QH sStwLQ1Uiv+NF0fJI/v4a2lZ/9WwtUGoqso25LN/aHdews4+9AOjrjeB2EZDDM2h4m/Jahi5p 770MVfGIjwvgpLG50HfBqprm0yzrcV69jyIiaKrkGP7Lm1BCOLHcEbr+IXSuHHuo5AyKIGKgk 9sITAvLijPcvHxvksNAc4LPwH4iKQZN7Rx3oUCsBSCrvzKx+gsJYOiNQqzWUNBuHgLb44+vK5 nHJfEOtooeORShp7n2JWapfvT2U8AXdrF6CS4elvY8tYK8apjT83i2VBSV2dXOlht9W1kVpQY 5GtGDEJPk6TVNBUIrK000UQSoCNA+mj3l9ghoIlG6YEBh2EvBLgblAHMSrE0Ra+pOeLCkbTTr +F+rle0/PdogRL0mZG1ncgl28pc0gHGctTsCZYHkLjTv7R0iGhTc6VuoJdunOoe3zBydOY3L5 cvMdjzMogwRZOzTepY8iULGNXUcZHgyMmSvhawNERojkeawk1L/e5LQcKwsrwy5OK6g+Hn6aL +u/fYtTyxCiszjCJEchTJNcdiFWU+QKffFMhx9vJsZtsNI/Q8wfAQJy+5v8Yqym6QJQuRe9iq /cOo4D5t4YpW/68S7knD0Y6ji11qDQ8URgUsi1h1bYjEo43jpcOoh1VRxbN8YOwMHWJE= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As Mathieu pointed out, my conversion to time64_t was incorrect and resulted in negative times to be read from the RTC. The problem is that during the conversion from a byte array to a time64_t, the 'unsigned char' variable holding the top byte gets turned into a negative signed 32-bit integer before being assigned to the 64-bit variable for any times after 1972. This changes the logic to cast to an unsigned 32-bit number first for the Macintosh time and then convert that to the Unix time, which then gives us a time in the documented 1904..2040 year range. I decided not to use the longer 1970..2106 range that other drivers use, for consistency with the literal interpretation of the register, but that could be easily changed if we decide we want to support any Mac after 2040. Just to be on the safe side, I'm also adding a WARN_ON that will trigger if either the year 2040 has come and is observed by this driver, or we run into an RTC that got set back to a pre-1970 date for some reason (the two are indistinguishable). The same code exists in arch/m68k/ and is patched in an identical way now in a separate patch. Fixes: 5bfd643583b2 ("powerpc: use time64_t in read_persistent_clock") Reported-by: Mathieu Malaterre Signed-off-by: Arnd Bergmann --- arch/powerpc/platforms/powermac/time.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) -- 2.9.0 diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c index 7c968e46736f..173a80630169 100644 --- a/arch/powerpc/platforms/powermac/time.c +++ b/arch/powerpc/platforms/powermac/time.c @@ -42,7 +42,11 @@ #define DBG(x...) #endif -/* Apparently the RTC stores seconds since 1 Jan 1904 */ +/* + * Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and PMU + * times wrap in 2040. If we need to handle later times, the read_time functions + * need to be changed to interpret wrapped times as post-2040. + */ #define RTC_OFFSET 2082844800 /* @@ -97,8 +101,11 @@ static time64_t cuda_get_time(void) if (req.reply_len != 7) printk(KERN_ERR "cuda_get_time: got %d byte reply\n", req.reply_len); - now = (req.reply[3] << 24) + (req.reply[4] << 16) - + (req.reply[5] << 8) + req.reply[6]; + now = (u32)((req.reply[3] << 24) + (req.reply[4] << 16) + + (req.reply[5] << 8) + req.reply[6]); + /* it's either after year 2040, or the RTC has gone backwards */ + WARN_ON(now < RTC_OFFSET); + return now - RTC_OFFSET; } @@ -140,8 +147,12 @@ static time64_t pmu_get_time(void) if (req.reply_len != 4) printk(KERN_ERR "pmu_get_time: got %d byte reply from PMU\n", req.reply_len); - now = (req.reply[0] << 24) + (req.reply[1] << 16) - + (req.reply[2] << 8) + req.reply[3]; + now = (u32)((req.reply[0] << 24) + (req.reply[1] << 16) + + (req.reply[2] << 8) + req.reply[3]); + + /* it's either after year 2040, or the RTC has gone backwards */ + WARN_ON(now < RTC_OFFSET); + return now - RTC_OFFSET; } From patchwork Mon Jun 18 14:05:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 138948 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3995620lji; Mon, 18 Jun 2018 07:05:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL6obmy/ge9KfRGnv0K6NA6jjFJ4A6qDuCJVE8Nsf693WEVGMbS9gfpYTokdvxjJG51z0k3 X-Received: by 2002:a17:902:7442:: with SMTP id e2-v6mr14527619plt.28.1529330757597; Mon, 18 Jun 2018 07:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529330757; cv=none; d=google.com; s=arc-20160816; b=GiNMUQqhhj2Rk0P3P6+kVAMUDAMKRg1lyuAh4lAp8AfjF2kIHDC9hpPZz/PK5F7+RB NZPBoyO1yYqKM4gJHcalj3qQnxH06dCpmK0IQN/F5XzyctIQfRnISDkX9qbqaBg+G4Ip OBmylLDlCrngf6SJPE0lYOmQB3T3ytUZb4Nr+iGpn60pIOnmveX4Dfu09tQb0Xim0/76 tRQByaq7h1Wax7FxSyEIlaPWjDvytdF1JyAceD17inGyiXr6f+Pzadk8vYPTNMVKnQDG o30qKp2ZbO3cM+vp3dXEOtDNXwdMXWQzZp1brVTAkG2xWklF1sxfha2R2XQ2re46cNzt gXoQ== 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=NA4GXQ8ek1+4DIGaxZpfRXYSrm+oMWZPdolrJLCjN4o=; b=d8SD8ZmVKQ8peGqd1FrU/QI9//RGzlFsQQBiBXLN+HJA28zhy51oEfrWodyMnge3rR o/4kxAoWGJfBWFfwnOWoGYNfjHeAP5TjW0bYcrr07mTD6lvGMjlZtvX/uhc/8yfVEsmb VcG7DiVUWYZGayjQszEkOKXdlj7aCMmV6Ks+5CuYhHvmAW5yRN4Yu2HJ7IIyv/+Jkiqy ad5zYDfD+DE/SnOEw5LbaiVnxuV0ai2iI9K7mwg8kxL8Oua67evWg98ZdjKoTFZ4NY5Q UukUeWp0EmdNzNS6aWR/+2t7+Jp9Y8hbSVo6RvT7+FtOavvVelPeA0JV18bLUywreO8y AiKQ== 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 v5-v6si11844373pgs.15.2018.06.18.07.05.57; Mon, 18 Jun 2018 07:05:57 -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 S934109AbeFROFx (ORCPT + 30 others); Mon, 18 Jun 2018 10:05:53 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:41743 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754321AbeFROFv (ORCPT ); Mon, 18 Jun 2018 10:05:51 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0MJHCg-1fWYgN3wc6-002qPD; Mon, 18 Jun 2018 16:05:38 +0200 From: Arnd Bergmann To: Paul Mackerras , Michael Ellerman , Geert Uytterhoeven , Joshua Thompson Cc: Mathieu Malaterre , Benjamin Herrenschmidt , Greg Ungerer , linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, Meelis Roos , Arnd Bergmann Subject: [PATCH 2/3] m68k: mac: use time64_t in RTC handling Date: Mon, 18 Jun 2018 16:05:17 +0200 Message-Id: <20180618140518.2920804-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180618140518.2920804-1-arnd@arndb.de> References: <20180618140518.2920804-1-arnd@arndb.de> X-Provags-ID: V03:K1:yPAWylP334m9hyjSidjsp/4YLCfNrVCbDnobHvtjLc31kecuWTj JECzE5tDX25o/7m1pCBNHjI7eNgbckaDgUeSxZNavQff9ljLhpgvAvUyMLGWz+ab8mMwbIJ Q3IpCyNCfHFGF4Q5bD6MiVgPb+N5SpNISLS0KbruleTHPSQt9pzLQVzGmH7dDQ5kOFe9yU1 m6Aeej7RRIOW0PFj2xG5A== X-UI-Out-Filterresults: notjunk:1; V01:K0:1AW0bKD/wCQ=:rv9mdrvRlNGwF4B8FN0Ijb 2/+um6FpjgSUFpDA2wiYRrAuapepLZJ3cYNqA/qk0heuQf4VuKXOecWaXcT35KuH7Mzm9UtuI tLo9X/5MtiHCpdfeUvmwF20E+4Rre1nagM/kxGzWBY92qH9c4DCoNJDoxnHTwlYGM67hLcUUJ ooEZxjwC59zGIlJuLkUsyfvbtGYzsWelTdll6WsUHEBYOOVQIHg3ZuIuS4a68L6jyiKZVv0oc 8CBI6SMVaRk+B1yT4hQdqS1O4LMmqXFUQgz6x6nCK9tofGGdqMJmVKaGynxWAVawm4ek7ghf9 c4N+OHDdprjOczgOC+CYAnppa0qxrvfb8zSpmo5BPuPeCmLq1cZr054Cc8vrJ54qSHHQnWHLf D9aIxiHbSFiLKuTb2NZrGkO5zvKl4wtGh8CRd/kP2ikNjSNwK9A/LAKktPrvUJEKorc0HOI4k WBINp/fe459Xr/12ohgbiLxAf/hSDu/b2lTz3/Whd0ghGZfhga3xouFyEqg/iDV/a1IhHDLs+ cCpMWUYTEseifdf8qiiTDwtTI6W9E9pVpU4etnJZXTjcJr/zpEj+znhOVEBxdiDJr1qZKE431 5FD47oD+tdABnydRCKnhjMsxYbI6kaEm1ilI3PkBc8bTKcZrQ85w8kS1wReIbc7E6r1gRPaMr y/SDb8U/k0yBMASPKpNOW7NO/xLEjwa0H9QFt2Pt4p9G3r7fPFa54tvhSUmaat2ty6Ok= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The real-time clock on m68k (and powerpc) mac systems uses an unsigned 32-bit value starting in 1904, which overflows in 2040, about two years later than everyone else, but this gets wrapped around in the Linux code in 2038 already because of the deprecated usage of time_t and/or long in the conversion. Getting rid of the deprecated interfaces makes it work until 2040 as documented, and it could be easily extended by reinterpreting the resulting time64_t as a positive number. For the moment, I'm adding a WARN_ON() that triggers if we encounter a time before 1970 or after 2040 (the two are indistinguishable). This brings it in line with the corresponding code that we have on powerpc macintosh. Signed-off-by: Arnd Bergmann --- arch/m68k/mac/misc.c | 58 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 21 deletions(-) -- 2.9.0 diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c index c68054361615..b399a0809e18 100644 --- a/arch/m68k/mac/misc.c +++ b/arch/m68k/mac/misc.c @@ -26,33 +26,40 @@ #include -/* Offset between Unix time (1970-based) and Mac time (1904-based) */ +/* Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and PMU + * times wrap in 2040. If we need to handle later times, the read_time functions + * need to be changed to interpret wrapped times as post-2040. */ #define RTC_OFFSET 2082844800 static void (*rom_reset)(void); #ifdef CONFIG_ADB_CUDA -static long cuda_read_time(void) +static time64_t cuda_read_time(void) { struct adb_request req; - long time; + time64_t time; if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0) return 0; while (!req.complete) cuda_poll(); - time = (req.reply[3] << 24) | (req.reply[4] << 16) | - (req.reply[5] << 8) | req.reply[6]; + time = (u32)((req.reply[3] << 24( | (req.reply[4] << 16) | + (req.reply[5] << 8) | req.reply[6]); + + /* it's either after year 2040, or the RTC has gone backwards */ + WARN_ON(time < RTC_OFFSET); + return time - RTC_OFFSET; } -static void cuda_write_time(long data) +static void cuda_write_time(time64_t data) { struct adb_request req; data += RTC_OFFSET; + data &= 0xffffffff; if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME, (data >> 24) & 0xFF, (data >> 16) & 0xFF, (data >> 8) & 0xFF, data & 0xFF) < 0) @@ -86,26 +93,29 @@ static void cuda_write_pram(int offset, __u8 data) #endif /* CONFIG_ADB_CUDA */ #ifdef CONFIG_ADB_PMU68K -static long pmu_read_time(void) +static time64_t pmu_read_time(void) { struct adb_request req; - long time; + time64_t time; if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0) return 0; while (!req.complete) pmu_poll(); - time = (req.reply[1] << 24) | (req.reply[2] << 16) | - (req.reply[3] << 8) | req.reply[4]; + /* it's either after year 2040, or the RTC has gone backwards */ + time = (u32)((req.reply[1] << 24) | (req.reply[2] << 16) | + (req.reply[3] << 8) | req.reply[4]); + return time - RTC_OFFSET; } -static void pmu_write_time(long data) +static void pmu_write_time(time64_t data) { struct adb_request req; data += RTC_OFFSET; + data &= 0xffffffff; if (pmu_request(&req, NULL, 5, PMU_SET_RTC, (data >> 24) & 0xFF, (data >> 16) & 0xFF, (data >> 8) & 0xFF, data & 0xFF) < 0) @@ -269,8 +279,12 @@ static long via_read_time(void) via_pram_command(0x89, &result.cdata[1]); via_pram_command(0x8D, &result.cdata[0]); - if (result.idata == last_result.idata) + if (result.idata == last_result.idata) { + if (result.idata < RTC_OFFSET) + result.idata += 0x100000000ull; + return result.idata - RTC_OFFSET; + } if (++count > 10) break; @@ -291,11 +305,11 @@ static long via_read_time(void) * is basically any machine with Mac II-style ADB. */ -static void via_write_time(long time) +static void via_write_time(time64_t time) { union { __u8 cdata[4]; - long idata; + __u32 idata; } data; __u8 temp; @@ -585,12 +599,15 @@ void mac_reset(void) * This function translates seconds since 1970 into a proper date. * * Algorithm cribbed from glibc2.1, __offtime(). + * + * This is roughly same as rtc_time64_to_tm(), which we should probably + * use here, but it's only available when CONFIG_RTC_LIB is enabled. */ #define SECS_PER_MINUTE (60) #define SECS_PER_HOUR (SECS_PER_MINUTE * 60) #define SECS_PER_DAY (SECS_PER_HOUR * 24) -static void unmktime(unsigned long time, long offset, +static void unmktime(time64_t time, long offset, int *yearp, int *monp, int *dayp, int *hourp, int *minp, int *secp) { @@ -602,11 +619,10 @@ static void unmktime(unsigned long time, long offset, /* Leap years. */ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; - long int days, rem, y, wday, yday; + int days, rem, y, wday, yday; const unsigned short int *ip; - days = time / SECS_PER_DAY; - rem = time % SECS_PER_DAY; + days = div_u64_rem(time, SECS_PER_DAY, &rem); rem += offset; while (rem < 0) { rem += SECS_PER_DAY; @@ -657,7 +673,7 @@ static void unmktime(unsigned long time, long offset, int mac_hwclk(int op, struct rtc_time *t) { - unsigned long now; + time64_t now; if (!op) { /* read */ switch (macintosh_config->adb_type) { @@ -693,8 +709,8 @@ int mac_hwclk(int op, struct rtc_time *t) __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); - now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec); + now = mktime64(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); switch (macintosh_config->adb_type) { case MAC_ADB_IOP: From patchwork Mon Jun 18 14:05:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 138949 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3996117lji; Mon, 18 Jun 2018 07:06:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIfQVxrDdKYDBsV7C7n3YeudodjCMPWXC2Ns0EjXPX3JHZEtgQwVp/3a4qig8KxHV30p0ay X-Received: by 2002:a62:8a0a:: with SMTP id y10-v6mr13769755pfd.237.1529330779402; Mon, 18 Jun 2018 07:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529330779; cv=none; d=google.com; s=arc-20160816; b=cHC0lpSEBvbHJQeZ23a3/O7DHJqWtNjQqqvSlt8y8A/ECC/vZUfr+8iwhM6pqRR6w+ xRoF9AbUHOG7rkRPdI4vOL9EjZJXvPWm28q9QccnGgn8wcHz7gEVlJy7bRqKub0hyhqV FpFLIeCR+a4SXIlNI/qTHWJgWw/0G7G2XkX1Q/fG9pSk7aG1yEtcaMbbwjbSc4MJXVKF b/kqFE69KRgSMsBeL2jtHhXn8X8PoTQtPjxQwIno6k13aYSjlsh0LwWzvsckkFZjNCfm jTkGrn2AcwU5MRMVC7QEXAyLG6sPvs5wlxiDFSvwc6LyBh6iQFFb5JuyVABOdktKiOZS O1jQ== 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=oY2CZdi8Ekj4kvIEoAZKxLZs4m2eicJLoVClIP02pBA=; b=tTR5a/YoRnAyW5P6INAZgexIx7MVGCVS2yk2ws1K59vebGcURSHcdkVNjk5hm9hjvg +gyRX2r9FBEZFXn/lwcIvkXSZMnOWiIMDqzPvKR/kYQ/wxv55JvBlSfZITX2qOSahjP8 81vqDRfMSQBCDjQJLzFXmUUyvjK0Qn1/WtqlwNnHq+RphSdgTq6h6UjdVQmkpq6Xu8dR 4L0UCipxTvY6Cqi0URjrVdwxoIhrxt6+inlCOB7fVPisDyGrPvsGL9SjjEQp7DSr3hHT 9TDeWDSX5+1ai8Jp6/keIbPB6ylwsI/kefMn1mKYNqMEnm6Pb9GwkHpADqh5s+5BaVAc ARtA== 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 f6-v6si12255224pgo.508.2018.06.18.07.06.19; Mon, 18 Jun 2018 07:06:19 -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 S934367AbeFROGR (ORCPT + 30 others); Mon, 18 Jun 2018 10:06:17 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:46669 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932860AbeFROGN (ORCPT ); Mon, 18 Jun 2018 10:06:13 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0MR93L-1fe0wX1aSV-00UaXW; Mon, 18 Jun 2018 16:05:38 +0200 From: Arnd Bergmann To: Paul Mackerras , Michael Ellerman , Geert Uytterhoeven , Joshua Thompson Cc: Mathieu Malaterre , Benjamin Herrenschmidt , Greg Ungerer , linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, Meelis Roos , Arnd Bergmann Subject: [PATCH 3/3] m68k: remove unused set_clock_mmss() helpers Date: Mon, 18 Jun 2018 16:05:18 +0200 Message-Id: <20180618140518.2920804-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180618140518.2920804-1-arnd@arndb.de> References: <20180618140518.2920804-1-arnd@arndb.de> X-Provags-ID: V03:K1:vfQQOaKe2n3mqDFre05WwoY3JCmb16m7u8GZoQfNBALTs/gxdze DmKP9O/UwiSUwR+y3blza0WdpXkZiLz8hKjMV6ZJrN0st+e6J4uV9elz8pdBuQYM08JLenc u4yGLMOk4zStqLkz2lzoEszEGkWnwfqlVzg3yGIIpj9XWGMz1b0UbpJG0UaVUBbDJB7bs3X lGiD0pN5VInPIs0fPYeYA== X-UI-Out-Filterresults: notjunk:1; V01:K0:chP0QgW4P0Q=:hLpWY7mPVAw4xRzV2BvuGE +BMaQoiP9qlNBF6yV7NrFUqcXsienrnncW1ZZNht4izoVMX4gGouAxg9n7cc9h/lUy9+5i5GD pGCxq0903Wzzmk1DYHC7pVdzlox5ntT8qYRszYeSTu/S5hqPDhczbKt2EIalhlHxzuy6fjGEs MD96PXv0UFbDLmNRW5Wo7w7rr4s1fGF7FymNhsA5NIbPkTnL3LLsiuXqycDkpqZSDXSUkJf52 tv39uKLkM+1dInrTjaHPw/Xliya7LEYofuRxqiDsyDp0EQnMtpn/64nS5GQ9tbb8Haxop067t 8B3uaN5OsxyGXta7WnTBWxGk9njBTgf493qCPQippzZ7ce/iuXIfkoAV2ENC//t7AqtF8C9CI z2ZaoaePqlwdb74onyymdji6GwYy//XHMeIg+QLz3+TeEtSE4Ng4LyA0TdWJCPbSky/1hEi8F TrGJsR9DFikadJb1/cTikFBnQhe1AVuhrhwJ2lzSj5G9wm+5XdhoI/7+FNsz5bC31cKP3j0bH rGOSN7+w1kh26a1yHkLjlrRs0+QMv3cb7/zpL6k41GNfA2BAp7dX67QjD0tkGDVbo172yZUIW qWiN2vjnaCVHKDJ0HvWxv2xVhw3RaahrHPOP0TT6KT8HlF1bkCSHTWcPApWjoI5CcFJBQpQ0Y +U74GBUjquRcgI3pBETFblhCAfP3TGg7gWug7AbzqhKPVhMmIOkBkdp6HEMlfVlHo2M8= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 397ac99c6cef ("m68k: remove dead timer code") removed set_rtc_mmss() because it was unused in 2012. However, this was itself the only user of the mach_set_clock_mmss() callback and the many implementations of that callback, which are equally unused. This removes all of those as well. Signed-off-by: Arnd Bergmann --- arch/m68k/apollo/config.c | 8 ------ arch/m68k/atari/config.c | 5 ---- arch/m68k/atari/time.c | 63 ----------------------------------------- arch/m68k/bvme6000/config.c | 45 ----------------------------- arch/m68k/include/asm/machdep.h | 1 - arch/m68k/kernel/setup_mm.c | 1 - arch/m68k/kernel/setup_no.c | 1 - arch/m68k/mac/config.c | 2 -- arch/m68k/mac/misc.c | 16 ----------- arch/m68k/mvme147/config.c | 7 ----- arch/m68k/mvme16x/config.c | 8 ------ arch/m68k/q40/config.c | 30 -------------------- 12 files changed, 187 deletions(-) -- 2.9.0 Acked-by: Greg Ungerer diff --git a/arch/m68k/apollo/config.c b/arch/m68k/apollo/config.c index b2a6bc63f8cd..aef8d42e078d 100644 --- a/arch/m68k/apollo/config.c +++ b/arch/m68k/apollo/config.c @@ -31,7 +31,6 @@ extern void dn_sched_init(irq_handler_t handler); extern void dn_init_IRQ(void); extern u32 dn_gettimeoffset(void); extern int dn_dummy_hwclk(int, struct rtc_time *); -extern int dn_dummy_set_clock_mmss(unsigned long); extern void dn_dummy_reset(void); #ifdef CONFIG_HEARTBEAT static void dn_heartbeat(int on); @@ -156,7 +155,6 @@ void __init config_apollo(void) arch_gettimeoffset = dn_gettimeoffset; mach_max_dma_address = 0xffffffff; mach_hwclk = dn_dummy_hwclk; /* */ - mach_set_clock_mmss = dn_dummy_set_clock_mmss; /* */ mach_reset = dn_dummy_reset; /* */ #ifdef CONFIG_HEARTBEAT mach_heartbeat = dn_heartbeat; @@ -240,12 +238,6 @@ int dn_dummy_hwclk(int op, struct rtc_time *t) { } -int dn_dummy_set_clock_mmss(unsigned long nowtime) -{ - pr_info("set_clock_mmss\n"); - return 0; -} - void dn_dummy_reset(void) { dn_serial_print("The end !\n"); diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c index 565c6f06ab0b..bd96702a1ad0 100644 --- a/arch/m68k/atari/config.c +++ b/arch/m68k/atari/config.c @@ -81,9 +81,6 @@ extern void atari_sched_init(irq_handler_t); extern u32 atari_gettimeoffset(void); extern int atari_mste_hwclk (int, struct rtc_time *); extern int atari_tt_hwclk (int, struct rtc_time *); -extern int atari_mste_set_clock_mmss (unsigned long); -extern int atari_tt_set_clock_mmss (unsigned long); - /* ++roman: This is a more elaborate test for an SCC chip, since the plain * Medusa board generates DTACK at the SCC's standard addresses, but a SCC @@ -362,13 +359,11 @@ void __init config_atari(void) ATARIHW_SET(TT_CLK); pr_cont(" TT_CLK"); mach_hwclk = atari_tt_hwclk; - mach_set_clock_mmss = atari_tt_set_clock_mmss; } if (hwreg_present(&mste_rtc.sec_ones)) { ATARIHW_SET(MSTE_CLK); pr_cont(" MSTE_CLK"); mach_hwclk = atari_mste_hwclk; - mach_set_clock_mmss = atari_mste_set_clock_mmss; } if (!MACH_IS_MEDUSA && hwreg_present(&dma_wd.fdc_speed) && hwreg_write(&dma_wd.fdc_speed, 0)) { diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c index c549b48174ec..9cca64286464 100644 --- a/arch/m68k/atari/time.c +++ b/arch/m68k/atari/time.c @@ -285,69 +285,6 @@ int atari_tt_hwclk( int op, struct rtc_time *t ) return( 0 ); } - -int atari_mste_set_clock_mmss (unsigned long nowtime) -{ - short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; - struct MSTE_RTC val; - unsigned char rtc_minutes; - - mste_read(&val); - rtc_minutes= val.min_ones + val.min_tens * 10; - if ((rtc_minutes < real_minutes - ? real_minutes - rtc_minutes - : rtc_minutes - real_minutes) < 30) - { - val.sec_ones = real_seconds % 10; - val.sec_tens = real_seconds / 10; - val.min_ones = real_minutes % 10; - val.min_tens = real_minutes / 10; - mste_write(&val); - } - else - return -1; - return 0; -} - -int atari_tt_set_clock_mmss (unsigned long nowtime) -{ - int retval = 0; - short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; - unsigned char save_control, save_freq_select, rtc_minutes; - - save_control = RTC_READ (RTC_CONTROL); /* tell the clock it's being set */ - RTC_WRITE (RTC_CONTROL, save_control | RTC_SET); - - save_freq_select = RTC_READ (RTC_FREQ_SELECT); /* stop and reset prescaler */ - RTC_WRITE (RTC_FREQ_SELECT, save_freq_select | RTC_DIV_RESET2); - - rtc_minutes = RTC_READ (RTC_MINUTES); - if (!(save_control & RTC_DM_BINARY)) - rtc_minutes = bcd2bin(rtc_minutes); - - /* Since we're only adjusting minutes and seconds, don't interfere - with hour overflow. This avoids messing with unknown time zones - but requires your RTC not to be off by more than 30 minutes. */ - if ((rtc_minutes < real_minutes - ? real_minutes - rtc_minutes - : rtc_minutes - real_minutes) < 30) - { - if (!(save_control & RTC_DM_BINARY)) - { - real_seconds = bin2bcd(real_seconds); - real_minutes = bin2bcd(real_minutes); - } - RTC_WRITE (RTC_SECONDS, real_seconds); - RTC_WRITE (RTC_MINUTES, real_minutes); - } - else - retval = -1; - - RTC_WRITE (RTC_FREQ_SELECT, save_freq_select); - RTC_WRITE (RTC_CONTROL, save_control); - return retval; -} - /* * Local variables: * c-indent-level: 4 diff --git a/arch/m68k/bvme6000/config.c b/arch/m68k/bvme6000/config.c index 2cfff4765040..143ee9fa3893 100644 --- a/arch/m68k/bvme6000/config.c +++ b/arch/m68k/bvme6000/config.c @@ -41,7 +41,6 @@ static void bvme6000_get_model(char *model); extern void bvme6000_sched_init(irq_handler_t handler); extern u32 bvme6000_gettimeoffset(void); extern int bvme6000_hwclk (int, struct rtc_time *); -extern int bvme6000_set_clock_mmss (unsigned long); extern void bvme6000_reset (void); void bvme6000_set_vectors (void); @@ -113,7 +112,6 @@ void __init config_bvme6000(void) mach_init_IRQ = bvme6000_init_IRQ; arch_gettimeoffset = bvme6000_gettimeoffset; mach_hwclk = bvme6000_hwclk; - mach_set_clock_mmss = bvme6000_set_clock_mmss; mach_reset = bvme6000_reset; mach_get_model = bvme6000_get_model; @@ -305,46 +303,3 @@ int bvme6000_hwclk(int op, struct rtc_time *t) return 0; } - -/* - * Set the minutes and seconds from seconds value 'nowtime'. Fail if - * clock is out by > 30 minutes. Logic lifted from atari code. - * Algorithm is to wait for the 10ms register to change, and then to - * wait a short while, and then set it. - */ - -int bvme6000_set_clock_mmss (unsigned long nowtime) -{ - int retval = 0; - short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; - unsigned char rtc_minutes, rtc_tenms; - volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE; - unsigned char msr = rtc->msr & 0xc0; - unsigned long flags; - volatile int i; - - rtc->msr = 0; /* Ensure clock accessible */ - rtc_minutes = bcd2bin (rtc->bcd_min); - - if ((rtc_minutes < real_minutes - ? real_minutes - rtc_minutes - : rtc_minutes - real_minutes) < 30) - { - local_irq_save(flags); - rtc_tenms = rtc->bcd_tenms; - while (rtc_tenms == rtc->bcd_tenms) - ; - for (i = 0; i < 1000; i++) - ; - rtc->bcd_min = bin2bcd(real_minutes); - rtc->bcd_sec = bin2bcd(real_seconds); - local_irq_restore(flags); - } - else - retval = -1; - - rtc->msr = msr; - - return retval; -} - diff --git a/arch/m68k/include/asm/machdep.h b/arch/m68k/include/asm/machdep.h index 1605da48ebf2..49bd3266b4b1 100644 --- a/arch/m68k/include/asm/machdep.h +++ b/arch/m68k/include/asm/machdep.h @@ -22,7 +22,6 @@ extern int (*mach_hwclk)(int, struct rtc_time*); extern unsigned int (*mach_get_ss)(void); extern int (*mach_get_rtc_pll)(struct rtc_pll_info *); extern int (*mach_set_rtc_pll)(struct rtc_pll_info *); -extern int (*mach_set_clock_mmss)(unsigned long); extern void (*mach_reset)( void ); extern void (*mach_halt)( void ); extern void (*mach_power_off)( void ); diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c index f35e3ebd6331..07244732eb41 100644 --- a/arch/m68k/kernel/setup_mm.c +++ b/arch/m68k/kernel/setup_mm.c @@ -88,7 +88,6 @@ void (*mach_get_hardware_list) (struct seq_file *m); /* machine dependent timer functions */ int (*mach_hwclk) (int, struct rtc_time*); EXPORT_SYMBOL(mach_hwclk); -int (*mach_set_clock_mmss) (unsigned long); unsigned int (*mach_get_ss)(void); int (*mach_get_rtc_pll)(struct rtc_pll_info *); int (*mach_set_rtc_pll)(struct rtc_pll_info *); diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c index a98af1018201..3c53e4c366ac 100644 --- a/arch/m68k/kernel/setup_no.c +++ b/arch/m68k/kernel/setup_no.c @@ -51,7 +51,6 @@ char __initdata command_line[COMMAND_LINE_SIZE]; /* machine dependent timer functions */ void (*mach_sched_init)(irq_handler_t handler) __initdata = NULL; -int (*mach_set_clock_mmss)(unsigned long); int (*mach_hwclk) (int, struct rtc_time*); /* machine dependent reboot functions */ diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index e522307db47c..da1aeb966474 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -57,7 +57,6 @@ static unsigned long mac_orig_videoaddr; /* Mac specific timer functions */ extern u32 mac_gettimeoffset(void); extern int mac_hwclk(int, struct rtc_time *); -extern int mac_set_clock_mmss(unsigned long); extern void iop_preinit(void); extern void iop_init(void); extern void via_init(void); @@ -158,7 +157,6 @@ void __init config_mac(void) mach_get_model = mac_get_model; arch_gettimeoffset = mac_gettimeoffset; mach_hwclk = mac_hwclk; - mach_set_clock_mmss = mac_set_clock_mmss; mach_reset = mac_reset; mach_halt = mac_poweroff; mach_power_off = mac_poweroff; diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c index b399a0809e18..b0dda5cb9e48 100644 --- a/arch/m68k/mac/misc.c +++ b/arch/m68k/mac/misc.c @@ -735,19 +735,3 @@ int mac_hwclk(int op, struct rtc_time *t) } return 0; } - -/* - * Set minutes/seconds in the hardware clock - */ - -int mac_set_clock_mmss (unsigned long nowtime) -{ - struct rtc_time now; - - mac_hwclk(0, &now); - now.tm_sec = nowtime % 60; - now.tm_min = (nowtime / 60) % 60; - mac_hwclk(1, &now); - - return 0; -} diff --git a/arch/m68k/mvme147/config.c b/arch/m68k/mvme147/config.c index f8a710fd84cd..adea549d240e 100644 --- a/arch/m68k/mvme147/config.c +++ b/arch/m68k/mvme147/config.c @@ -40,7 +40,6 @@ static void mvme147_get_model(char *model); extern void mvme147_sched_init(irq_handler_t handler); extern u32 mvme147_gettimeoffset(void); extern int mvme147_hwclk (int, struct rtc_time *); -extern int mvme147_set_clock_mmss (unsigned long); extern void mvme147_reset (void); @@ -92,7 +91,6 @@ void __init config_mvme147(void) mach_init_IRQ = mvme147_init_IRQ; arch_gettimeoffset = mvme147_gettimeoffset; mach_hwclk = mvme147_hwclk; - mach_set_clock_mmss = mvme147_set_clock_mmss; mach_reset = mvme147_reset; mach_get_model = mvme147_get_model; @@ -164,8 +162,3 @@ int mvme147_hwclk(int op, struct rtc_time *t) } return 0; } - -int mvme147_set_clock_mmss (unsigned long nowtime) -{ - return 0; -} diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c index 4ffd9ef98de4..6ee36a5b528d 100644 --- a/arch/m68k/mvme16x/config.c +++ b/arch/m68k/mvme16x/config.c @@ -46,7 +46,6 @@ static void mvme16x_get_model(char *model); extern void mvme16x_sched_init(irq_handler_t handler); extern u32 mvme16x_gettimeoffset(void); extern int mvme16x_hwclk (int, struct rtc_time *); -extern int mvme16x_set_clock_mmss (unsigned long); extern void mvme16x_reset (void); int bcd2int (unsigned char b); @@ -280,7 +279,6 @@ void __init config_mvme16x(void) mach_init_IRQ = mvme16x_init_IRQ; arch_gettimeoffset = mvme16x_gettimeoffset; mach_hwclk = mvme16x_hwclk; - mach_set_clock_mmss = mvme16x_set_clock_mmss; mach_reset = mvme16x_reset; mach_get_model = mvme16x_get_model; mach_get_hardware_list = mvme16x_get_hardware_list; @@ -411,9 +409,3 @@ int mvme16x_hwclk(int op, struct rtc_time *t) } return 0; } - -int mvme16x_set_clock_mmss (unsigned long nowtime) -{ - return 0; -} - diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c index 71c0867ecf20..96810d91da2b 100644 --- a/arch/m68k/q40/config.c +++ b/arch/m68k/q40/config.c @@ -43,7 +43,6 @@ extern void q40_sched_init(irq_handler_t handler); static u32 q40_gettimeoffset(void); static int q40_hwclk(int, struct rtc_time *); static unsigned int q40_get_ss(void); -static int q40_set_clock_mmss(unsigned long); static int q40_get_rtc_pll(struct rtc_pll_info *pll); static int q40_set_rtc_pll(struct rtc_pll_info *pll); @@ -175,7 +174,6 @@ void __init config_q40(void) mach_get_ss = q40_get_ss; mach_get_rtc_pll = q40_get_rtc_pll; mach_set_rtc_pll = q40_set_rtc_pll; - mach_set_clock_mmss = q40_set_clock_mmss; mach_reset = q40_reset; mach_get_model = q40_get_model; @@ -267,34 +265,6 @@ static unsigned int q40_get_ss(void) return bcd2bin(Q40_RTC_SECS); } -/* - * Set the minutes and seconds from seconds value 'nowtime'. Fail if - * clock is out by > 30 minutes. Logic lifted from atari code. - */ - -static int q40_set_clock_mmss(unsigned long nowtime) -{ - int retval = 0; - short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; - - int rtc_minutes; - - rtc_minutes = bcd2bin(Q40_RTC_MINS); - - if ((rtc_minutes < real_minutes ? - real_minutes - rtc_minutes : - rtc_minutes - real_minutes) < 30) { - Q40_RTC_CTRL |= Q40_RTC_WRITE; - Q40_RTC_MINS = bin2bcd(real_minutes); - Q40_RTC_SECS = bin2bcd(real_seconds); - Q40_RTC_CTRL &= ~(Q40_RTC_WRITE); - } else - retval = -1; - - return retval; -} - - /* get and set PLL calibration of RTC clock */ #define Q40_RTC_PLL_MASK ((1<<5)-1) #define Q40_RTC_PLL_SIGN (1<<5)