diff options
| author | Alvin Šipraga <alvin@airtame.com> | 2018-07-15 17:31:53 -0400 |
|---|---|---|
| committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2018-07-28 08:49:25 -0400 |
| commit | ec9cf1b7a6af2c0cffaa887351e7c7acced5290e (patch) | |
| tree | 761e0285b6c2ddb2a36058a76586da4c4325dafa /drivers/rtc | |
| parent | 8856541557f3626beec43aa0821b2e0f031f0153 (diff) | |
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>
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/rtc-pcf85063.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c index 49bcbb3d4a69..283c2335b01b 100644 --- a/drivers/rtc/rtc-pcf85063.c +++ b/drivers/rtc/rtc-pcf85063.c | |||
| @@ -43,37 +43,38 @@ static struct i2c_driver pcf85063_driver; | |||
| 43 | 43 | ||
| 44 | static int pcf85063_stop_clock(struct i2c_client *client, u8 *ctrl1) | 44 | static int pcf85063_stop_clock(struct i2c_client *client, u8 *ctrl1) |
| 45 | { | 45 | { |
| 46 | s32 ret; | 46 | int rc; |
| 47 | u8 reg; | ||
| 47 | 48 | ||
| 48 | ret = i2c_smbus_read_byte_data(client, PCF85063_REG_CTRL1); | 49 | rc = i2c_smbus_read_byte_data(client, PCF85063_REG_CTRL1); |
| 49 | if (ret < 0) { | 50 | if (rc < 0) { |
| 50 | dev_err(&client->dev, "Failing to stop the clock\n"); | 51 | dev_err(&client->dev, "Failing to stop the clock\n"); |
| 51 | return -EIO; | 52 | return -EIO; |
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | /* stop the clock */ | 55 | /* stop the clock */ |
| 55 | ret |= PCF85063_REG_CTRL1_STOP; | 56 | reg = rc | PCF85063_REG_CTRL1_STOP; |
| 56 | 57 | ||
| 57 | ret = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, ret); | 58 | rc = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, reg); |
| 58 | if (ret < 0) { | 59 | if (rc < 0) { |
| 59 | dev_err(&client->dev, "Failing to stop the clock\n"); | 60 | dev_err(&client->dev, "Failing to stop the clock\n"); |
| 60 | return -EIO; | 61 | return -EIO; |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | *ctrl1 = ret; | 64 | *ctrl1 = reg; |
| 64 | 65 | ||
| 65 | return 0; | 66 | return 0; |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | static int pcf85063_start_clock(struct i2c_client *client, u8 ctrl1) | 69 | static int pcf85063_start_clock(struct i2c_client *client, u8 ctrl1) |
| 69 | { | 70 | { |
| 70 | s32 ret; | 71 | int rc; |
| 71 | 72 | ||
| 72 | /* start the clock */ | 73 | /* start the clock */ |
| 73 | ctrl1 &= ~PCF85063_REG_CTRL1_STOP; | 74 | ctrl1 &= ~PCF85063_REG_CTRL1_STOP; |
| 74 | 75 | ||
| 75 | ret = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, ctrl1); | 76 | rc = i2c_smbus_write_byte_data(client, PCF85063_REG_CTRL1, ctrl1); |
| 76 | if (ret < 0) { | 77 | if (rc < 0) { |
| 77 | dev_err(&client->dev, "Failing to start the clock\n"); | 78 | dev_err(&client->dev, "Failing to start the clock\n"); |
| 78 | return -EIO; | 79 | return -EIO; |
| 79 | } | 80 | } |
