[PATCH v2] rtc: pcf8563: fix wrong alarm register

Troy Mitchell posted 1 patch 6 months, 2 weeks ago
drivers/rtc/rtc-pcf8563.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] rtc: pcf8563: fix wrong alarm register
Posted by Troy Mitchell 6 months, 2 weeks ago
When the regmap framework was introduced to this driver,
the PCF8563_REG_AMN register within the set_alarm function was
incorrectly changed to PCF8563_REG_SC.

The PCF8563_REG_SC register is the seconds register.
This caused alarm values to be written to the seconds register
when an alarm was set. Which means the alarm would not trigger
as expected and the seconds register would be overwritten
with an incorrect value.

Signed-off-by: Troy Mitchell <troymitchell988@gmail.com>
---
Since this patch[1], the set_alarm function has been setting
an wrong register.

Link:
https://lore.kernel.org/all/20241010084949.3351182-3-iwamatsu@nigauri.org/ [1]
---
Changes in v2:
- Remove irrelevant changes
- Link to v1: https://lore.kernel.org/r/20250419-pcf8563-fix-alarm-v1-1-b893a5de55b8@gmail.com
---
 drivers/rtc/rtc-pcf8563.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 5a084d426e58d09cfedf0809695a96a27627c420..b2611697fa5e3adc61f687e39385d10736dec677 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -285,7 +285,7 @@ static int pcf8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *tm)
 	buf[2] = bin2bcd(tm->time.tm_mday);
 	buf[3] = tm->time.tm_wday & 0x07;
 
-	err = regmap_bulk_write(pcf8563->regmap, PCF8563_REG_SC, buf,
+	err = regmap_bulk_write(pcf8563->regmap, PCF8563_REG_AMN, buf,
 				sizeof(buf));
 	if (err)
 		return err;

---
base-commit: 8560697b23dc2f405cb463af2b17256a9888129d
change-id: 20250419-pcf8563-fix-alarm-5e787f095861

Best regards,
-- 
Troy Mitchell <troymitchell988@gmail.com>
Re: [PATCH v2] rtc: pcf8563: fix wrong alarm register
Posted by Alexandre Belloni 6 months, 2 weeks ago
On Sat, 31 May 2025 15:20:40 +0800, Troy Mitchell wrote:
> When the regmap framework was introduced to this driver,
> the PCF8563_REG_AMN register within the set_alarm function was
> incorrectly changed to PCF8563_REG_SC.
> 
> The PCF8563_REG_SC register is the seconds register.
> This caused alarm values to be written to the seconds register
> when an alarm was set. Which means the alarm would not trigger
> as expected and the seconds register would be overwritten
> with an incorrect value.
> 
> [...]

Applied, thanks!

[1/1] rtc: pcf8563: fix wrong alarm register
      https://git.kernel.org/abelloni/c/1e15a6803df0

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com