mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: linux-rtc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: [PATCH 6/7] rtc: rx8581: error out when time invalid
Date: Thu, 17 May 2018 22:33:30 +0200	[thread overview]
Message-ID: <20180517203331.24504-6-alexandre.belloni@bootlin.com> (raw)
In-Reply-To: <20180517203331.24504-1-alexandre.belloni@bootlin.com>

Return an error when the date is unreliable because the battery is low.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-rx8581.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c
index 0a70f1ac5cc2..53644bb271af 100644
--- a/drivers/rtc/rtc-rx8581.c
+++ b/drivers/rtc/rtc-rx8581.c
@@ -109,6 +109,12 @@ static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm)
 		return -EIO;
 	}
 
+	if (data & RX8581_FLAG_VLF) {
+		dev_warn(dev,
+			"low voltage detected, date/time is not reliable.\n");
+		return -EINVAL;
+	}
+
 	do {
 		/* If update flag set, clear it */
 		if (data & RX8581_FLAG_UF) {
@@ -136,10 +142,6 @@ static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm)
 		}
 	} while (data & RX8581_FLAG_UF);
 
-	if (data & RX8581_FLAG_VLF)
-		dev_info(dev,
-			"low voltage detected, date/time is not reliable.\n");
-
 	dev_dbg(dev, "%s: raw data is sec=%02x, min=%02x, hr=%02x, "
 		"wday=%02x, mday=%02x, mon=%02x, year=%02x\n",
 		__func__,
-- 
2.17.0

  parent reply	other threads:[~2018-05-17 20:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17 20:33 [PATCH 1/7] rtc: rx8581: switch to rtc_register_device Alexandre Belloni
2018-05-17 20:33 ` [PATCH 2/7] rtc: rx8581: add RTC range Alexandre Belloni
2018-05-17 20:33 ` [PATCH 3/7] rtc: rx8581: let the core handle rtc range Alexandre Belloni
2018-05-17 20:33 ` [PATCH 4/7] rtc: rx8581: remove useless indirection Alexandre Belloni
2018-05-17 20:33 ` [PATCH 5/7] rtc: rx8581: remove useless declaration Alexandre Belloni
2018-05-17 20:33 ` Alexandre Belloni [this message]
2018-05-17 20:33 ` [PATCH 7/7] rtc: rx8581: switch to regmap Alexandre Belloni

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=20180517203331.24504-6-alexandre.belloni@bootlin.com \
    --to=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®