All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] rtc: at91rm9200: stop calculating yday in at91_rtc_readalarm
@ 2017-11-10  8:59 ` Alexandre Belloni
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2017-11-10  8:59 UTC (permalink / raw)
  To: linux-rtc
  Cc: Nicolas Ferre, linux-arm-kernel, linux-kernel, Alexandre Belloni

Calculating yday in the read_alarm callback is useless as this value is
never used later. Also, it was buggy anyway because at the time this is
done, tm_year is always 0 as the alarm register doesn't hold the year.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/rtc/rtc-at91rm9200.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index e221b78b6f10..e84f5ec4faf6 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -208,7 +208,6 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	struct rtc_time *tm = &alrm->time;
 
 	at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
-	tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
 	tm->tm_year = at91_alarm_year - 1900;
 
 	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/2] rtc: at91rm9200: stop calculating yday in at91_rtc_readalarm
@ 2017-11-10  8:59 ` Alexandre Belloni
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2017-11-10  8:59 UTC (permalink / raw)
  To: linux-arm-kernel

Calculating yday in the read_alarm callback is useless as this value is
never used later. Also, it was buggy anyway because at the time this is
done, tm_year is always 0 as the alarm register doesn't hold the year.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/rtc/rtc-at91rm9200.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index e221b78b6f10..e84f5ec4faf6 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -208,7 +208,6 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	struct rtc_time *tm = &alrm->time;
 
 	at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
-	tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
 	tm->tm_year = at91_alarm_year - 1900;
 
 	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] rtc: at91rm9200: fix reading alarm value
  2017-11-10  8:59 ` Alexandre Belloni
@ 2017-11-10  8:59   ` Alexandre Belloni
  -1 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2017-11-10  8:59 UTC (permalink / raw)
  To: linux-rtc
  Cc: Nicolas Ferre, linux-arm-kernel, linux-kernel, Alexandre Belloni

When alarm value is read at boot time, at91_alarm_year is not yet set to
the proper value so the year is always set to 1900.

This results in that kind of message at boot:
rtc rtc0: invalid alarm value: 1900-1-14 2:11:39

There is no way to recover from that as the alarm is now only read when
booting.

Instead, rely on the rtc core to figure out the proper year.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/rtc/rtc-at91rm9200.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index e84f5ec4faf6..de81ecedd571 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -42,8 +42,6 @@
 #define at91_rtc_write(field, val) \
 	writel_relaxed((val), at91_rtc_regs + field)
 
-#define AT91_RTC_EPOCH		1900UL	/* just like arch/arm/common/rtctime.c */
-
 struct at91_rtc_config {
 	bool use_shadow_imr;
 };
@@ -51,7 +49,6 @@ struct at91_rtc_config {
 static const struct at91_rtc_config *at91_rtc_config;
 static DECLARE_COMPLETION(at91_rtc_updated);
 static DECLARE_COMPLETION(at91_rtc_upd_rdy);
-static unsigned int at91_alarm_year = AT91_RTC_EPOCH;
 static void __iomem *at91_rtc_regs;
 static int irq;
 static DEFINE_SPINLOCK(at91_rtc_lock);
@@ -131,8 +128,7 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg,
 
 	/*
 	 * The Calendar Alarm register does not have a field for
-	 * the year - so these will return an invalid value.  When an
-	 * alarm is set, at91_alarm_year will store the current year.
+	 * the year - so these will return an invalid value.
 	 */
 	tm->tm_year  = bcd2bin(date & AT91_RTC_CENT) * 100;	/* century */
 	tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8);	/* year */
@@ -208,14 +204,14 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	struct rtc_time *tm = &alrm->time;
 
 	at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
-	tm->tm_year = at91_alarm_year - 1900;
+	tm->tm_year = -1;
 
 	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
 			? 1 : 0;
 
-	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
-		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "%s(): %02d-%02d %02d:%02d:%02d %sabled\n", __func__,
+		tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
+		alrm->enabled ? "en" : "dis");
 
 	return 0;
 }
@@ -229,8 +225,6 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 	at91_rtc_decodetime(AT91_RTC_TIMR, AT91_RTC_CALR, &tm);
 
-	at91_alarm_year = tm.tm_year;
-
 	tm.tm_mon = alrm->time.tm_mon;
 	tm.tm_mday = alrm->time.tm_mday;
 	tm.tm_hour = alrm->time.tm_hour;
