]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rtc: isl1208: Fix return value of nvmem callbacks
authorJoy Chakraborty <joychakr@google.com>
Wed, 12 Jun 2024 08:08:31 +0000 (08:08 +0000)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 27 Jun 2024 22:20:20 +0000 (00:20 +0200)
Read/write callbacks registered with nvmem core expect 0 to be returned
on success and a negative value to be returned on failure.

isl1208_nvmem_read()/isl1208_nvmem_write() currently return the number of
bytes read/written on success, fix to return 0 on success and negative on
failure.

Fixes: c3544f6f51ed ("rtc: isl1208: Add new style nvmem support to driver")
Cc: stable@vger.kernel.org
Signed-off-by: Joy Chakraborty <joychakr@google.com>
Link: https://lore.kernel.org/r/20240612080831.1227131-1-joychakr@google.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-isl1208.c

index e50c23ee1646a5d90af3aa9940dd1be0ace7c55a..206f96b90f58bc487b0f96ce7806a42c286e9d96 100644 (file)
@@ -775,14 +775,13 @@ static int isl1208_nvmem_read(void *priv, unsigned int off, void *buf,
 {
        struct isl1208_state *isl1208 = priv;
        struct i2c_client *client = to_i2c_client(isl1208->rtc->dev.parent);
-       int ret;
 
        /* nvmem sanitizes offset/count for us, but count==0 is possible */
        if (!count)
                return count;
-       ret = isl1208_i2c_read_regs(client, ISL1208_REG_USR1 + off, buf,
+
+       return isl1208_i2c_read_regs(client, ISL1208_REG_USR1 + off, buf,
                                    count);
-       return ret == 0 ? count : ret;
 }
 
 static int isl1208_nvmem_write(void *priv, unsigned int off, void *buf,
@@ -790,15 +789,13 @@ static int isl1208_nvmem_write(void *priv, unsigned int off, void *buf,
 {
        struct isl1208_state *isl1208 = priv;
        struct i2c_client *client = to_i2c_client(isl1208->rtc->dev.parent);
-       int ret;
 
        /* nvmem sanitizes off/count for us, but count==0 is possible */
        if (!count)
                return count;
-       ret = isl1208_i2c_set_regs(client, ISL1208_REG_USR1 + off, buf,
-                                  count);
 
-       return ret == 0 ? count : ret;
+       return isl1208_i2c_set_regs(client, ISL1208_REG_USR1 + off, buf,
+                                  count);
 }
 
 static const struct nvmem_config isl1208_nvmem_config = {