[PATCH] rtc: m41t80: Correct alarm month range with RTC reads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
Fixes: 9c6dfed92c3e ("rtc: m41t80: add alarm functionality")
References: 48e9766726eb ("drivers/rtc/rtc-m41t80.c: remove disabled alarm functionality")
Cc: stable@xxxxxxxxxxxxxxx # 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;



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux