linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@linux-mips.org>
To: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] rtc: m41t80: Correct alarm month range with RTC reads
Date: Wed, 7 Nov 2018 02:39:13 +0000 (GMT)	[thread overview]
Message-ID: <alpine.LFD.2.21.1811070053580.20378@eddie.linux-mips.org> (raw)

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;

             reply	other threads:[~2018-11-07  2:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07  2:39 Maciej W. Rozycki [this message]
2018-11-14  9:47 ` [PATCH] rtc: m41t80: Correct alarm month range with RTC reads Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.21.1811070053580.20378@eddie.linux-mips.org \
    --to=macro@linux-mips.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).