@@ -254,7 +248,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	}
 
 	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
-		at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
+		tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
 		tm.tm_min, tm.tm_sec);
 
 	return 0;
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] rtc: at91rm9200: fix reading alarm value
@ 2017-11-10  8:59   ` Alexandre Belloni
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2017-11-10  8:59 UTC (permalink / raw)
  To: linux-arm-kernel

When alarm value is read at boot time, at91_alarm_year is not yet set to
the proper value so the year is always set to 1900.

This results in that kind of message at boot:
rtc rtc0: invalid alarm value: 1900-1-14 2:11:39

There is no way to recover from that as the alarm is now only read when
booting.

Instead, rely on the rtc core to figure out the proper year.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/rtc/rtc-at91rm9200.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index e84f5ec4faf6..de81ecedd571 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -42,8 +42,6 @@
 #define at91_rtc_write(field, val) \
 	writel_relaxed((val), at91_rtc_regs + field)
 
-#define AT91_RTC_EPOCH		1900UL	/* just like arch/arm/common/rtctime.c */
-
 struct at91_rtc_config {
 	bool use_shadow_imr;
 };
@@ -51,7 +49,6 @@ struct at91_rtc_config {
 static const struct at91_rtc_config *at91_rtc_config;
 static DECLARE_COMPLETION(at91_rtc_updated);
 static DECLARE_COMPLETION(at91_rtc_upd_rdy);
-static unsigned int at91_alarm_year = AT91_RTC_EPOCH;
 static void __iomem *at91_rtc_regs;
 static int irq;
 static DEFINE_SPINLOCK(at91_rtc_lock);
@@ -131,8 +128,7 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg,
 
 	/*
 	 * The Calendar Alarm register does not have a field for
-	 * the year - so these will return an invalid value.  When an
-	 * alarm is set, at91_alarm_year will store the current year.
+	 * the year - so these will return an invalid value.
 	 */
 	tm->tm_year  = bcd2bin(date & AT91_RTC_CENT) * 100;	/* century */
 	tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8);	/* year */
@@ -208,14 +204,14 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	struct rtc_time *tm = &alrm->time;
 
 	at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
-	tm->tm_year = at91_alarm_year - 1900;
+	tm->tm_year = -1;
 
 	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
 			? 1 : 0;
 
-	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
-		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
-		tm->tm_hour, tm->tm_min, tm->tm_sec);
+	dev_dbg(dev, "%s(): %02d-%02d %02d:%02d:%02d %sabled\n", __func__,
+		tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
+		alrm->enabled ? "en" : "dis");
 
 	return 0;
 }
@@ -229,8 +225,6 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 	at91_rtc_decodetime(AT91_RTC_TIMR, AT91_RTC_CALR, &tm);
 
-	at91_alarm_year = tm.tm_year;
-
 	tm.tm_mon = alrm->time.tm_mon;
 	tm.tm_mday = alrm->time.tm_mday;
 	tm.tm_hour = alrm->time.tm_hour;
@@ -254,7 +248,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	}
 
 	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
-		at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
+		tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
 		tm.tm_min, tm.tm_sec);
 
 	return 0;
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] rtc: at91rm9200: stop calculating yday in at91_rtc_readalarm
  2017-11-10  8:59 ` Alexandre Belloni
