Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drivers/rtc/rtc-rx8581.c: fix setdatetime

Fix the logic while writing new date/time to the chip. The driver
incorrectly wrote back register values to different registers and even
with wrong mask. The patch adds clearing of the VLF register, which
should be cleared if all date/time values are set.

Signed-off-by: Rudolf Marek <rudolf.marek@sysgo.com>
Acked-by: Wan ZongShun <mcuos.com@gmail.com>
Cc: Martyn Welch <martyn.welch@gefanuc.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Rudolf Marek and committed by
Linus Torvalds
2884fce1 b82bab4b

+17 -3
+17 -3
drivers/rtc/rtc-rx8581.c
··· 168 168 return -EIO; 169 169 } 170 170 171 - err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, 171 + err = i2c_smbus_write_byte_data(client, RX8581_REG_CTRL, 172 172 (data | RX8581_CTRL_STOP)); 173 173 if (err < 0) { 174 174 dev_err(&client->dev, "Unable to write control register\n"); ··· 182 182 return -EIO; 183 183 } 184 184 185 + /* get VLF and clear it */ 186 + data = i2c_smbus_read_byte_data(client, RX8581_REG_FLAG); 187 + if (data < 0) { 188 + dev_err(&client->dev, "Unable to read flag register\n"); 189 + return -EIO; 190 + } 191 + 192 + err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, 193 + (data & ~(RX8581_FLAG_VLF))); 194 + if (err != 0) { 195 + dev_err(&client->dev, "Unable to write flag register\n"); 196 + return -EIO; 197 + } 198 + 185 199 /* Restart the clock */ 186 200 data = i2c_smbus_read_byte_data(client, RX8581_REG_CTRL); 187 201 if (data < 0) { ··· 203 189 return -EIO; 204 190 } 205 191 206 - err = i2c_smbus_write_byte_data(client, RX8581_REG_FLAG, 207 - (data | ~(RX8581_CTRL_STOP))); 192 + err = i2c_smbus_write_byte_data(client, RX8581_REG_CTRL, 193 + (data & ~(RX8581_CTRL_STOP))); 208 194 if (err != 0) { 209 195 dev_err(&client->dev, "Unable to write control register\n"); 210 196 return -EIO;