aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1347.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2019-10-07 15:47:23 +0200
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2019-10-07 15:49:36 +0200
commit860c45b56d9367f220f6ff786588ccd2d6c44065 (patch)
treeaca96b9efaf9c593dff3dd5c624d4a1b5202e2e1 /drivers/rtc/rtc-ds1347.c
parentd9dcfa5f7084a0c648d9f0946994f4320a411a40 (diff)
downloadlinux-860c45b56d9367f220f6ff786588ccd2d6c44065.tar.gz
rtc: ds1347: use regmap_update_bits
Use regmap_update_bits instead of open coding. Also add proper error handling. Link: https://lore.kernel.org/r/20191007134724.15505-9-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-ds1347.c')
-rw-r--r--drivers/rtc/rtc-ds1347.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/rtc/rtc-ds1347.c b/drivers/rtc/rtc-ds1347.c
index eeaf43586bce7..a49ce99919160 100644
--- a/drivers/rtc/rtc-ds1347.c
+++ b/drivers/rtc/rtc-ds1347.c
@@ -29,6 +29,8 @@
#define DS1347_STATUS_REG 0x17
#define DS1347_CLOCK_BURST 0x3F
+#define DS1347_WP_BIT BIT(7)
+
#define DS1347_NEOSC_BIT BIT(7)
#define DS1347_OSF_BIT BIT(2)
@@ -117,7 +119,7 @@ static int ds1347_probe(struct spi_device *spi)
struct rtc_device *rtc;
struct regmap_config config;
struct regmap *map;
- unsigned int data;
+ int err;
memset(&config, 0, sizeof(config));
config.reg_bits = 8;
@@ -141,9 +143,9 @@ static int ds1347_probe(struct spi_device *spi)
spi_set_drvdata(spi, map);
/* Disable the write protect of rtc */
- regmap_read(map, DS1347_CONTROL_REG, &data);
- data = data & ~(1<<7);
- regmap_write(map, DS1347_CONTROL_REG, data);
+ err = regmap_update_bits(map, DS1347_CONTROL_REG, DS1347_WP_BIT, 0);
+ if (err)
+ return err;
rtc = devm_rtc_allocate_device(&spi->dev);
if (IS_ERR(rtc))