@ 2017-11-10 13:41   ` Nicolas Ferre
  -1 siblings, 0 replies; 8+ messages in thread
From: Nicolas Ferre @ 2017-11-10 13:41 UTC (permalink / raw)
  To: Alexandre Belloni, linux-rtc; +Cc: linux-arm-kernel, linux-kernel

On 10/11/2017 at 09:59, Alexandre Belloni wrote:
> Calculating yday in the read_alarm callback is useless as this value is
> never used later. Also, it was buggy anyway because at the time this is
> done, tm_year is always 0 as the alarm register doesn't hold the year.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>  drivers/rtc/rtc-at91rm9200.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
> index e221b78b6f10..e84f5ec4faf6 100644
> --- a/drivers/rtc/rtc-at91rm9200.c
> +++ b/drivers/rtc/rtc-at91rm9200.c
> @@ -208,7 +208,6 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
>  	struct rtc_time *tm = &alrm->time;
>  
>  	at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
> -	tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
>  	tm->tm_year = at91_alarm_year - 1900;
>  
>  	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] rtc: at91rm9200: stop calculating yday in at91_rtc_readalarm
@ 2017-11-10 13:41   ` Nicolas Ferre
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Ferre @ 2017-11-10 13:41 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/11/2017 at 09:59, Alexandre Belloni wrote:
> Calculating yday in the read_alarm callback is useless as this value is
> never used later. Also, it was buggy anyway because at the time this is
> done, tm_year is always 0 as the alarm register doesn't hold the year.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>  drivers/rtc/rtc-at91rm9200.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
> index e221b78b6f10..e84f5ec4faf6 100644
> --- a/drivers/rtc/rtc-at91rm9200.c
> +++ b/drivers/rtc/rtc-at91rm9200.c
> @@ -208,7 +208,6 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
>  	struct rtc_time *tm = &alrm->time;
>  
>  	at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
> -	tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
>  	tm->tm_year = at91_alarm_year - 1900;
>  
>  	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] rtc: at91rm9200: fix reading alarm value
  2017-11-10  8:59   ` Alexandre Belloni
@ 2017-11-10 14:55     ` Nicolas Ferre
  -1 siblings, 0 replies; 8+ messages in thread
From: Nicolas Ferre @ 2017-11-10 14:55 UTC (permalink / raw)
  To: Alexandre Belloni, linux-rtc; +Cc: linux-arm-kernel, linux-kernel

