Commit ae0929cf authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

rtc: rv3029: revert error handling patch to rv3029_eeprom_write()

[ Upstream commit a6f26606 ]

My error handling "cleanup" was totally wrong.  Both the "err" and "ret"
variables are required.  The "err" variable holds the error codes for
rv3029_eeprom_enter/exit() and the "ret" variable holds the error codes
for if actual write fails.  In my patch if the write failed, the
function probably still returned success.
Reported-by: default avatarTom Evans <tom.evans@motec.com.au>
Fixes: 97f5b037 ("rtc: rv3029: Clean up error handling in rv3029_eeprom_write()")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20190817065604.GB29951@mwandaSigned-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9f2d3e49
...@@ -282,13 +282,13 @@ static int rv3029_eeprom_read(struct device *dev, u8 reg, ...@@ -282,13 +282,13 @@ static int rv3029_eeprom_read(struct device *dev, u8 reg,
static int rv3029_eeprom_write(struct device *dev, u8 reg, static int rv3029_eeprom_write(struct device *dev, u8 reg,
u8 const buf[], size_t len) u8 const buf[], size_t len)
{ {
int ret; int ret, err;
size_t i; size_t i;
u8 tmp; u8 tmp;
ret = rv3029_eeprom_enter(dev); err = rv3029_eeprom_enter(dev);
if (ret < 0) if (err < 0)
return ret; return err;
for (i = 0; i < len; i++, reg++) { for (i = 0; i < len; i++, reg++) {
ret = rv3029_read_regs(dev, reg, &tmp, 1); ret = rv3029_read_regs(dev, reg, &tmp, 1);
...@@ -304,11 +304,11 @@ static int rv3029_eeprom_write(struct device *dev, u8 reg, ...@@ -304,11 +304,11 @@ static int rv3029_eeprom_write(struct device *dev, u8 reg,
break; break;
} }
ret = rv3029_eeprom_exit(dev); err = rv3029_eeprom_exit(dev);
if (ret < 0) if (err < 0)
return ret; return err;
return 0; return ret;
} }
static int rv3029_eeprom_update_bits(struct device *dev, static int rv3029_eeprom_update_bits(struct device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment