From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755081AbcGHO0G (ORCPT ); Fri, 8 Jul 2016 10:26:06 -0400 Received: from down.free-electrons.com ([37.187.137.238]:55195 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754746AbcGHOZ4 (ORCPT ); Fri, 8 Jul 2016 10:25:56 -0400 Date: Fri, 8 Jul 2016 16:25:54 +0200 From: Alexandre Belloni To: Keerthy Cc: a.zummo@towertech.it, nm@ti.com, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rtc: ds1307: Fix relying on reset value for weekday Message-ID: <20160708142554.GI22202@piout.net> References: <1464778147-22075-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464778147-22075-1-git-send-email-j-keerthy@ti.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/06/2016 at 16:19:07 +0530, Keerthy wrote : > The reset value of weekday is 0x1. This is wrong since > the reset values of the day/month/year make up to Jan 1 2001. > When computed weekday comes out to be Monday. On a scale > of 1-7(Sunday - Saturday) it should be 0x2. So we should not > be relying on the reset value. > > Hence compute the wday using the current date/month/year values. > Check if reset wday is any different from the computed wday, > If different then set the wday which we computed using > date/month/year values. > > Document Referred: > http://ww1.microchip.com/downloads/en/DeviceDoc/20002266F.pdf > > Fixes: 1d1945d261a2af "drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips" > Signed-off-by: Keerthy > --- > drivers/rtc/rtc-ds1307.c | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > Applied, thanks. -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com