Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp601925pxp; Wed, 9 Mar 2022 08:55:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJz985YKvWLSO3DEZI5UwYsessKmLke/29v8WLIF8Y1ZJjoaHik0YDEuCvg7qYfWGFRk0sKQ X-Received: by 2002:a17:907:78d6:b0:6da:825b:96d with SMTP id kv22-20020a17090778d600b006da825b096dmr673645ejc.460.1646844957831; Wed, 09 Mar 2022 08:55:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646844957; cv=none; d=google.com; s=arc-20160816; b=CAt2BqpCZiOhLrTItqSEA6lPN7RGW0axtZOk1dnMkRYzqFxD8jC7We50gI31WpKbm+ xfrq748sbd/+dqtVOb8uWYSZrc1MhLJ6fFavEWYq/KN2Jvhy7RLSorMPLc8A6h994nsw hx29QvmK2HY/EVg9svjK38Stkegw9vsuctR3bVggOblI5nQfdBLLuAt8kk3zlc3CfMKY NNXup43fns+SBBKR1Nc41+C3z2qM0179MBTsrl9jIvhqEi0Ncxz0b8NtAyLNz6CKX35U kiV7bEGz1kKnQki6JDTlYIjJ9G4gUdv4iLWufWBQ8fsMVPQGl/dcJ4iENhoIZSCHQ9fh aCIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KHZGIokNZTQCU6zOlzF1qzHt8v1GoKMVBKRTyQFOlUw=; b=xkW/Jdp5lw1kyp1Tex+ZRkyIp8hTCA9hT/6WsqJrbrdl7vMqCK5NwAHxrt0c5MihYz VHMhIifmgus6L+MkPcjCdC58p8B3ovz2WdyU7IWA2NYUdTNm7noa+wNAKWI8YtbRpugj GPyDB/78oDYKRBv3PRGjfpRLEYMPw88uDyaJVaYCK5mPuahgM3E7TVU4gNS7TB1zpoyZ qdmzDy9ONXDMuHjR+xGTwXANdbHj5xZdx9sb8ObS8LVvSxmsy5X5frVIkixZ4vGj80j5 dN/qX7iL+YQlWlnkUIZVyGYFCMSh9oPASgwcTxfXok5BPeLNeVRA5tONo9VPAO1a6U+R 2XoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mIrNODGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a170906248600b006d6dd9c1311si1440676ejb.448.2022.03.09.08.55.34; Wed, 09 Mar 2022 08:55:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mIrNODGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235295AbiCIQhn (ORCPT + 99 others); Wed, 9 Mar 2022 11:37:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236778AbiCIQaM (ORCPT ); Wed, 9 Mar 2022 11:30:12 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 672BDDCE20; Wed, 9 Mar 2022 08:23:37 -0800 (PST) Received: (Authenticated sender: alexandre.belloni@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id CDC48E000F; Wed, 9 Mar 2022 16:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1646843013; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KHZGIokNZTQCU6zOlzF1qzHt8v1GoKMVBKRTyQFOlUw=; b=mIrNODGT8AKgdYd6dH+SnBfomM4O2tlur71NTYRyIEMy/dv8mt7X9Lc+uQmrhBD190mzrS QFTXgDF6mvuhdMVahAwioadN2AV4yRZrs43yCRTvLfAs8egG8C8UDYgmoLNBgU5totjKF6 YDrlozX7iLqNTRw3iS9a+76AEP65+G6DD/NK8Cl6o4nwhn5KuFw0ZeLDYcIhoP0e3pYm4H sOXD6BW7kYIGpxw5tu9PEwsgKJdh/2RSx33yKnvaMm4oE1az37UwIjrvaHb1M7EW4jvKbq x5Z68VlLi4AY36bgcO6r8ecNgc14vZ1tjT7MfbRP4tVAnIDk89YhVbDYzAE8jQ== From: Alexandre Belloni To: Alessandro Zummo , Alexandre Belloni Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/29] rtc: spear: fix spear_rtc_read_time Date: Wed, 9 Mar 2022 17:22:52 +0100 Message-Id: <20220309162301.61679-21-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220309162301.61679-1-alexandre.belloni@bootlin.com> References: <20220309162301.61679-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The reference manual doesn't specify whether the registers are latched and they probably aren't, ensure the read time and date are consistent. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-spear.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c index c395af3ebc91..d4777b01ab22 100644 --- a/drivers/rtc/rtc-spear.c +++ b/drivers/rtc/rtc-spear.c @@ -204,8 +204,10 @@ static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm) /* we don't report wday/yday/isdst ... */ rtc_wait_not_busy(config); - time = readl(config->ioaddr + TIME_REG); - date = readl(config->ioaddr + DATE_REG); + do { + time = readl(config->ioaddr + TIME_REG); + date = readl(config->ioaddr + DATE_REG); + } while (time == readl(config->ioaddr + TIME_REG)); tm->tm_sec = (time >> SECOND_SHIFT) & SECOND_MASK; tm->tm_min = (time >> MINUTE_SHIFT) & MIN_MASK; tm->tm_hour = (time >> HOUR_SHIFT) & HOUR_MASK; -- 2.35.1