From: Nishanth Menon <nm@ti.com>
To: Tero Kristo <t-kristo@ti.com>,
a.zummo@towertech.it, alexandre.belloni@free-electrons.com
Cc: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com,
linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org
Subject: Re: [PATCH] rtc: ds1307: Fix alarm programming for mcp794xx
Date: Sat, 24 Oct 2015 09:44:37 -0500 [thread overview]
Message-ID: <562B9955.40308@ti.com> (raw)
In-Reply-To: <1445581797-19693-1-git-send-email-t-kristo@ti.com>
On 10/23/2015 01:29 AM, Tero Kristo wrote:
> mcp794xx alarm registers must be written in BCD format. However, the
> alarm programming logic neglected this by adding one to the value
> after bin2bcd conversion has been already done, writing bad values
> to month register in case the alarm being set is in October. In this
> case, the alarm month value becomes 0x0a instead of the expected 0x10.
>
> Fix by moving the +1 addition within the bin2bcd call also.
>
> Fixes: 1d1945d261a2 ("drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips")
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
Nice catch.
Acked-by: Nishanth Menon <nm@ti.com>
> ---
> drivers/rtc/rtc-ds1307.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index a705e64..188006c 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -718,9 +718,9 @@ static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t)
> regs[3] = bin2bcd(t->time.tm_sec);
> regs[4] = bin2bcd(t->time.tm_min);
> regs[5] = bin2bcd(t->time.tm_hour);
> - regs[6] = bin2bcd(t->time.tm_wday) + 1;
> + regs[6] = bin2bcd(t->time.tm_wday + 1);
> regs[7] = bin2bcd(t->time.tm_mday);
> - regs[8] = bin2bcd(t->time.tm_mon) + 1;
> + regs[8] = bin2bcd(t->time.tm_mon + 1);
>
> /* Clear the alarm 0 interrupt flag. */
> regs[6] &= ~MCP794XX_BIT_ALMX_IF;
>
--
Regards,
Nishanth Menon
WARNING: multiple messages have this Message-ID (diff)
From: Nishanth Menon <nm@ti.com>
To: Tero Kristo <t-kristo@ti.com>, <a.zummo@towertech.it>,
<alexandre.belloni@free-electrons.com>
Cc: <linux-kernel@vger.kernel.org>, <rtc-linux@googlegroups.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-omap@vger.kernel.org>
Subject: [rtc-linux] Re: [PATCH] rtc: ds1307: Fix alarm programming for mcp794xx
Date: Sat, 24 Oct 2015 09:44:37 -0500 [thread overview]
Message-ID: <562B9955.40308@ti.com> (raw)
In-Reply-To: <1445581797-19693-1-git-send-email-t-kristo@ti.com>
On 10/23/2015 01:29 AM, Tero Kristo wrote:
> mcp794xx alarm registers must be written in BCD format. However, the
> alarm programming logic neglected this by adding one to the value
> after bin2bcd conversion has been already done, writing bad values
> to month register in case the alarm being set is in October. In this
> case, the alarm month value becomes 0x0a instead of the expected 0x10.
>
> Fix by moving the +1 addition within the bin2bcd call also.
>
> Fixes: 1d1945d261a2 ("drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips")
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
Nice catch.
Acked-by: Nishanth Menon <nm@ti.com>
> ---
> drivers/rtc/rtc-ds1307.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index a705e64..188006c 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -718,9 +718,9 @@ static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t)
> regs[3] = bin2bcd(t->time.tm_sec);
> regs[4] = bin2bcd(t->time.tm_min);
> regs[5] = bin2bcd(t->time.tm_hour);
> - regs[6] = bin2bcd(t->time.tm_wday) + 1;
> + regs[6] = bin2bcd(t->time.tm_wday + 1);
> regs[7] = bin2bcd(t->time.tm_mday);
> - regs[8] = bin2bcd(t->time.tm_mon) + 1;
> + regs[8] = bin2bcd(t->time.tm_mon + 1);
>
> /* Clear the alarm 0 interrupt flag. */
> regs[6] &= ~MCP794XX_BIT_ALMX_IF;
>
--
Regards,
Nishanth Menon
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
WARNING: multiple messages have this Message-ID (diff)
From: nm@ti.com (Nishanth Menon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] rtc: ds1307: Fix alarm programming for mcp794xx
Date: Sat, 24 Oct 2015 09:44:37 -0500 [thread overview]
Message-ID: <562B9955.40308@ti.com> (raw)
In-Reply-To: <1445581797-19693-1-git-send-email-t-kristo@ti.com>
On 10/23/2015 01:29 AM, Tero Kristo wrote:
> mcp794xx alarm registers must be written in BCD format. However, the
> alarm programming logic neglected this by adding one to the value
> after bin2bcd conversion has been already done, writing bad values
> to month register in case the alarm being set is in October. In this
> case, the alarm month value becomes 0x0a instead of the expected 0x10.
>
> Fix by moving the +1 addition within the bin2bcd call also.
>
> Fixes: 1d1945d261a2 ("drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips")
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
Nice catch.
Acked-by: Nishanth Menon <nm@ti.com>
> ---
> drivers/rtc/rtc-ds1307.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index a705e64..188006c 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -718,9 +718,9 @@ static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t)
> regs[3] = bin2bcd(t->time.tm_sec);
> regs[4] = bin2bcd(t->time.tm_min);
> regs[5] = bin2bcd(t->time.tm_hour);
> - regs[6] = bin2bcd(t->time.tm_wday) + 1;
> + regs[6] = bin2bcd(t->time.tm_wday + 1);
> regs[7] = bin2bcd(t->time.tm_mday);
> - regs[8] = bin2bcd(t->time.tm_mon) + 1;
> + regs[8] = bin2bcd(t->time.tm_mon + 1);
>
> /* Clear the alarm 0 interrupt flag. */
> regs[6] &= ~MCP794XX_BIT_ALMX_IF;
>
--
Regards,
Nishanth Menon
WARNING: multiple messages have this Message-ID (diff)
From: Nishanth Menon <nm@ti.com>
To: Tero Kristo <t-kristo@ti.com>, <a.zummo@towertech.it>,
<alexandre.belloni@free-electrons.com>
Cc: <linux-kernel@vger.kernel.org>, <rtc-linux@googlegroups.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-omap@vger.kernel.org>
Subject: Re: [PATCH] rtc: ds1307: Fix alarm programming for mcp794xx
Date: Sat, 24 Oct 2015 09:44:37 -0500 [thread overview]
Message-ID: <562B9955.40308@ti.com> (raw)
In-Reply-To: <1445581797-19693-1-git-send-email-t-kristo@ti.com>
On 10/23/2015 01:29 AM, Tero Kristo wrote:
> mcp794xx alarm registers must be written in BCD format. However, the
> alarm programming logic neglected this by adding one to the value
> after bin2bcd conversion has been already done, writing bad values
> to month register in case the alarm being set is in October. In this
> case, the alarm month value becomes 0x0a instead of the expected 0x10.
>
> Fix by moving the +1 addition within the bin2bcd call also.
>
> Fixes: 1d1945d261a2 ("drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips")
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
Nice catch.
Acked-by: Nishanth Menon <nm@ti.com>
> ---
> drivers/rtc/rtc-ds1307.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index a705e64..188006c 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -718,9 +718,9 @@ static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t)
> regs[3] = bin2bcd(t->time.tm_sec);
> regs[4] = bin2bcd(t->time.tm_min);
> regs[5] = bin2bcd(t->time.tm_hour);
> - regs[6] = bin2bcd(t->time.tm_wday) + 1;
> + regs[6] = bin2bcd(t->time.tm_wday + 1);
> regs[7] = bin2bcd(t->time.tm_mday);
> - regs[8] = bin2bcd(t->time.tm_mon) + 1;
> + regs[8] = bin2bcd(t->time.tm_mon + 1);
>
> /* Clear the alarm 0 interrupt flag. */
> regs[6] &= ~MCP794XX_BIT_ALMX_IF;
>
--
Regards,
Nishanth Menon
next prev parent reply other threads:[~2015-10-24 14:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 6:29 [PATCH] rtc: ds1307: Fix alarm programming for mcp794xx Tero Kristo
2015-10-23 6:29 ` Tero Kristo
2015-10-23 6:29 ` Tero Kristo
2015-10-23 6:29 ` [rtc-linux] " Tero Kristo
2015-10-24 14:44 ` Nishanth Menon [this message]
2015-10-24 14:44 ` Nishanth Menon
2015-10-24 14:44 ` Nishanth Menon
2015-10-24 14:44 ` [rtc-linux] " Nishanth Menon
2015-10-27 22:53 ` Alexandre Belloni
2015-10-27 22:53 ` Alexandre Belloni
2015-10-27 22:53 ` [rtc-linux] " 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=562B9955.40308@ti.com \
--to=nm@ti.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
--cc=t-kristo@ti.com \
/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 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.