2007-08-23 06:34:17

by Mike Rapoport

[permalink] [raw]
Subject: [PATCH] RTC v3020 fixes

Signed-off-by: Mike Rapoport <[email protected]>
Acked-by: Raphael Assenat <[email protected]>

diff --git a/drivers/char/emv3020.c b/drivers/char/emv3020.c
index df7f1a4..1d93269 100644
--- a/drivers/char/emv3020.c
+++ b/drivers/char/emv3020.c
@@ -48,12 +48,16 @@ static void emv3020_set_reg(unsigned char address, unsigned char data)
{
int i;

- for ( i = 0; i < 4; i++ )
+ for ( i = 0; i < 4; i++ ) {
writel((address << (16-i)), EMV3020_VA_RTC);
+ udelay(1);
+ }

if ( address < 0xe)
- for ( i = 0; i < 8; i++)
+ for ( i = 0; i < 8; i++) {
writel((data << (16-i)), EMV3020_VA_RTC);
+ udelay(1);
+ }
}

static unsigned char emv3020_get_reg(unsigned char address)
@@ -61,12 +65,16 @@ static unsigned char emv3020_get_reg(unsigned char address)
unsigned int data=0;
int i, tmp;

- for ( i = 0; i < 4; i++ )
+ for ( i = 0; i < 4; i++ ) {
writel((address << (16-i)), EMV3020_VA_RTC);
+ udelay(1);
+ }
+

for ( i = 0; i < 8; i++ ) {
tmp = readl(EMV3020_VA_RTC);
data |= ((tmp & 0x10000) >> (16 - i));
+ udelay(1);
}

return data;
@@ -108,7 +116,7 @@ static int emv3020_rtc_gettime(struct rtc_time *dt)
BCD_TO_BIN(dt->tm_min);
BCD_TO_BIN(dt->tm_hour);
BCD_TO_BIN(dt->tm_mday);
- BCD_TO_BIN(dt->tm_mon);
+ BCD_TO_BIN(dt->tm_mon - 1);
BCD_TO_BIN(dt->tm_wday);
BCD_TO_BIN(dt->tm_year);
dt->tm_year += 100;
@@ -148,7 +156,7 @@ static int emv3020_rtc_settime(struct rtc_time *dt)
emv3020_set_reg(0x03, dt->tm_min);
emv3020_set_reg(0x04, dt->tm_hour);
emv3020_set_reg(0x05, dt->tm_mday);
- emv3020_set_reg(0x06, dt->tm_mon);
+ emv3020_set_reg(0x06, dt->tm_mon + 1);
emv3020_set_reg(0x08, dt->tm_wday);
emv3020_set_reg(0x07, dt->tm_year);



2007-08-23 06:43:56

by Satyam Sharma

[permalink] [raw]
Subject: Re: [PATCH] RTC v3020 fixes

Hi,


On Thu, 23 Aug 2007, Mike Rapoport wrote:

No changelog for patch ?!

> - for ( i = 0; i < 4; i++ )
> + for ( i = 0; i < 4; i++ ) {
> writel((address << (16-i)), EMV3020_VA_RTC);
> + udelay(1);
> + }
> +
>

^ Spurious extra newline here.

> - BCD_TO_BIN(dt->tm_mon);
> + BCD_TO_BIN(dt->tm_mon - 1);

> - emv3020_set_reg(0x06, dt->tm_mon);
> + emv3020_set_reg(0x06, dt->tm_mon + 1);

Why? (looks unrelated to the udelay() fixes as well)

2007-08-23 07:40:43

by Mike Rapoport

[permalink] [raw]
Subject: Re: [PATCH] RTC v3020 fixes

Satyam Sharma wrote:
> Hi,
>
>
> On Thu, 23 Aug 2007, Mike Rapoport wrote:
>
> No changelog for patch ?!
>

Ooops. The wrong file from the wrong place. Sorry for the noise.