Skip to content

Commit 78a92c6

Browse files
committed
rtc: mpfs: fix counter upload completion condition
The condition that needs to be checked for upload completion is the UPLOAD bit in the completion register going low. The original iterations of this driver used a do-while and this was converted to a read_poll_timeout() during upstreaming without the condition being inverted as it should have been. I suspect that this went unnoticed until now because a) the first read was done when the bit was still set, immediately completing the read_poll_timeout() and b) because the RTC doesn't hold time when power is removed from the SoC reducing its utility (I for one keep it disabled). If my first suspicion was true when the driver was upstreamed, it's not true any longer though, hence the detection of the problem. Fixes: 0b31d70 ("rtc: Add driver for Microchip PolarFire SoC") CC: stable@vger.kernel.org Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
1 parent b6fe42b commit 78a92c6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/rtc/rtc-mpfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int mpfs_rtc_settime(struct device *dev, struct rtc_time *tm)
112112
ctrl |= CONTROL_UPLOAD_BIT;
113113
writel(ctrl, rtcdev->base + CONTROL_REG);
114114

115-
ret = read_poll_timeout(readl, prog, prog & CONTROL_UPLOAD_BIT, 0, UPLOAD_TIMEOUT_US,
115+
ret = read_poll_timeout(readl, prog, !(prog & CONTROL_UPLOAD_BIT), 0, UPLOAD_TIMEOUT_US,
116116
false, rtcdev->base + CONTROL_REG);
117117
if (ret) {
118118
dev_err(dev, "timed out uploading time to rtc");

0 commit comments

Comments
 (0)