rtc: ds1347: fix value written to century register

commit 4dfe05bdc1 upstream.

In `ds1347_set_time()`, the wrong value is being written to the
`DS1347_CENTURY_REG` register.  It needs to be converted to BCD.  Fix
it.

Fixes: 147dae76db ("rtc: ds1347: handle century register")
Cc: <stable@vger.kernel.org> # v5.5+
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20221027163249.447416-1-abbotti@mev.co.uk
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ian Abbott 2022-10-27 17:32:49 +01:00 committed by Greg Kroah-Hartman
parent 30e859c14f
commit 5f218aab2e
1 changed files with 1 additions and 1 deletions

View File

@ -112,7 +112,7 @@ static int ds1347_set_time(struct device *dev, struct rtc_time *dt)
return err;
century = (dt->tm_year / 100) + 19;
err = regmap_write(map, DS1347_CENTURY_REG, century);
err = regmap_write(map, DS1347_CENTURY_REG, bin2bcd(century));
if (err)
return err;