Skip to contentSkip to conversation

rtc: pl030: set range

PATCH New Alexandre Belloni 1 participant 3 messages Mar 6, 2020 Real time clock (RTC)

lore
Share & tools
lore

Alexandre Belloni

author maintainer
#0 lore raw

PATCH 1/3 rtc: pl030: set range

This RTC is a 32bit seconds counter.

---
 drivers/rtc/rtc-pl030.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-pl030.c +1 -0
index d4a5f8afafbc..30aa813f96c0 100644
@@ -116,6 +116,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id)
 	}
 
 	rtc->rtc->ops = &pl030_ops;
+	rtc->rtc->range_max = U32_MAX;
 	rtc->base = ioremap(dev->res.start, resource_size(&dev->res));
 	if (!rtc->base) {
 		ret = -ENOMEM;
Signature · 1 line
2.24.1
author maintainer
#1 lore raw

PATCH 2/3 rtc: pl030: remove useless invalid alarm handling

The core will never pass an invalid alarm to .set_alarm, it is not necessary to check for its validity.

---
 drivers/rtc/rtc-pl030.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/rtc/rtc-pl030.c +1 -6
index 30aa813f96c0..55776e8fa87c 100644
@@ -46,12 +46,7 @@ static int pl030_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	unsigned long time;
 	int ret;
 
-	/*
-	 * At the moment, we can only deal with non-wildcarded alarm times.
-	 */
-	ret = rtc_valid_tm(&alrm->time);
-	if (ret == 0)
-		ret = rtc_tm_to_time(&alrm->time, &time);
+	ret = rtc_tm_to_time(&alrm->time, &time);
 	if (ret == 0)
 		writel(time, rtc->base + RTC_MR);
 	return ret;
Signature · 1 line
2.24.1
author maintainer
#2 lore raw

PATCH 3/3 rtc: pl030: switch to rtc_time64_to_tm/rtc_tm_to_time64

In reply to Alexandre Belloni

Call the 64bit versions of rtc_tm time conversion to avoid the y2106 issue.

---
 drivers/rtc/rtc-pl030.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/rtc/rtc-pl030.c +7 -14
index 55776e8fa87c..ebe03eba8f5f 100644
@@ -36,27 +36,24 @@ static int pl030_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
 	struct pl030_rtc *rtc = dev_get_drvdata(dev);
 
-	rtc_time_to_tm(readl(rtc->base + RTC_MR), &alrm->time);
+	rtc_time64_to_tm(readl(rtc->base + RTC_MR), &alrm->time);
 	return 0;
 }
 
 static int pl030_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
 	struct pl030_rtc *rtc = dev_get_drvdata(dev);
-	unsigned long time;
-	int ret;
 
-	ret = rtc_tm_to_time(&alrm->time, &time);
-	if (ret == 0)
-		writel(time, rtc->base + RTC_MR);
-	return ret;
+	writel(rtc_tm_to_time64(&alrm->time), rtc->base + RTC_MR);
+
+	return 0;
 }
 
 static int pl030_read_time(struct device *dev, struct rtc_time *tm)
 {
 	struct pl030_rtc *rtc = dev_get_drvdata(dev);
 
-	rtc_time_to_tm(readl(rtc->base + RTC_DR), tm);
+	rtc_time64_to_tm(readl(rtc->base + RTC_DR), tm);
 
 	return 0;
 }
@@ -72,14 +69,10 @@ static int pl030_read_time(struct device *dev, struct rtc_time *tm)
 static int pl030_set_time(struct device *dev, struct rtc_time *tm)
 {
 	struct pl030_rtc *rtc = dev_get_drvdata(dev);
-	unsigned long time;
-	int ret;
 
-	ret = rtc_tm_to_time(tm, &time);
-	if (ret == 0)
-		writel(time + 1, rtc->base + RTC_LR);
+	writel(rtc_tm_to_time64(tm) + 1, rtc->base + RTC_LR);
 
-	return ret;
+	return 0;
 }
 
 static const struct rtc_class_ops pl030_ops = {
Signature · 1 line
2.24.1