rtc: ds1307: rx8130: Fix alarm handling

When the EXTENSION.WADA bit is set, register 0x19 contains a bitmap of
week days, not a day of month. As Linux only handles a single alarm
without repetition using day of month is more flexible, so clear this
bit. (Otherwise a value depending on time.tm_wday would have to be
written to register 0x19.)

Also optimize setting the AIE bit to use a single register write instead
of a bulk write of three registers.

Fixes: ee0981be77 ("rtc: ds1307: Add support for Epson RX8130CE")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
Uwe Kleine-König 2019-01-25 15:35:58 +01:00 committed by Alexandre Belloni
parent 501f98266c
commit 3f929cad94
1 changed files with 3 additions and 4 deletions

View File

@ -554,8 +554,8 @@ static int rx8130_set_alarm(struct device *dev, struct rtc_wkalrm *t)
if (ret < 0) if (ret < 0)
return ret; return ret;
ctl[0] &= ~RX8130_REG_EXTENSION_WADA; ctl[0] &= RX8130_REG_EXTENSION_WADA;
ctl[1] |= RX8130_REG_FLAG_AF; ctl[1] &= ~RX8130_REG_FLAG_AF;
ctl[2] &= ~RX8130_REG_CONTROL0_AIE; ctl[2] &= ~RX8130_REG_CONTROL0_AIE;
ret = regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl, ret = regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl,
@ -578,8 +578,7 @@ static int rx8130_set_alarm(struct device *dev, struct rtc_wkalrm *t)
ctl[2] |= RX8130_REG_CONTROL0_AIE; ctl[2] |= RX8130_REG_CONTROL0_AIE;
return regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl, return regmap_write(ds1307->regmap, RX8130_REG_CONTROL0, ctl[2]);
sizeof(ctl));
} }
static int rx8130_alarm_irq_enable(struct device *dev, unsigned int enabled) static int rx8130_alarm_irq_enable(struct device *dev, unsigned int enabled)