From patchwork Thu Jun 17 09:42:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 55995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wy0-f184.google.com (mail-wy0-f184.google.com [74.125.82.184]) by ozlabs.org (Postfix) with ESMTP id 4A4E51007D2 for ; Thu, 17 Jun 2010 19:43:01 +1000 (EST) Received: by wyf23 with SMTP id 23sf1993773wyf.11 for ; Thu, 17 Jun 2010 02:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:mime-version:x-beenthere:received :received:received:received:received-spf:received:received:received :received:from:to:cc:subject:date:message-id:x-mailer:x-mimetrack :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=qJSTOuK/h86MT1CDfx0T5Fnr0Ar0EAbAXt/4sRv5eF8=; b=HlzW67PF9gnjOsft+uEoD1UaIMwkmoOG/kv7SSkomkCqvcobNjouCVF2US2QkjDJWG x7iI4V8oDW8Vh8RrDabSQWLM0hIZ3kO+1tVJqa0RpMwDLQrqs2Eyu1nZv/0GIKbjrk5A M0HeuvPx9RaEDTCoeydEFNbqOnsPRdXvLMEXM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:x-mimetrack: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=zkajc4brdfV/SpXHFlqJ8heJedrgLxiNr+ZIo0o/8vhxTCWPTjxmNfp6k4sIuFtSmv 2ouQpjbJWFw8WeGgojGtB3pTdTSvcz9XTbDxQM6QGEbid4w15DQ/hQ34jsUs1l2uMYkd S17FiehGQZjpVB8njAcJUnt8kOOezac34MjHE= Received: by 10.216.236.139 with SMTP id w11mr769871weq.10.1276767779317; Thu, 17 Jun 2010 02:42:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.216.145.167 with SMTP id p39ls441466wej.0.p; Thu, 17 Jun 2010 02:42:58 -0700 (PDT) Received: by 10.216.90.194 with SMTP id e44mr477099wef.9.1276767777669; Thu, 17 Jun 2010 02:42:57 -0700 (PDT) Received: by 10.216.90.194 with SMTP id e44mr477098wef.9.1276767777515; Thu, 17 Jun 2010 02:42:57 -0700 (PDT) Received: from gw1.transmode.se (gw1.transmode.se [213.115.205.20]) by gmr-mx.google.com with ESMTP id v18si9415977wbb.7.2010.06.17.02.42.57; Thu, 17 Jun 2010 02:42:57 -0700 (PDT) Received-SPF: pass (google.com: domain of joakim.tjernlund@transmode.com designates 213.115.205.20 as permitted sender) client-ip=213.115.205.20; Received: from sesr04.transmode.se (sesr04.transmode.se [192.168.201.15]) by gw1.transmode.se (Postfix) with ESMTP id 27FD42597D7; Thu, 17 Jun 2010 11:42:57 +0200 (CEST) Received: from gentoo-jocke.transmode.se ([192.168.1.15]) by sesr04.transmode.se (Lotus Domino Release 8.5.1FP3) with ESMTP id 2010061711425710-5926 ; Thu, 17 Jun 2010 11:42:57 +0200 Received: from gentoo-jocke.transmode.se (gentoo-jocke.transmode.se [127.0.0.1]) by gentoo-jocke.transmode.se (8.14.4/8.14.0) with ESMTP id o5H9guvE022567; Thu, 17 Jun 2010 11:42:56 +0200 Received: (from jocke@localhost) by gentoo-jocke.transmode.se (8.14.4/8.14.4/Submit) id o5H9gtqr022566; Thu, 17 Jun 2010 11:42:55 +0200 From: Joakim Tjernlund To: rtc-linux@googlegroups.com, Paul Gortmaker , linux-kernel@vger.kernel.org Cc: Joakim Tjernlund Subject: [rtc-linux] [PATCH] rtc: fix ds1388 time corruption Date: Thu, 17 Jun 2010 11:42:50 +0200 Message-Id: <1276767770-22531-1-git-send-email-Joakim.Tjernlund@transmode.se> X-Mailer: git-send-email 1.7.1 X-MIMETrack: Itemize by SMTP Server on sesr04/Transmode(Release 8.5.1FP3|May 23, 2010) at 2010-06-17 11:42:57, Serialize by Router on sesr04/Transmode(Release 8.5.1FP3|May 23, 2010) at 2010-06-17 11:42:57, Serialize complete at 2010-06-17 11:42:57 X-Original-Sender: joakim.tjernlund@transmode.se X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of joakim.tjernlund@transmode.com designates 213.115.205.20 as permitted sender) smtp.mail=joakim.tjernlund@transmode.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: , The ds1307 driver misreads the ds1388 registers when checking for 12 or 24 hour mode. Instead of checking the hour register it reads the minute register. Therefore the driver thinks minutes >= 40 has the 12HR bit set and resets the minute register by zeroing the high bits. This results in minutes are reset to 0-9, jumping back in time 40 or 50 minutes. The time jump is also written back to the RTC. Signed-off-by: Joakim Tjernlund --- This should go to Linus ASAP IMHO. drivers/rtc/rtc-ds1307.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index c4ec5c1..a01bbe2 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -775,7 +775,7 @@ static int __devinit ds1307_probe(struct i2c_client *client, read_rtc: /* read RTC registers */ - tmp = ds1307->read_block_data(ds1307->client, 0, 8, buf); + tmp = ds1307->read_block_data(ds1307->client, ds1307->offset, 8, buf); if (tmp != 8) { pr_debug("read error %d\n", tmp); err = -EIO; @@ -860,7 +860,7 @@ read_rtc: if (ds1307->regs[DS1307_REG_HOUR] & DS1307_BIT_PM) tmp += 12; i2c_smbus_write_byte_data(client, - DS1307_REG_HOUR, + ds1307->offset + DS1307_REG_HOUR, bin2bcd(tmp)); }