linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: m41t80: Correct alarm month range with RTC reads
@ 2018-11-07  2:39 Maciej W. Rozycki
  2018-11-14  9:47 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Maciej W. Rozycki @ 2018-11-07  2:39 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, linux-kernel, stable

Add the missing adjustment of the month range on alarm reads from the 
RTC, correcting an issue coming from commit 9c6dfed92c3e ("rtc: m41t80: 
add alarm functionality").  The range is 1-12 for hardware and 0-11 for 
`struct rtc_time', and is already correctly handled on alarm writes to 
the RTC.

It was correct up until commit 48e9766726eb ("drivers/rtc/rtc-m41t80.c: 
remove disabled alarm functionality") too, which removed the previous 
implementation of alarm support.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: 9c6dfed92c3e ("rtc: m41t80: add alarm functionality")
References: 48e9766726eb ("drivers/rtc/rtc-m41t80.c: remove disabled alarm functionality")
Cc: stable@vger.kernel.org # 4.7+
---
Hi,

 I have no means to verify this change at run time as my M41T81 device, 
which is the reason for me to use this driver, regrettably hasn't got its 
IRQ line routed, due to historical reasons I gathered, as it replaced a 
different RTC device, that didn't have an IRQ output at all, used with 
earlier revisions of the Broadcom SiByte SWARM board I have been using 
this code with.  However it should be obvious by code inspection.

 Please apply and backport as appropriate.

  Maciej
---
 drivers/rtc/rtc-m41t80.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

linux-rtc-m41t80-read-alarm-month.diff
Index: linux-20181008-swarm64-eb/drivers/rtc/rtc-m41t80.c
===================================================================
--- linux-20181008-swarm64-eb.orig/drivers/rtc/rtc-m41t80.c
+++ linux-20181008-swarm64-eb/drivers/rtc/rtc-m41t80.c
@@ -393,7 +393,7 @@ static int m41t80_read_alarm(struct devi
 	alrm->time.tm_min  = bcd2bin(alarmvals[3] & 0x7f);
 	alrm->time.tm_hour = bcd2bin(alarmvals[2] & 0x3f);
 	alrm->time.tm_mday = bcd2bin(alarmvals[1] & 0x3f);
-	alrm->time.tm_mon  = bcd2bin(alarmvals[0] & 0x3f);
+	alrm->time.tm_mon  = bcd2bin(alarmvals[0] & 0x3f) - 1;
 
 	alrm->enabled = !!(alarmvals[0] & M41T80_ALMON_AFE);
 	alrm->pending = (flags & M41T80_FLAGS_AF) && alrm->enabled;

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

end of thread, other threads:[~2018-11-14  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07  2:39 [PATCH] rtc: m41t80: Correct alarm month range with RTC reads Maciej W. Rozycki
2018-11-14  9:47 ` Alexandre Belloni

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).