Skip to contentSkip to conversation

rtc: pcf2127: fix pcf2127_nvmem_read/write() returns

PATCH Applied Dan Carpenter 2 participants 2 messages Oct 22, 2020 – Oct 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: pcf2127: fix pcf2127_nvmem_read/write() returns

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")
---
 drivers/rtc/rtc-pcf2127.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/rtc/rtc-pcf2127.c +4 -8
index 07a5630ec841..4d9711d51f8f 100644
@@ -243,10 +243,8 @@ static int pcf2127_nvmem_read(void *priv, unsigned int offset,
 	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,
@@ -261,10 +259,8 @@ static int pcf2127_nvmem_write(void *priv, unsigned int offset,
 	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);
 }
 
 /* watchdog driver */
Signature · 1 line
2.28.0
maintainer Applied
#1 lore raw
Quoted 4 lines · Dan Carpenter

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.

Applied, thanks!

[1/1] rtc: pcf2127: fix pcf2127_nvmem_read/write() returns

      commit: ba1c30bf3f2536f248d262c6f257b5a787305991

Best regards,

Signature · 1 line
Alexandre Belloni <[email protected]>