From 7b4c86b3b1fc64a242458ce05932e14c4b7d41d9 Mon Sep 17 00:00:00 2001 From: Rudolf Marek Date: Tue, 27 Jul 2010 13:18:02 -0700 Subject: [PATCH] --- yaml --- r: 201329 b: refs/heads/master c: 2884fce165047db7df422e52a672970fa09c87b5 h: refs/heads/master i: 201327: 1ccd7d5726a0f5c913dcd8c463b86f232661e462 v: v3 --- [refs] | 2 +- trunk/drivers/rtc/rtc-rx8581.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index f83e30f39c2a..85e65d1a2f4a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b82bab4bbe9efa7bc7177fc20620fff19bd95484 +refs/heads/master: 2884fce165047db7df422e52a672970fa09c87b5 diff --git a/trunk/drivers/rtc/rtc-rx8581.c b/trunk/drivers/rtc/rtc-rx8581.c index 9718aaaa8215..600b890a3c15 100644 --- a/trunk/drivers/rtc/rtc-rx8581.c +++ b/trunk/drivers/rtc/rtc-rx8581.c @@ -168,7 +168,7 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm) return -EIO; } - err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, + err = i2c_smbus_write_byte_data(client, RX8581_REG_CTRL, (data | RX8581_CTRL_STOP)); if (err < 0) { dev_err(&client->dev, "Unable to write control register\n"); @@ -182,6 +182,20 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm) return -EIO; } + /* get VLF and clear it */ + data = i2c_smbus_read_byte_data(client, RX8581_REG_FLAG); + if (data < 0) { + dev_err(&client->dev, "Unable to read flag register\n"); + return -EIO; + } + + err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, + (data & ~(RX8581_FLAG_VLF))); + if (err != 0) { + dev_err(&client->dev, "Unable to write flag register\n"); + return -EIO; + } + /* Restart the clock */ data = i2c_smbus_read_byte_data(client, RX8581_REG_CTRL); if (data < 0) { @@ -189,8 +203,8 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm) return -EIO; } - err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, - (data | ~(RX8581_CTRL_STOP))); + err = i2c_smbus_write_byte_data(client, RX8581_REG_CTRL, + (data & ~(RX8581_CTRL_STOP))); if (err != 0) { dev_err(&client->dev, "Unable to write control register\n"); return -EIO;