From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Thu, 22 Oct 2020 10:04:51 +0300
Subject: rtc: pcf2127: fix pcf2127_nvmem_read/write() returns
Git-commit: ba1c30bf3f2536f248d262c6f257b5a787305991
Patch-mainline: v5.11-rc1
References: git-fixes
These functions should return zero on success. Non-zero returns are
treated as error. On some paths, this doesn't matter but in
nvmem_cell_read() a non-zero return would be passed to ERR_PTR() and
lead to an Oops.
Fixes: d6c3029f32f7 ("rtc: pcf2127: add support for accessing internal static RAM")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201022070451.GA2817669@mwanda
Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
---
drivers/rtc/rtc-pcf2127.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -200,10 +200,8 @@ static int pcf2127_nvmem_read(void *priv
if (ret)
return ret;
- ret = regmap_bulk_read(pcf2127->regmap, PCF2127_REG_RAM_rd_cmd,
- val, bytes);
-
- return ret ?: bytes;
+ return regmap_bulk_read(pcf2127->regmap, PCF2127_REG_RAM_rd_cmd,
+ val, bytes);
}
static int pcf2127_nvmem_write(void *priv, unsigned int offset,
@@ -218,10 +216,8 @@ static int pcf2127_nvmem_write(void *pri
if (ret)
return ret;
- ret = regmap_bulk_write(pcf2127->regmap, PCF2127_REG_RAM_wrt_cmd,
- val, bytes);
-
- return ret ?: bytes;
+ return regmap_bulk_write(pcf2127->regmap, PCF2127_REG_RAM_wrt_cmd,
+ val, bytes);
}
static int pcf2127_probe(struct device *dev, struct regmap *regmap,