From patchwork Thu May 17 20:33:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 915755 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40n32B2RZkz9s2R for ; Fri, 18 May 2018 06:34:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752338AbeEQUeW (ORCPT ); Thu, 17 May 2018 16:34:22 -0400 Received: from mail.bootlin.com ([62.4.15.54]:39019 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752141AbeEQUdr (ORCPT ); Thu, 17 May 2018 16:33:47 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 849F8207BB; Thu, 17 May 2018 22:33:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (unknown [88.191.26.124]) by mail.bootlin.com (Postfix) with ESMTPSA id 64F27207D4; Thu, 17 May 2018 22:33:33 +0200 (CEST) From: Alexandre Belloni To: linux-rtc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Alexandre Belloni Subject: [PATCH 6/7] rtc: rx8581: error out when time invalid Date: Thu, 17 May 2018 22:33:30 +0200 Message-Id: <20180517203331.24504-6-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180517203331.24504-1-alexandre.belloni@bootlin.com> References: <20180517203331.24504-1-alexandre.belloni@bootlin.com> Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org Return an error when the date is unreliable because the battery is low. Signed-off-by: Alexandre Belloni --- 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__,