public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <mike@compulab.co.il>
To: "Raphaël Assénat" <raph@8d.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Alessandro Zummo <a.zummo@towertech.it>
Subject: Re: [PATCH] RTC v3020 fixes
Date: Wed, 15 Aug 2007 17:02:37 +0300	[thread overview]
Message-ID: <46C3077D.4000307@compulab.co.il> (raw)
In-Reply-To: <46C2F8C9.6020806@8d.com>

Raphaël Assénat wrote:
> Mike Rapoport wrote:
>> Fix off-by-one in month calculations
>> Add delay for bus accesses to satisfy Tw > 500ns
>>
> *snip*
>> @@ -135,7 +140,7 @@ static int v3020_set_time(struct device *dev, 
>> struct rtc_time *dt)
>>      v3020_set_reg(chip, V3020_MINUTES,     BIN2BCD(dt->tm_min));
>>      v3020_set_reg(chip, V3020_HOURS,     BIN2BCD(dt->tm_hour));
>>      v3020_set_reg(chip, V3020_MONTH_DAY,    BIN2BCD(dt->tm_mday));
>> -    v3020_set_reg(chip, V3020_MONTH,     BIN2BCD(dt->tm_mon));
>> +    v3020_set_reg(chip, V3020_MONTH,     BIN2BCD(dt->tm_mon) + 1);
> 
> This should be BIN2BCD(dt->tm_mon + 1)) instead. Otherwise, in october 
> (month 9), the final value will be 0xa instead of 0x10.

Fixed.


> Other than that, the patch looks fine to me. You can add
> Acked-by: Raphael Assenat <raph@8d.com> to the updated patch.
> 
> Please add Alessandro Zummo <a.zummo@towertech.it> in the CC list to 
> make sure he sees it.
> 
> Best regards,
> Raphaël Assénat

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Acked-by: Raphael Assenat <raph@8d.com>

  drivers/rtc/rtc-v3020.c |    9 +++++++--
  1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index 3b58d3d..e96d667 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -26,6 +26,7 @@
  #include <linux/types.h>
  #include <linux/bcd.h>
  #include <linux/rtc-v3020.h>
+#include <linux/delay.h>

  #include <asm/io.h>

@@ -47,6 +48,7 @@ static void v3020_set_reg(struct v3020 *chip, unsigned char 
address,
  	for (i = 0; i < 4; i++) {
  		writel((tmp & 1) << chip->leftshift, chip->ioaddress);
  		tmp >>= 1;
+		udelay(1);
  	}

  	/* Commands dont have data */
@@ -54,6 +56,7 @@ static void v3020_set_reg(struct v3020 *chip, unsigned char 
address,
  		for (i = 0; i < 8; i++) {
  			writel((data & 1) << chip->leftshift, chip->ioaddress);
  			data >>= 1;
+			udelay(1);
  		}
  	}
  }
@@ -66,12 +69,14 @@ static unsigned char v3020_get_reg(struct v3020 *chip, 
unsigned char address)
  	for (i = 0; i < 4; i++) {
  		writel((address & 1) << chip->leftshift, chip->ioaddress);
  		address >>= 1;
+		udelay(1);
  	}

  	for (i = 0; i < 8; i++) {
  		data >>= 1;
  		if (readl(chip->ioaddress) & (1 << chip->leftshift))
  			data |= 0x80;
+		udelay(1);
  	}

  	return data;
@@ -95,7 +100,7 @@ static int v3020_read_time(struct device *dev, struct 
rtc_time *dt)
  	tmp = v3020_get_reg(chip, V3020_MONTH_DAY);
  	dt->tm_mday	= BCD2BIN(tmp);
  	tmp = v3020_get_reg(chip, V3020_MONTH);
-	dt->tm_mon	= BCD2BIN(tmp);
+	dt->tm_mon	= BCD2BIN(tmp) - 1;
  	tmp = v3020_get_reg(chip, V3020_WEEK_DAY);
  	dt->tm_wday	= BCD2BIN(tmp);
  	tmp = v3020_get_reg(chip, V3020_YEAR);
@@ -135,7 +140,7 @@ static int v3020_set_time(struct device *dev, struct 
rtc_time *dt)
  	v3020_set_reg(chip, V3020_MINUTES, 	BIN2BCD(dt->tm_min));
  	v3020_set_reg(chip, V3020_HOURS, 	BIN2BCD(dt->tm_hour));
  	v3020_set_reg(chip, V3020_MONTH_DAY,	BIN2BCD(dt->tm_mday));
-	v3020_set_reg(chip, V3020_MONTH, 	BIN2BCD(dt->tm_mon));
+	v3020_set_reg(chip, V3020_MONTH, 	BIN2BCD(dt->tm_mon + 1));
  	v3020_set_reg(chip, V3020_WEEK_DAY, 	BIN2BCD(dt->tm_wday));
  	v3020_set_reg(chip, V3020_YEAR, 	BIN2BCD(dt->tm_year % 100));



-- 
Sincerely yours,
Mike.


  reply	other threads:[~2007-08-15 14:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-15  5:45 [PATCH] RTC v3020 fixes Mike Rapoport
2007-08-15 12:59 ` Raphaël Assénat
2007-08-15 14:02   ` Mike Rapoport [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-08-23  6:28 Mike Rapoport
2007-08-23  6:56 ` Satyam Sharma
2007-08-23  7:34   ` Mike

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=46C3077D.4000307@compulab.co.il \
    --to=mike@compulab.co.il \
    --cc=a.zummo@towertech.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raph@8d.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox