Skip to contentSkip to conversation

rtc: rv3029: Clean up error handling in rv3029_eeprom_write()

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 20, 2017 – Oct 12, 2017

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

PATCH 1/1 rtc: rv3029: Clean up error handling in rv3029_eeprom_write()

We don't need both "ret" and "err" when they do the same thing. All the functions called here return zero on success or negative error codes. It's more clear to return a literal zero at the end instead of "return ret;"

drivers/rtc/rtc-rv3029c2.c +8 -8
index aa09771de04f..f4f957ab5fe6 100644
@@ -282,13 +282,13 @@ static int rv3029_eeprom_read(struct device *dev, u8 reg,
 static int rv3029_eeprom_write(struct device *dev, u8 reg,
 			       u8 const buf[], size_t len)
 {
-	int ret, err;
+	int ret;
 	size_t i;
 	u8 tmp;
 
-	err = rv3029_eeprom_enter(dev);
-	if (err < 0)
-		return err;
+	ret = rv3029_eeprom_enter(dev);
+	if (ret < 0)
+		return ret;
 
 	for (i = 0; i < len; i++, reg++) {
 		ret = rv3029_read_regs(dev, reg, &tmp, 1);
@@ -304,11 +304,11 @@ static int rv3029_eeprom_write(struct device *dev, u8 reg,
 			break;
 	}
 
-	err = rv3029_eeprom_exit(dev);
-	if (err < 0)
-		return err;
+	ret = rv3029_eeprom_exit(dev);
+	if (ret < 0)
+		return ret;
 
-	return ret;
+	return 0;
 }
 
 static int rv3029_eeprom_update_bits(struct device *dev,
#1 lore raw
Quoted 7 lines · Dan Carpenter

We don't need both "ret" and "err" when they do the same thing. All the functions called here return zero on success or negative error codes. It's more clear to return a literal zero at the end instead of "return ret;"

Applied, thanks.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com