Skip to contentSkip to conversation

rtc: mv: let the core handle invalid alarms

PATCH In review Alexandre Belloni 2 participants 2 messages Oct 1, 2018 – Oct 2, 2018 Real time clock (RTC)

lore
Share & tools
lore

Alexandre Belloni

author maintainer
#0 lore raw

PATCH 1/1 rtc: mv: let the core handle invalid alarms

Instead of lying to the core when the alarm is invalid, let it handle that by returning the error.

---
 drivers/rtc/rtc-mv.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/rtc/rtc-mv.c +2 -6
index 4b198b3778d3..e7f14bd12fe3 100644
@@ -125,13 +125,9 @@ static int mv_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
 	/* hw counts from year 2000, but tm_year is relative to 1900 */
 	alm->time.tm_year = bcd2bin(year) + 100;
 
-	if (rtc_valid_tm(&alm->time) < 0) {
-		dev_err(dev, "retrieved alarm date/time is not valid.\n");
-		rtc_time_to_tm(0, &alm->time);
-	}
-
 	alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
-	return 0;
+
+	return rtc_valid_tm(&alm->time);
 }
 
 static int mv_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
Signature · 1 line
2.19.0
Tested-by on v1 1/1
#1 lore raw

Hi Alexandre,

Quoted 4 lines · Alexandre Belloni

Instead of lying to the core when the alarm is invalid, let it handle that by returning the error.

Gregory

Quoted 27 lines
---
 drivers/rtc/rtc-mv.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/rtc/rtc-mv.c +2 -6
index 4b198b3778d3..e7f14bd12fe3 100644
@@ -125,13 +125,9 @@ static int mv_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
 	/* hw counts from year 2000, but tm_year is relative to 1900 */
 	alm->time.tm_year = bcd2bin(year) + 100;
 
-	if (rtc_valid_tm(&alm->time) < 0) {
-		dev_err(dev, "retrieved alarm date/time is not valid.\n");
-		rtc_time_to_tm(0, &alm->time);
-	}
-
 	alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
-	return 0;
+
+	return rtc_valid_tm(&alm->time);
 }
 
 static int mv_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
Signature · 1 line
2.19.0
Signature · 3 lines
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com