From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbcGNUCd (ORCPT ); Thu, 14 Jul 2016 16:02:33 -0400 Received: from 36.223.133.77.rev.sfr.net ([77.133.223.36]:56857 "EHLO smtp.natisbad.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751798AbcGNUC2 (ORCPT ); Thu, 14 Jul 2016 16:02:28 -0400 X-Greylist: delayed 451 seconds by postgrey-1.27 at vger.kernel.org; Thu, 14 Jul 2016 16:02:28 EDT From: arno@natisbad.org (Arnaud Ebalard) To: Alexandre Belloni Cc: Alessandro Zummo , rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rtc: ds1307: fix century bit support References: <1468370064-19255-1-git-send-email-alexandre.belloni@free-electrons.com> X-PGP-Key-URL: http://natisbad.org/arno@natisbad.org.asc X-Fingerprint: D3A5 B68A 839B 38A5 815A 781B B77C 0748 A7AE 341B X-Hashcash: 1:20:160714:rtc-linux@googlegroups.com::8I7chAusWWBgn7Tn:000000000000000000000000000000000003vRd X-Hashcash: 1:20:160714:alexandre.belloni@free-electrons.com::Upzxkkaotqtotq7z:00000000000000000000000004kqg X-Hashcash: 1:20:160714:linux-kernel@vger.kernel.org::MSbCTQrF74qV07/y:0000000000000000000000000000000006tC2 X-Hashcash: 1:20:160714:a.zummo@towertech.it::ku/W3A/H+dW5zV79:00000000000000000000000000000000000000000F/u6 Date: Thu, 14 Jul 2016 21:54:45 +0200 Message-ID: <87inw8hu62.fsf@natisbad.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexandre, Alexandre Belloni writes: > Add an option to properly support the century bit of ds1337 and compatibles > and ds1340. > Because the driver had a bug until now, it is not possible to switch users > to the fixed code directly as RTCs in the field will wrongly have the > century bit set. > > Signed-off-by: Alexandre Belloni > --- > > Arnaud, do you mind testing that patch, I still don't have the necessary > hardware but I think this is the proper course of action. I did some tests w/ all patches applied (the one below and the ones in the other series). I had to fix two errors: one pointed in the patch below and the other one in a patch in the other series (I'll reply to the patch). With both RTC_DRV_DS1307 and RTC_DRV_DS1307_CENTURY enabled, this works as expected on my side: booting on a system which had only seen an ISL12057 driver, the time on the system at boot (or via hwclock -r) is correct. Playing w/ -s and -w options works as expected. Booting back on a kernel w/ ISL12057 driver, things are also ok. So, AFAICT, your changes do the work. One small thing though: for user which have always used RTC_DRV_ISL12057 config knob, the change will not be transparent. Would it be possible to somehow make that old kernel config knob some kind of alias for RTC_DRV_DS1307 and RTC_DRV_DS1307_CENTURY in Kconfig? Cheers, a+ > +#ifdef CONFIG_RTC_DRV_DS1307_CENTURY > + switch (ds1307->type) { > + case ds_1337: > + case ds_1339: > + case ds_3231: > + if (ds1307->regs[DS1307_REG_MONTH] && DS1337_BIT_CENTURY) ^^ > + t->tm_year += 100; > + break; > + case ds_1340: > + if (ds1307->regs[DS1307_REG_HOUR] && DS1340_BIT_CENTURY) ^^