Skip to contentSkip to conversation

rtc: ab3100: set range

PATCH In review Alexandre Belloni 2 participants 6 messages Apr 9, 2019 – Apr 11, 2019 Real time clock (RTC)

lore
Share & tools
lore

Alexandre Belloni

author maintainer
#0 lore raw

PATCH 1/3 rtc: ab3100: set range

The ab3100 has a 48bit counter running at 65536 Hz (despite one of the comment). The max value is then (2^48 - 1)/2^16 == 2^32 - 1.

---
 drivers/rtc/rtc-ab3100.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/rtc/rtc-ab3100.c +9 -7
index 821ff52a2222..f73a3707b897 100644
@@ -228,15 +228,17 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev)
 		/* Ignore any error on this write */
 	}
 
-	rtc = devm_rtc_device_register(&pdev->dev, "ab3100-rtc",
-					&ab3100_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rtc)) {
-		err = PTR_ERR(rtc);
-		return err;
-	}
+	rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(rtc))
+		return PTR_ERR(rtc);
+
+	rtc->ops = &ab3100_rtc_ops;
+	/* 48bit counter at (AB3100_RTC_CLOCK_RATE * 2) */
+	rtc->range_max = U32_MAX;
+
 	platform_set_drvdata(pdev, rtc);
 
-	return 0;
+	return rtc_register_device(rtc);
 }
 
 static struct platform_driver ab3100_rtc_driver = {
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH 2/3 rtc: ab3100: use .set_time

Use .set_time instead of the deprecated .set_mmss64.

---
 drivers/rtc/rtc-ab3100.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-ab3100.c +3 -3
index f73a3707b897..ecf3f1494c13 100644
@@ -43,12 +43,12 @@
 /*
  * RTC clock functions and device struct declaration
  */
-static int ab3100_rtc_set_mmss(struct device *dev, time64_t secs)
+static int ab3100_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
 	u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2,
 		     AB3100_TI3, AB3100_TI4, AB3100_TI5};
 	unsigned char buf[6];
-	u64 hw_counter = secs * AB3100_RTC_CLOCK_RATE * 2;
+	u64 hw_counter = rtc_tm_to_time64(tm) * AB3100_RTC_CLOCK_RATE * 2;
 	int err = 0;
 	int i;
 
@@ -192,7 +192,7 @@ static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled)
 
 static const struct rtc_class_ops ab3100_rtc_ops = {
 	.read_time	= ab3100_rtc_read_time,
-	.set_mmss64	= ab3100_rtc_set_mmss,
+	.set_time	= ab3100_rtc_set_time,
 	.read_alarm	= ab3100_rtc_read_alarm,
 	.set_alarm	= ab3100_rtc_set_alarm,
 	.alarm_irq_enable = ab3100_rtc_irq_enable,
Signature · 1 line
2.20.1
author maintainer
#3 lore raw

PATCH 3/3 rtc: ab3100: convert to SPDX identifier

In reply to Alexandre Belloni

Use SPDX-License-Identifier instead of the custom license line.

---
 drivers/rtc/rtc-ab3100.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ab3100.c +1 -1
index ecf3f1494c13..2ed6def90975 100644
@@ -1,6 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2007-2009 ST-Ericsson AB
- * License terms: GNU General Public License (GPL) version 2
  * RTC clock driver for the AB3100 Analog Baseband Chip
  * Author: Linus Walleij <[email protected]>
  */
Signature · 1 line
2.20.1