Skip to contentSkip to conversation

rtc-pcf85063 driver bug in pcf85063_stop_clock()

DISCUSSION Craig McQueen 2 participants 5 messages Oct 11, 2018 – Nov 26, 2018 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

The function pcf85063_stop_clock() is intended to provide the value of the Control_1 register via the pointer ctrl1.

However, it's really providing the return value of the last i2c_smbus_write_byte_data() call, i.e., zero. So the register value needs to be saved in a separate local variable other than ret. Or, the line *ctrl1 = ret; needs to be moved up to be above the last i2c_smbus_write_byte_data() call.

Signature · 1 line
Craig McQueen
#1 lore raw

Hello,

Quoted 4 lines · Craig McQueen

The function pcf85063_stop_clock() is intended to provide the value of the Control_1 register via the pointer ctrl1.

However, it's really providing the return value of the last i2c_smbus_write_byte_data() call, i.e., zero. So the register value needs to be saved in a separate local variable other than ret. Or, the line *ctrl1 = ret; needs to be moved up to be above the last i2c_smbus_write_byte_data() call.

Isn't that fixed by http://patchwork.ozlabs.org/patch/944107/ ?

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw
In reply to Craig McQueen
Quoted 9 lines · I wrote:

The function pcf85063_stop_clock() is intended to provide the value of the Control_1 register via the pointer ctrl1.

However, it's really providing the return value of the last i2c_smbus_write_byte_data() call, i.e., zero. So the register value needs to be saved in a separate local variable other than ret. Or, the line *ctrl1 = ret; needs to be moved up to be above the last i2c_smbus_write_byte_data() call.

I'd like to follow up on this. I could perhaps submit a patch, but I'm not sure what is the best fix for this bug. Any recommendations?

Signature · 1 line
Craig McQueen
#3 lore raw

Hello,

Quoted 5 lines · Craig McQueen
Quoted 4 lines · I wrote:

The function pcf85063_stop_clock() is intended to provide the value of the Control_1 register via the pointer ctrl1.

Quoted 8 lines
Quoted 5 lines

However, it's really providing the return value of the last i2c_smbus_write_byte_data() call, i.e., zero. So the register value needs to be saved in a separate local variable other than ret. Or, the line *ctrl1 = ret; needs to be moved up to be above the last i2c_smbus_write_byte_data() call.

I'd like to follow up on this. I could perhaps submit a patch, but I'm not sure what is the best fix for this bug. Any recommendations?

I replied a while ago, isn't that fixed by:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/rtc/rtc-pcf85063.c?id=ec9cf1b7a6af2c0cffaa887351e7c7acced5290e

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw
Quoted 16 lines · Alexandre Belloni

Hello,

Quoted 12 lines · Craig McQueen
Quoted 10 lines · I wrote:

The function pcf85063_stop_clock() is intended to provide the value of the
Control_1 register via the pointer ctrl1.

However, it's really providing the return value of the last i2c_smbus_write_byte_data() call, i.e., zero. So the register value needs to be saved in a separate local variable other than ret. Or, the line *ctrl1 = ret; needs to be moved up to be above the last i2c_smbus_write_byte_data() call.

Quoted 7 lines
Quoted 1 line

I'd like to follow up on this. I could perhaps submit a patch, but I'm not sure

what is the best fix for this bug. Any recommendations?

Quoted 1 line

I replied a while ago, isn't that fixed by:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/d
rivers/rtc/rtc-pcf85063.c?id=ec9cf1b7a6af2c0cffaa887351e7c7acced5290e

Thanks, that looks like a fix for the exact problem. I thought I'd checked the master branch for a fix before posting this, but maybe I hadn't fetched the latest that includes that commit.

Sorry I missed your previous reply.

Signature · 1 line
Craig McQueen