summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-ds2404.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2019-04-19 10:24:56 +0200
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2019-04-19 22:37:16 +0200
commit13bfa942254f0894f22bcbfccee3480df1bfd89d (patch)
tree5169c4af60557f5242e709445183bcff209fce70 /drivers/rtc/rtc-ds2404.c
parentd71c7715326b561e5b11768e8146f46287d1edd8 (diff)
downloadlinux-13bfa942254f0894f22bcbfccee3480df1bfd89d.tar.gz
rtc: ds2404: set range
The real-time clock is a 5-byte binary counter. It is incremented 256 times per second. The least significant byte is a count of fractional seconds. The upper four bytes are a count of seconds. The realtime clock can accumulate 136 years of seconds before rolling over. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-ds2404.c')
-rw-r--r--drivers/rtc/rtc-ds2404.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/rtc/rtc-ds2404.c b/drivers/rtc/rtc-ds2404.c
index b886b6a5c178..7b36c09bed10 100644
--- a/drivers/rtc/rtc-ds2404.c
+++ b/drivers/rtc/rtc-ds2404.c
@@ -234,6 +234,10 @@ static int rtc_probe(struct platform_device *pdev)
chip->ops = &ds2404_gpio_ops;
+ chip->rtc = devm_rtc_allocate_device(&pdev->dev);
+ if (IS_ERR(chip->rtc))
+ return PTR_ERR(chip->rtc);
+
retval = chip->ops->map_io(chip, pdev, pdata);
if (retval)
goto err_chip;
@@ -244,12 +248,12 @@ static int rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chip);
- chip->rtc = devm_rtc_device_register(&pdev->dev, "ds2404",
- &ds2404_rtc_ops, THIS_MODULE);
- if (IS_ERR(chip->rtc)) {
- retval = PTR_ERR(chip->rtc);
+ chip->rtc->ops = &ds2404_rtc_ops;
+ chip->rtc->range_max = U32_MAX;
+
+ retval = rtc_register_device(chip->rtc);
+ if (retval)
goto err_io;
- }
ds2404_enable_osc(&pdev->dev);
return 0;