From patchwork Fri Jan 28 05:56:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xulei X-Patchwork-Id: 80769 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-vw0-f56.google.com (mail-vw0-f56.google.com [209.85.212.56]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 6A6F71007D2 for ; Fri, 28 Jan 2011 16:53:47 +1100 (EST) Received: by vws2 with SMTP id 2sf1786722vws.11 for ; Thu, 27 Jan 2011 21:53:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:x-beenthere:received-spf:x-spamscore:x-bigfish :x-spam-tcs-scl:x-forefront-antispam-report:from:to:cc:subject:date :message-id:x-mailer:mime-version:x-originatororg:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=Z99ad1SnwsisMEwKI72vQNu+wBumh5XoxHzplcYCO80=; b=ij+mhwUo4JjU2tM50WdUYrOfU24+Z1p1juvgHNqjdoa2AzhvzHabcWdCSN7p8B0NHO C7ce0vy+rscl9aXxsBimhymdqgmQ+pPu4pXh9VFG68OHytvGU/HmNq67rZSWkZM3GQvR tNHqyK5f0OCo7ZP4Yo0MnZE8A9uH9I1VE37BQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:x-spamscore:x-bigfish:x-spam-tcs-scl :x-forefront-antispam-report:from:to:cc:subject:date:message-id :x-mailer:mime-version:x-originatororg:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; b=wBNSLS7NrL1VWrzi9GOS2srWtmo/AYHy3ExqPvYalZIbgas9k6S8fA+8nZ34yHEoXn ZYj9z/8qQAycCAWxDMkzIM0q1UnrN4ffALKxggz7SkfCfFeKiYTWHuK2GhljMYZxImqL 6fBhpAyLMJLx+Z7ls4aYl/g1aCZDhq3sGJ6lQ= Received: by 10.220.200.134 with SMTP id ew6mr141740vcb.1.1296194023595; Thu, 27 Jan 2011 21:53:43 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.220.109.137 with SMTP id j9ls317423vcp.0.p; Thu, 27 Jan 2011 21:53:42 -0800 (PST) Received: by 10.220.200.65 with SMTP id ev1mr466266vcb.0.1296194022811; Thu, 27 Jan 2011 21:53:42 -0800 (PST) Received: by 10.220.200.65 with SMTP id ev1mr466265vcb.0.1296194022774; Thu, 27 Jan 2011 21:53:42 -0800 (PST) Received: from TX2EHSOBE003.bigfish.com (tx2ehsobe002.messaging.microsoft.com [65.55.88.12]) by gmr-mx.google.com with ESMTPS id l22si3363573vbn.4.2011.01.27.21.53.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 27 Jan 2011 21:53:42 -0800 (PST) Received-SPF: neutral (google.com: 65.55.88.12 is neither permitted nor denied by best guess record for domain of B33228@freescale.com) client-ip=65.55.88.12; Received: from mail93-tx2-R.bigfish.com (10.9.14.247) by TX2EHSOBE003.bigfish.com (10.9.40.23) with Microsoft SMTP Server id 14.1.225.8; Fri, 28 Jan 2011 05:53:41 +0000 Received: from mail93-tx2 (localhost.localdomain [127.0.0.1]) by mail93-tx2-R.bigfish.com (Postfix) with ESMTP id C179611C8092; Fri, 28 Jan 2011 05:53:41 +0000 (UTC) X-SpamScore: 3 X-BigFish: VS3(zzc8kzz1202hzz8275bhz2dh2a8h668h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:az33egw02.freescale.net; RD:az33egw02.freescale.net; EFVD:NLI Received: from mail93-tx2 (localhost.localdomain [127.0.0.1]) by mail93-tx2 (MessageSwitch) id 1296194021590837_10040; Fri, 28 Jan 2011 05:53:41 +0000 (UTC) Received: from TX2EHSMHS036.bigfish.com (unknown [10.9.14.252]) by mail93-tx2.bigfish.com (Postfix) with ESMTP id 8D8CFD30055; Fri, 28 Jan 2011 05:53:41 +0000 (UTC) Received: from az33egw02.freescale.net (192.88.158.103) by TX2EHSMHS036.bigfish.com (10.9.99.136) with Microsoft SMTP Server (TLS) id 14.1.225.8; Fri, 28 Jan 2011 05:53:41 +0000 Received: from az33smr02.freescale.net (az33smr02.freescale.net [10.64.34.200]) by az33egw02.freescale.net (8.14.3/8.14.3) with ESMTP id p0S5reMZ012375; Thu, 27 Jan 2011 22:53:40 -0700 (MST) Received: from localhost.localdomain (xulei-desktop.ap.freescale.net [10.193.20.28]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id p0S5rbNi027008; Thu, 27 Jan 2011 23:53:38 -0600 (CST) From: Lei Xu To: CC: , Lei Xu Subject: [rtc-linux] [PATCH] RTC: Fix time range difference between linux and RTC chip Date: Fri, 28 Jan 2011 13:56:41 +0800 Message-ID: <1296194201-4747-1-git-send-email-B33228@freescale.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Original-Sender: b33228@freescale.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 65.55.88.12 is neither permitted nor denied by best guess record for domain of B33228@freescale.com) smtp.mail=B33228@freescale.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , In linux rtc_time struct, tm_mon range is 0~11, tm_wday range is 0~6, while in RTC HW REG, month range is 1~12, day of the week range is 1~7, this patch adjusts difference of them. Signed-off-by: Lei Xu --- For SDK2.3.1 drivers/rtc/rtc-ds3232.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c index 9daed8d..ad61546 100644 --- a/drivers/rtc/rtc-ds3232.c +++ b/drivers/rtc/rtc-ds3232.c @@ -1,7 +1,7 @@ /* * RTC client/driver for the Maxim/Dallas DS3232 Real-Time Clock over I2C * - * Copyright (C) 2009-2010 Freescale Semiconductor. + * Copyright (C) 2009-2011 Freescale Semiconductor. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -140,9 +140,11 @@ static int ds3232_read_time(struct device *dev, struct rtc_time *time) time->tm_hour = bcd2bin(hour); } - time->tm_wday = bcd2bin(week); + /* Day of the week in linux range is 0~6 while 1~7 in RTC chip */ + time->tm_wday = bcd2bin(week) - 1; time->tm_mday = bcd2bin(day); - time->tm_mon = bcd2bin(month & 0x7F); + /* linux tm_mon range:0~11, while month range is 1~12 in RTC chip */ + time->tm_mon = bcd2bin(month & 0x7F) - 1; if (century) add_century = 100; @@ -161,9 +163,11 @@ static int ds3232_set_time(struct device *dev, struct rtc_time *time) buf[0] = bin2bcd(time->tm_sec); buf[1] = bin2bcd(time->tm_min); buf[2] = bin2bcd(time->tm_hour); - buf[3] = bin2bcd(time->tm_wday); /* Day of the week */ + /* Day of the week in linux range is 0~6 while 1~7 in RTC chip */ + buf[3] = bin2bcd(time->tm_wday + 1); buf[4] = bin2bcd(time->tm_mday); /* Date */ - buf[5] = bin2bcd(time->tm_mon); + /* linux tm_mon range:0~11, while month range is 1~12 in RTC chip */ + buf[5] = bin2bcd(time->tm_mon + 1); if (time->tm_year >= 100) { buf[5] |= 0x80; buf[6] = bin2bcd(time->tm_year - 100);