mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 09:34:12 +08:00
rtc: abx80x: Fix return value of nvmem callback on read
commitfc82336b50
upstream. 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(). Fixes:e90ff8ede7
("rtc: abx80x: Add nvmem support") Cc: stable@vger.kernel.org Signed-off-by: Joy Chakraborty <joychakr@google.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Sean Anderson <sean.anderson@seco.com> Link: https://lore.kernel.org/r/20240613120750.1455209-1-joychakr@google.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
625fd91308
commit
0cff6d4953
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user