rtc: abx80x: Fix return value of nvmem callback on read
authorJoy Chakraborty <joychakr@google.com>
Thu, 13 Jun 2024 12:07:50 +0000 (12:07 +0000)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 27 Jun 2024 22:21:46 +0000 (00:21 +0200)
commitfc82336b50e7652530bc32caec80be0f8792513b
tree4d750f575b259b11f938285664056e2c4f4248ad
parent1c184baccf0d5e2ef4cc1562261d0e48508a1c2b
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().

Fixes: e90ff8ede777 ("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>
drivers/rtc/rtc-abx80x.c