Linux RTC
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Jan Kardell <jan.kardell@telliq.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org,
	Vincent Donnefort <vdonnefort@gmail.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [rtc-linux] Re: [PATCH] rtc: pcf8563 fix: return -EINVAL if we read an invalid time.
Date: Wed, 27 May 2015 10:55:06 +0200	[thread overview]
Message-ID: <20150527085506.GM3199@piout.net> (raw)
In-Reply-To: <1432547474-3787-1-git-send-email-jan.kardell@telliq.com>

Hi,

On 25/05/2015 at 11:51:14 +0200, Jan Kardell wrote :
> @@ -202,8 +202,9 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
>  
>  	if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) {
>  		pcf8563->voltage_low = 1;
> -		dev_info(&client->dev,
> +		dev_err(&client->dev,
>  			"low voltage detected, date/time is not reliable.\n");
> +		return -EINVAL;
>  	}
>  
>  	dev_dbg(&client->dev,
> @@ -234,11 +235,11 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
>  		tm->tm_sec, tm->tm_min, tm->tm_hour,
>  		tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
>  
> -	/* the clock can give out invalid datetime, but we cannot return
> -	 * -EINVAL otherwise hwclock will refuse to set the time on bootup.
> -	 */
> -	if (rtc_valid_tm(tm) < 0)
> +	err = rtc_valid_tm(tm);
> +	if (err < 0) {
>  		dev_err(&client->dev, "retrieved date/time is not valid.\n");
> +		return err;
> +	}

I would avoid dev_err and directly return rtc_valid_tm(tm) or you could
also return 0 and let the core do the rtc_valid_tm() check.

>  
>  	return 0;
>  }
> -- 
> 1.8.4.5
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
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.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

      reply	other threads:[~2015-05-27  8:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25  9:51 [rtc-linux] [PATCH] rtc: pcf8563 fix: return -EINVAL if we read an invalid time Jan Kardell
2015-05-27  8:55 ` Alexandre Belloni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150527085506.GM3199@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=a.zummo@towertech.it \
    --cc=dan.carpenter@oracle.com \
    --cc=jan.kardell@telliq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=vdonnefort@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox