rtc: abx80x: Fix return value of nvmem callback on read
Subsystems (2)
PATCH v2 1/1 rtc: abx80x: Fix return value of nvmem callback on read
Read callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
abx80x_nvmem_xfer() on read calls i2c_smbus_read_i2c_block_data() which returns the number of bytes read on success as per its api description, this return value is handled as an error and returned to nvmem even on success.
Fix to handle all possible values that would be returned by i2c_smbus_read_i2c_block_data().
--- drivers/rtc/rtc-abx80x.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/rtc/rtc-abx80x.c +8 -4
@@ -705,14 +705,18 @@ static int abx80x_nvmem_xfer(struct abx80x_priv *priv, unsigned int offset,if (ret)return ret; -if (write) +if (write) { ret =i2c_smbus_write_i2c_block_data (priv->client, reg, len, val); -else +if (ret) +return ret; + }else { ret =i2c_smbus_read_i2c_block_data (priv->client, reg, len, val); -if (ret) -return ret; +if (ret <=0 ) +return ret ? ret : -EIO ; + len = ret; + } offset += len; val += len;
Signature · 1 line
2.45.2.505.gda0bf45e8d-goog
Quoted 8 lines · Joy Chakraborty
Read callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
abx80x_nvmem_xfer()on read callsi2c_smbus_read_i2c_block_data()which returns the number of bytes read on success as per its api description, this return value is handled as an error and returned to nvmem even on success.
Quoted 6 lines
Fix to handle all possible values that would be returned by
i2c_smbus_read_i2c_block_data().Fixes e90ff8ede777 ("rtc: abx80x: Add nvmem support")Signed-off-by Joy Chakraborty <[email protected]>
Thanks!
regards,
dan carpenter
Quoted 7 lines · Joy Chakraborty
Read callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
abx80x_nvmem_xfer()on read callsi2c_smbus_read_i2c_block_data()which returns the number of bytes read on success as per its api description, this return value is handled as an error and returned to nvmem even on success.
Humm, I wish this were documented in nvmem-provider.h...
Quoted 27 lines
Fix to handle all possible values that would be returned by
i2c_smbus_read_i2c_block_data().Fixes e90ff8ede777 ("rtc: abx80x: Add nvmem support")Signed-off-by Joy Chakraborty <[email protected]>--- drivers/rtc/rtc-abx80x.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)drivers/rtc/rtc-abx80x.c +4
-2@@ -705,14 +705,18 @@ static int abx80x_nvmem_xfer(struct abx80x_priv *priv, unsigned int offset,if (ret)return ret; -if (write) +if (write) { ret =i2c_smbus_write_i2c_block_data (priv->client, reg, len, val); -else +if (ret) +return ret; + }else { ret = i2c_smbus_read_i2c_block_data(priv->client, reg,
drivers/rtc/rtc-abx80x.c static int abx80x_nvmem_xfer(struct abx80x_priv *priv, unsigned int offset, · line 722
Quoted 10 lines
drivers/rtc/rtc-abx80x.c +4
-2len, val); -if (ret) -return ret; +if (ret <=0 ) +return ret ? ret : -EIO ; + len = ret; + } offset += len; val += len;
Srinivas Kandagatla
AppliedQuoted 9 lines · Joy Chakraborty
Read callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
abx80x_nvmem_xfer()on read callsi2c_smbus_read_i2c_block_data()which returns the number of bytes read on success as per its api description, this return value is handled as an error and returned to nvmem even on success.[...]
Applied, thanks!
[1/1] rtc: abx80x: Fix return value of nvmem callback on read
commit: 126b2b4ec0f471d46117ca31b99cd76b1eee48d8
Best regards,
Signature · 1 line
Srinivas Kandagatla <[email protected]>
Alexandre Belloni
maintainerQuoted 10 lines · Srinivas Kandagatla
Quoted 8 lines · Joy Chakraborty
Read callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
abx80x_nvmem_xfer()on read callsi2c_smbus_read_i2c_block_data()which returns the number of bytes read on success as per its api description, this return value is handled as an error and returned to nvmem even on success.
Quoted 7 lines
Quoted 1 line
[...]
Applied, thanks!
[1/1] rtc: abx80x: Fix return value of nvmem callback on read
commit: 126b2b4ec0f471d46117ca31b99cd76b1eee48d8
Please drop it from your tree, I'm going to handle the rtc related patches...
Quoted 4 lines
Best regards,
Signature · 1 line
Srinivas Kandagatla <[email protected]>
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 13 lines · Alexandre Belloni
Quoted 12 lines · Srinivas Kandagatla
Quoted 9 lines · Joy Chakraborty
Read callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
abx80x_nvmem_xfer()on read callsi2c_smbus_read_i2c_block_data()which returns the number of bytes read on success as per its api description, this return value is handled as an error and returned to nvmem even on success.[...]
Quoted 9 lines
Quoted 5 lines
Applied, thanks!
[1/1] rtc: abx80x: Fix return value of nvmem callback on read
commit: 126b2b4ec0f471d46117ca31b99cd76b1eee48d8Please drop it from your tree, I'm going to handle the rtc related patches...
Sure I will drop it.
--srini
Quoted 5 lines
Quoted 4 lines
Best regards,
Signature · 1 line
Srinivas Kandagatla <[email protected]>
Quoted 9 lines · Joy Chakraborty
Read callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
abx80x_nvmem_xfer()on read callsi2c_smbus_read_i2c_block_data()which returns the number of bytes read on success as per its api description, this return value is handled as an error and returned to nvmem even on success.[...]
Applied, thanks!
[1/1] rtc: abx80x: Fix return value of nvmem callback on read
https://git.kernel.org/abelloni/c/fc82336b50e7
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com