From patchwork Fri Jan 16 08:13:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yegor Yefremov X-Patchwork-Id: 18929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from mail-gx0-f56.google.com (mail-gx0-f56.google.com [209.85.217.56]) by ozlabs.org (Postfix) with ESMTP id BD3C5474C7 for ; Fri, 16 Jan 2009 19:13:47 +1100 (EST) Received: by gxk16 with SMTP id 16so1806901gxk.1 for ; Fri, 16 Jan 2009 00:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received-spf:authentication-results:received :received:received:received:message-id:date:from:reply-to:user-agent :mime-version:content-type:to:cc:subject:references:in-reply-to :x-originalarrivaltime:x-virus-scanned:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; bh=unWYqyaWibzEfyhRnjoKIWDqQ7IQzksQB5EudBzeih0=; b=YydNhK75kJOsyiPVlXcLhfL/q4gf9Mepe/IuPe/ijoU5SX5EvT566MdrsQmVWlaeP3 7jZu+aM9GRB1U3/3RxrH6KhdNsQJg8qWxilQfoEtax3393niWjZ64w+drd5Z20+h3ss1 xHTiSVHXo1V+irFnP3pZvDZgI/rd1QvyCGLpk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :message-id:date:from:reply-to:user-agent:mime-version:content-type :to:cc:subject:references:in-reply-to:x-originalarrivaltime :x-virus-scanned:sender:precedence:x-google-loop:mailing-list :list-id:list-post:list-help:list-unsubscribe:x-beenthere-env :x-beenthere; b=Qu+SbhUeIuEXIwLWxTAJigUv+e4a++IY+0135Ayc136uFTcAjEAV0qlXNMGsU9eLQg IOXnM5e0MJiWW7ANQCVK5lepYGeFadmsikSa0BhUJGXqeLyY3hxvGTgwo7nIpY873+tG 2y0i+hmqV8IwOGJgRYNqehNLvoPsbc46W8WU4= Received: by 10.90.93.13 with SMTP id q13mr296525agb.1.1232093623294; Fri, 16 Jan 2009 00:13:43 -0800 (PST) Received: by 10.176.150.34 with SMTP id x34gr1821yqd.0; Fri, 16 Jan 2009 00:13:43 -0800 (PST) X-Sender: Yegor.Yefremov@visionsystems.de X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.103.131.18 with SMTP id i18mr52164mun.19.1232093622749; Fri, 16 Jan 2009 00:13:42 -0800 (PST) Received: from mail.visionsystems.de (hhlx01.vscom.de [62.145.30.242]) by mx.google.com with ESMTP id e3si110327fga.9.2009.01.16.00.13.42; Fri, 16 Jan 2009 00:13:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of Yegor.Yefremov@visionsystems.de designates 62.145.30.242 as permitted sender) client-ip=62.145.30.242; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of Yegor.Yefremov@visionsystems.de designates 62.145.30.242 as permitted sender) smtp.mail=Yegor.Yefremov@visionsystems.de Received: from localhost (localhost [127.0.0.1]) by mail.visionsystems.de (Postfix) with ESMTP id 99C56178C86; Fri, 16 Jan 2009 09:13:41 +0100 (CET) Received: from mail.visionsystems.de ([127.0.0.1]) by localhost (mail.visionsystems.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10785-07; Fri, 16 Jan 2009 09:13:38 +0100 (CET) Received: from visionsystems.de (kallisto.visionsystems.local [192.168.1.3]) by mail.visionsystems.de (Postfix) with ESMTP id 0A4EB178C7C; Fri, 16 Jan 2009 09:13:38 +0100 (CET) Received: from [192.168.1.38] ([192.168.1.38]) by visionsystems.de with Microsoft SMTPSVC(6.0.3790.3959); Fri, 16 Jan 2009 09:13:37 +0100 Message-ID: <497041B1.5000501@visionsystems.de> Date: Fri, 16 Jan 2009 09:13:37 +0100 From: Yegor Yefremov Reply-To: rtc-linux@googlegroups.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.19) Gecko/20081209 Lightning/0.9 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666 Mime-Version: 1.0 To: David Brownell CC: juri.reitel@liewenthal.ee, rtc-linux@googlegroups.com Subject: [rtc-linux] Re: rtc-ds1307: Remove rtc_valid_tm() from ds1307_get_time() References: <496F0DC8.1010704@visionsystems.de> <200901151832.25296.david-b@pacbell.net> In-Reply-To: <200901151832.25296.david-b@pacbell.net> X-OriginalArrivalTime: 16 Jan 2009 08:13:37.0919 (UTC) FILETIME=[558148F0:01C977B2] X-Virus-Scanned: amavisd-new at visionsystems.de Sender: rtc-linux@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rtc-linux@googlegroups.com; contact rtc-linux+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rtc-linux@googlegroups.com X-BeenThere: rtc-linux@googlegroups.com David Brownell wrote: > On Thursday 15 January 2009, Yegor Yefremov wrote: > >> we are maintaining Linux kernel for our OpenRISC device family like >> Alekto and Alena. Both devices are using RTC DS1337 chip from Maxim. >> Sometimes it happens that the RTC provides invalid values such as 32 >> days or 13th month etc. The RTC is still working properly, but due to >> this check rtc_valid_tm() the time in the RTC cannot be changed, >> > > That would be a bug in whatever version of hwclock you're using. > I recall such a bug getting discussed, and fixed, a while back. > > Basically, if you're setting the clock, you don't need to read > it first... > > - Dave > I see your point, but then the drivers/rtc/hctosys.c should be changed not to check the correctness of returned time value but to parse the returned err value. See the diff file to 2.6.29-rc1. - Yegor > > > >> because ds1307_get_time() comes with error. I think it is a matter of >> application such as hwclock to check if the time value returned is valid >> or not, but as long as I2C communication is working without errors the >> read call should be successful. For example rtc_hctosys() from >> /driver/rtc/hctosys.c is making this check itself. To throw a kernel >> warning were also a solution. What do you think about this? >> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. -~----------~----~----~----~------~----~------~--~--- diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c index 33c0e98..446ad06 100644 --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c @@ -36,30 +36,29 @@ static int __init rtc_hctosys(void) err = rtc_read_time(rtc, &tm); if (err == 0) { - err = rtc_valid_tm(&tm); - if (err == 0) { - struct timespec tv; + struct timespec tv; - tv.tv_nsec = NSEC_PER_SEC >> 1; + tv.tv_nsec = NSEC_PER_SEC >> 1; - rtc_tm_to_time(&tm, &tv.tv_sec); + rtc_tm_to_time(&tm, &tv.tv_sec); - do_settimeofday(&tv); + do_settimeofday(&tv); - dev_info(rtc->dev.parent, - "setting system clock to " - "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, - (unsigned int) tv.tv_sec); - } - else - dev_err(rtc->dev.parent, - "hctosys: invalid date/time\n"); + dev_info(rtc->dev.parent, + "setting system clock to " + "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, + (unsigned int) tv.tv_sec); } - else + else if(err == -EIO){ dev_err(rtc->dev.parent, "hctosys: unable to read the hardware clock\n"); + } + else if(err == -EINVAL){ + dev_err(rtc->dev.parent, + "hctosys: invalid date/time\n"); + } rtc_class_close(rtc);