Skip to content

Commit 8beb689

Browse files
Paladinkingpelwell
authored andcommitted
rtc: pcf8523: Fix oscillator stop bit handling reading from Control_1
The check if the oscillator stop bit is set was reading from Control_1 register instead of the Seconds register. This caused the Seconds register to be incorrectly changed if bit 7 of Control_1 happens to be set. Signed-off-by: Axel Hammarberg <[email protected]>
1 parent e596d70 commit 8beb689

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/rtc/rtc-pcf8523.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ static int pcf8523_rtc_read_time(struct device *dev, struct rtc_time *tm)
108108
if (err < 0)
109109
return err;
110110

111-
if ((regs[0] & PCF8523_CONTROL1_STOP) || (regs[3] & PCF8523_SECONDS_OS))
111+
if (regs[PCF8523_REG_CONTROL1] & PCF8523_CONTROL1_STOP)
112112
return -EINVAL;
113113

114-
if (regs[0] & PCF8523_SECONDS_OS) {
114+
if (regs[PCF8523_REG_SECONDS] & PCF8523_SECONDS_OS) {
115115
/*
116116
* If the oscillator was stopped, try to clear the flag. Upon
117117
* power-up the flag is always set, but if we cannot clear it
@@ -120,10 +120,10 @@ static int pcf8523_rtc_read_time(struct device *dev, struct rtc_time *tm)
120120
* that the clock cannot be assumed to be correct.
121121
*/
122122

123-
regs[0] &= ~PCF8523_SECONDS_OS;
123+
regs[PCF8523_REG_SECONDS] &= ~PCF8523_SECONDS_OS;
124124

125125
err = regmap_write(pcf8523->regmap, PCF8523_REG_SECONDS,
126-
regs[0]);
126+
regs[PCF8523_REG_SECONDS]);
127127
if (err < 0)
128128
return err;
129129

@@ -135,7 +135,7 @@ static int pcf8523_rtc_read_time(struct device *dev, struct rtc_time *tm)
135135
if (value & PCF8523_SECONDS_OS)
136136
return -EAGAIN;
137137

138-
regs[0] = value;
138+
regs[PCF8523_REG_SECONDS] = value;
139139
}
140140

141141
tm->tm_sec = bcd2bin(regs[3] & 0x7f);

0 commit comments

Comments
 (0)