linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: linux-rtc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: [PATCH 1/6] rtc: ds2404: set range
Date: Fri, 19 Apr 2019 10:24:56 +0200	[thread overview]
Message-ID: <20190419082501.17549-1-alexandre.belloni@bootlin.com> (raw)

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>
---
 drivers/rtc/rtc-ds2404.c | 14 +++++++++-----
 1 file 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;
-- 
2.20.1


             reply	other threads:[~2019-04-19 18:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-19  8:24 Alexandre Belloni [this message]
2019-04-19  8:24 ` [PATCH 2/6] rtc: ds2404: switch to rtc_time64_to_tm Alexandre Belloni
2019-04-19  8:24 ` [PATCH 3/6] rtc: ds2404: use .set_time Alexandre Belloni
2019-04-19  8:24 ` [PATCH 4/6] rtc: ds2404: convert to SPDX identifier Alexandre Belloni
2019-04-19  8:25 ` [PATCH 5/6] rtc: ds2404: remove ds2404_chip_ops Alexandre Belloni
2019-04-19  8:25 ` [PATCH 6/6] rtc: ds2404: simplify .probe and remove .remove Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190419082501.17549-1-alexandre.belloni@bootlin.com \
    --to=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).