On 10/11/2017 at 09:59, Alexandre Belloni wrote:
> When alarm value is read at boot time, at91_alarm_year is not yet set to
> the proper value so the year is always set to 1900.
> 
> This results in that kind of message at boot:
> rtc rtc0: invalid alarm value: 1900-1-14 2:11:39
> 
> There is no way to recover from that as the alarm is now only read when
> booting.
> 
> Instead, rely on the rtc core to figure out the proper year.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>  drivers/rtc/rtc-at91rm9200.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
> index e84f5ec4faf6..de81ecedd571 100644
> --- a/drivers/rtc/rtc-at91rm9200.c
> +++ b/drivers/rtc/rtc-at91rm9200.c
> @@ -42,8 +42,6 @@
>  #define at91_rtc_write(field, val) \
>  	writel_relaxed((val), at91_rtc_regs + field)
>  
> -#define AT91_RTC_EPOCH		1900UL	/* just like arch/arm/common/rtctime.c */
> -
>  struct at91_rtc_config {
>  	bool use_shadow_imr;
>  };
> @@ -51,7 +49,6 @@ struct at91_rtc_config {
>  static const struct at91_rtc_config *at91_rtc_config;
>  static DECLARE_COMPLETION(at91_rtc_updated);
>  static DECLARE_COMPLETION(at91_rtc_upd_rdy);
> -static unsigned int at91_alarm_year = AT91_RTC_EPOCH;
>  static void __iomem *at91_rtc_regs;
>  static int irq;
>  static DEFINE_SPINLOCK(at91_rtc_lock);
> @@ -131,8 +128,7 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg,
>  
>  	/*
>  	 * The Calendar Alarm register does not have a field for
> -	 * the year - so these will return an invalid value.  When an
> -	 * alarm is set, at91_alarm_year will store the current year.
> +	 * the year - so these will return an invalid value.
>  	 */
>  	tm->tm_year  = bcd2bin(date & AT91_RTC_CENT) * 100;	/* century */
>  	tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8);	/* year */
> @@ -208,14 +204,14 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
>  	struct rtc_time *tm = &alrm->time;
>  
>  	at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
> -	tm->tm_year = at91_alarm_year - 1900;
> +	tm->tm_year = -1;
>  
>  	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
>  			? 1 : 0;
>  
> -	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
> -		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
> -		tm->tm_hour, tm->tm_min, tm->tm_sec);
> +	dev_dbg(dev, "%s(): %02d-%02d %02d:%02d:%02d %sabled\n", __func__,
> +		tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
> +		alrm->enabled ? "en" : "dis");
>  
>  	return 0;
>  }
> @@ -229,8 +225,6 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
>  
>  	at91_rtc_decodetime(AT91_RTC_TIMR, AT91_RTC_CALR, &tm);
>  
> -	at91_alarm_year = tm.tm_year;
> -
>  	tm.tm_mon = alrm->time.tm_mon;
>  	tm.tm_mday = alrm->time.tm_mday;
>  	tm.tm_hour = alrm->time.tm_hour;
> @@ -254,7 +248,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
>  	}
>  
>  	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
> -		at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
> +		tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
>  		tm.tm_min, tm.tm_sec);
>  
>  	return 0;
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] rtc: at91rm9200: fix reading alarm value
@ 2017-11-10 14:55     ` Nicolas Ferre
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Ferre @ 2017-11-10 14:55 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/11/2017 at 09:59, Alexandre Belloni wrote:
> When alarm value is read at boot time, at91_alarm_year is not yet set to
> the proper value so the year is always set to 1900.
> 
> This results in that kind of message at boot:
> rtc rtc0: invalid alarm value: 1900-1-14 2:11:39
> 
> There is no way to recover from that as the alarm is now only read when
> booting.
> 
> Instead, rely on the rtc core to figure out the proper year.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>  drivers/rtc/rtc-at91rm9200.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
> index e84f5ec4faf6..de81ecedd571 100644
> --- a/drivers/rtc/rtc-at91rm9200.c
> +++ b/drivers/rtc/rtc-at91rm9200.c
> @@ -42,8 +42,6 @@
>  #define at91_rtc_write(field, val) \
>  	writel_relaxed((val), at91_rtc_regs + field)
>  
> -#define AT91_RTC_EPOCH		1900UL	/* just like arch/arm/common/rtctime.c */
> -
>  struct at91_rtc_config {
>  	bool use_shadow_imr;
>  };
> @@ -51,7 +49,6 @@ struct at91_rtc_config {
>  static const struct at91_rtc_config *at91_rtc_config;
>  static DECLARE_COMPLETION(at91_rtc_updated);
>  static DECLARE_COMPLETION(at91_rtc_upd_rdy);
> -static unsigned int at91_alarm_year = AT91_RTC_EPOCH;
>  static void __iomem *at91_rtc_regs;
>  static int irq;
>  static DEFINE_SPINLOCK(at91_rtc_lock);
> @@ -131,8 +128,7 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg,
>  
>  	/*
>  	 * The Calendar Alarm register does not have a field for
> -	 * the year - so these will return an invalid value.  When an
> -	 * alarm is set, at91_alarm_year will store the current year.
> +	 * the year - so these will return an invalid value.
>  	 */
>  	tm->tm_year  = bcd2bin(date & AT91_RTC_CENT) * 100;	/* century */
>  	tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8);	/* year */
> @@ -208,14 +204,14 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
>  	struct rtc_time *tm = &alrm->time;
>  
>  	at91_rtc_decodetime(AT91_RTC_TIMALR, AT91_RTC_CALALR, tm);
> -	tm->tm_year = at91_alarm_year - 1900;
> +	tm->tm_year = -1;
>  
>  	alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
>  			? 1 : 0;
>  
> -	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
> -		1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
> -		tm->tm_hour, tm->tm_min, tm->tm_sec);
> +	dev_dbg(dev, "%s(): %02d-%02d %02d:%02d:%02d %sabled\n", __func__,
> +		tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
> +		alrm->enabled ? "en" : "dis");
>  
>  	return 0;
>  }
> @@ -229,8 +225,6 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
>  
>  	at91_rtc_decodetime(AT91_RTC_TIMR, AT91_RTC_CALR, &tm);
>  
> -	at91_alarm_year = tm.tm_year;
> -
>  	tm.tm_mon = alrm->time.tm_mon;
>  	tm.tm_mday = alrm->time.tm_mday;
>  	tm.tm_hour = alrm->time.tm_hour;
> @@ -254,7 +248,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
>  	}
>  
>  	dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
> -		at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
> +		tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour,
>  		tm.tm_min, tm.tm_sec);
>  
>  	return 0;
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-11-10 14:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-10  8:59 [PATCH 1/2] rtc: at91rm9200: stop calculating yday in at91_rtc_readalarm Alexandre Belloni
2017-11-10  8:59 ` Alexandre Belloni
2017-11-10  8:59 ` [PATCH 2/2] rtc: at91rm9200: fix reading alarm value Alexandre Belloni
2017-11-10  8:59   ` Alexandre Belloni
2017-11-10 14:55   ` Nicolas Ferre
2017-11-10 14:55     ` Nicolas Ferre
2017-11-10 13:41 ` [PATCH 1/2] rtc: at91rm9200: stop calculating yday in at91_rtc_readalarm Nicolas Ferre
2017-11-10 13:41   ` Nicolas Ferre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.