When reading the seconds register, all time/date registers are frozen until the year register is read. So, read all time/date registers in one turn.
Signed-off-by: Juergen Borleis <j...@pengutronix.de> --- drivers/rtc/rtc-pcf85063.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c index 63334cb..75f2866 100644 --- a/drivers/rtc/rtc-pcf85063.c +++ b/drivers/rtc/rtc-pcf85063.c @@ -39,6 +39,38 @@ struct pcf85063 { int voltage_low; /* indicates if a low_voltage was detected */ }; +static int pcf85063_read_time(struct i2c_client *client, u8 *buf, u16 size) +{ + int rc; + u8 clk_ctrl = PCF85063_REG_SC; + struct i2c_msg msgs[] = { + { + .addr = client->addr, + .len = sizeof(clk_ctrl), + .buf = &clk_ctrl, + }, { + .addr = client->addr, + .flags = I2C_M_RD, + .len = size, + .buf = buf + }, + }; + + /* + * while reading the time/date registers are blocked and not updated + * anymore until the access is finished. To not lose a second + * event, the access must be finished within one second. So, read all + * time/date registers in one turn. + */ + rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + if (rc != ARRAY_SIZE(msgs)) { + dev_err(&client->dev, "date/time register read error\n"); + return -EIO; + } + + return 0; +} + /* * In the routines that deal directly with the pcf85063 hardware, we use * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch. -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/