Skip to content

Commit 70f1ae5

Browse files
Joy Chakrabortyalexandrebelloni
authored andcommitted
rtc: isl1208: Fix return value of nvmem callbacks
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: c3544f6 ("rtc: isl1208: Add new style nvmem support to driver") Cc: [email protected] Signed-off-by: Joy Chakraborty <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent c88014c commit 70f1ae5

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/rtc/rtc-isl1208.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -775,30 +775,27 @@ static int isl1208_nvmem_read(void *priv, unsigned int off, void *buf,
775775
{
776776
struct isl1208_state *isl1208 = priv;
777777
struct i2c_client *client = to_i2c_client(isl1208->rtc->dev.parent);
778-
int ret;
779778

780779
/* nvmem sanitizes offset/count for us, but count==0 is possible */
781780
if (!count)
782781
return count;
783-
ret = isl1208_i2c_read_regs(client, ISL1208_REG_USR1 + off, buf,
782+
783+
return isl1208_i2c_read_regs(client, ISL1208_REG_USR1 + off, buf,
784784
count);
785-
return ret == 0 ? count : ret;
786785
}
787786

788787
static int isl1208_nvmem_write(void *priv, unsigned int off, void *buf,
789788
size_t count)
790789
{
791790
struct isl1208_state *isl1208 = priv;
792791
struct i2c_client *client = to_i2c_client(isl1208->rtc->dev.parent);
793-
int ret;
794792

795793
/* nvmem sanitizes off/count for us, but count==0 is possible */
796794
if (!count)
797795
return count;
798-
ret = isl1208_i2c_set_regs(client, ISL1208_REG_USR1 + off, buf,
799-
count);
800796

801-
return ret == 0 ? count : ret;
797+
return isl1208_i2c_set_regs(client, ISL1208_REG_USR1 + off, buf,
798+
count);
802799
}
803800

804801
static const struct nvmem_config isl1208_nvmem_config = {

0 commit comments

Comments
 (0)