OSDN Git Service

rtc: ds1347: fix value written to century register
authorIan Abbott <abbotti@mev.co.uk>
Thu, 27 Oct 2022 16:32:49 +0000 (17:32 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Tue, 15 Nov 2022 20:01:51 +0000 (21:01 +0100)
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: 147dae76dbb9 ("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>
drivers/rtc/rtc-ds1347.c

index 157bf52..a40c1a5 100644 (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;