mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-10 08:33:14 +00:00
rtc: pcf85063: preserve control register value between stop and start
Fix a bug that caused the Control_1 register to get zeroed whenever the RTC time is set. The problem occurred between stopping and starting the RTC clock, wherein the return value of a successful I2C write function would get written to the register. Also update variables of the start and stop functions to be more consistent with the rest of the driver. Signed-off-by: Alvin Šipraga <alvin@airtame.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
8856541557
commit
ec9cf1b7a6
1 changed files with 11 additions and 10 deletions
|
@ -43,37 +43,38 @@ static struct i2c_driver pcf85063_driver;
|
||||||
|
|
||||||
static int pcf85063_stop_clock(struct i2c_client *client, u8 *ctrl1)
|
static int pcf85063_stop_clock(struct i2c_client *client, u8 *ctrl1)
|
||||||
{
|
{
|
||||||
s32 ret;
|
int rc;
|
||||||
|
u8 reg;
|
||||||
|
|
||||||
ret = i2c_smbus_read_byte_data(client, PCF85063_REG_CTRL1);
|
rc = i2c_smbus_read_byte_data(client, PCF85063_REG_CTRL1);
|
||||||
if (ret < 0) {
|
if (rc < 0) {
|
||||||
dev_err(&client->dev, "Failing to stop the clock\n");
|
dev_err(&client->dev, "Failing to stop the clock\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stop the clock */
|
/* stop the clock */
|
||||||
ret |= PCF85063_REG_CTRL1_STOP;
|
reg = rc | PCF85063_REG_CTRL1_STOP;
|
||||||
|
|
||||||
ret = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, ret);
|
rc = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, reg);
|
||||||
if (ret < 0) {
|
if (rc < 0) {
|
||||||
dev_err(&client->dev, "Failing to stop the clock\n");
|
dev_err(&client->dev, "Failing to stop the clock\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ctrl1 = ret;
|
*ctrl1 = reg;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pcf85063_start_clock(struct i2c_client *client, u8 ctrl1)
|
static int pcf85063_start_clock(struct i2c_client *client, u8 ctrl1)
|
||||||
{
|
{
|
||||||
s32 ret;
|
int rc;
|
||||||
|
|
||||||
/* start the clock */
|
/* start the clock */
|
||||||
ctrl1 &= ~PCF85063_REG_CTRL1_STOP;
|
ctrl1 &= ~PCF85063_REG_CTRL1_STOP;
|
||||||
|
|
||||||
ret = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, ctrl1);
|
rc = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, ctrl1);
|
||||||
if (ret < 0) {
|
if (rc < 0) {
|
||||||
dev_err(&client->dev, "Failing to start the clock\n");
|
dev_err(&client->dev, "Failing to start the clock\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue