linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: pcf2127: fix pcf2127_nvmem_read/write() returns
@ 2020-10-22  7:04 Dan Carpenter
  2020-10-27 11:32 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-10-22  7:04 UTC (permalink / raw)
  To: Alessandro Zummo, Uwe Kleine-König
  Cc: Alexandre Belloni, linux-rtc, kernel-janitors

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>
---
 drivers/rtc/rtc-pcf2127.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index 07a5630ec841..4d9711d51f8f 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -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 */
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: pcf2127: fix pcf2127_nvmem_read/write() returns
  2020-10-22  7:04 [PATCH] rtc: pcf2127: fix pcf2127_nvmem_read/write() returns Dan Carpenter
@ 2020-10-27 11:32 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2020-10-27 11:32 UTC (permalink / raw)
  To: Uwe Kleine-König, Alessandro Zummo, Dan Carpenter
  Cc: Alexandre Belloni, kernel-janitors, linux-rtc

On Thu, 22 Oct 2020 10:04:51 +0300, Dan Carpenter wrote:
> 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,
-- 
Alexandre Belloni <alexandre.belloni@bootlin.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-27 11:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22  7:04 [PATCH] rtc: pcf2127: fix pcf2127_nvmem_read/write() returns Dan Carpenter
2020-10-27 11:32 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).