From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Cc: Ilya Ledvich <ilya@compulab.co.il>, linux-rtc@vger.kernel.org
Subject: Re: [PATCH] rtc: em3027: correct month value
Date: Thu, 31 Oct 2019 11:27:17 +0100 [thread overview]
Message-ID: <20191031102717.GB2967@piout.net> (raw)
In-Reply-To: <CABMQnVJ-Y4fiE3LnS=JpGHyGdf11KTf0xnmnd-5h5=zpQAx0TQ@mail.gmail.com>
On 31/10/2019 18:53:00+0900, Nobuhiro Iwamatsu wrote:
> Hi,
>
> 2019年10月31日(木) 16:57 Ilya Ledvich <ilya@compulab.co.il>:
> >
> > The RTC month value is 1-indexed, but the kernel assumes it is 0-indexed.
> > This may result in the RTC not rolling over correctly.
> >
> > Signed-off-by: Ilya Ledvich <ilya@compulab.co.il>
> > ---
> > drivers/rtc/rtc-em3027.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/rtc/rtc-em3027.c b/drivers/rtc/rtc-em3027.c
> > index 77cca1392253..ef3792543f93 100644
> > --- a/drivers/rtc/rtc-em3027.c
> > +++ b/drivers/rtc/rtc-em3027.c
> > @@ -71,7 +71,7 @@ static int em3027_get_time(struct device *dev, struct rtc_time *tm)
> > tm->tm_hour = bcd2bin(buf[2]);
> > tm->tm_mday = bcd2bin(buf[3]);
> > tm->tm_wday = bcd2bin(buf[4]);
> > - tm->tm_mon = bcd2bin(buf[5]);
> > + tm->tm_mon = bcd2bin(buf[5]) - 1;
> > tm->tm_year = bcd2bin(buf[6]) + 100;
> >
> > return 0;
> > @@ -94,7 +94,7 @@ static int em3027_set_time(struct device *dev, struct rtc_time *tm)
> > buf[3] = bin2bcd(tm->tm_hour);
> > buf[4] = bin2bcd(tm->tm_mday);
> > buf[5] = bin2bcd(tm->tm_wday);
> > - buf[6] = bin2bcd(tm->tm_mon);
> > + buf[6] = bin2bcd(tm->tm_mon) + 1;
>
> I think '+'1 should be set in bin2bcd().
>
This is correct.
Ilya, could you also run
https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/rtc-tools.git/tree/rtc-range.c
on that rtc? I'm interested in the full output. It seems this RTC
working range is 2000 to 2079
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2019-10-31 10:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-31 7:36 [PATCH] rtc: em3027: correct month value Ilya Ledvich
2019-10-31 9:53 ` Nobuhiro Iwamatsu
2019-10-31 10:27 ` Alexandre Belloni [this message]
2019-10-31 12:07 ` Ilya Ledvich
2019-10-31 12:16 ` Ilya Ledvich
2019-11-01 9:54 ` [PATCH v2] " Ilya Ledvich
2019-11-04 1:10 ` Nobuhiro Iwamatsu
2019-11-05 17:19 ` 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=20191031102717.GB2967@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=ilya@compulab.co.il \
--cc=iwamatsu@nigauri.org \
--cc=linux-rtc@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).