Skip to contentSkip to conversation

power: supply: twl4030-charger: remove unused cur_reg variable

PATCH In review Tom Rix 3 participants 3 messages Apr 1, 2023 Power supply

lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 power: supply: twl4030-charger: remove unused cur_reg variable

clang with W=1 reports drivers/power/supply/twl4030_charger.c:242:16: error: variable
'cur_reg' set but not used [-Werror,-Wunused-but-set-variable]

        unsigned reg, cur_reg;
                      ^

This variable is not used so remove it.

---
 drivers/power/supply/twl4030_charger.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/power/supply/twl4030_charger.c +1 -3
index 7adfd69fe649..5fa5b2311330 100644
@@ -239,7 +239,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
 {
 	int status;
 	int cur;
-	unsigned reg, cur_reg;
+	unsigned reg;
 	u8 bcictl1, oldreg, fullreg;
 	bool cgain = false;
 	u8 boot_bci;
@@ -357,11 +357,9 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
 	status = twl4030_bci_read(TWL4030_BCIIREF1, &oldreg);
 	if (status < 0)
 		return status;
-	cur_reg = oldreg;
 	status = twl4030_bci_read(TWL4030_BCIIREF2, &oldreg);
 	if (status < 0)
 		return status;
-	cur_reg |= oldreg << 8;
 	if (reg != oldreg) {
 		/* disable write protection for one write access for
 		 * BCIIREF */
Signature · 1 line
2.27.0
#1 lore raw

Hi,

Quoted 26 lines · Tom Rix

clang with W=1 reports drivers/power/supply/twl4030_charger.c:242:16: error: variable
'cur_reg' set but not used [-Werror,-Wunused-but-set-variable]

        unsigned reg, cur_reg;
                      ^

This variable is not used so remove it.

---
 drivers/power/supply/twl4030_charger.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/power/supply/twl4030_charger.c +1 -1
index 7adfd69fe649..5fa5b2311330 100644
@@ -239,7 +239,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
 {
 	int status;
 	int cur;
-	unsigned reg, cur_reg;
+	unsigned reg;
 	u8 bcictl1, oldreg, fullreg;
 	bool cgain = false;
 	u8 boot_bci;

drivers/power/supply/twl4030_charger.c static int twl4030_charger_update_current(struct twl4030_bci *bci) · line 363

Quoted 9 lines
drivers/power/supply/twl4030_charger.c +0 -2
@@ -357,11 +357,9 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
 	status = twl4030_bci_read(TWL4030_BCIIREF1, &oldreg);
 	if (status < 0)
 		return status;
-	cur_reg = oldreg;
 	status = twl4030_bci_read(TWL4030_BCIIREF2, &oldreg);
 	if (status < 0)
 		return status;
-	cur_reg |= oldreg << 8;
 	if (reg != oldreg) {

I think the correct fix would be checking for (reg != cur_reg) here.

-- Sebastian

Quoted 5 lines
drivers/power/supply/twl4030_charger.c +0 -0
 		/* disable write protection for one write access for
 		 * BCIIREF */
Signature · 1 line
2.27.0
#2 lore raw
Quoted 32 lines · On Sat, 1 Apr 2023 22:30:26 +0200 Sebastian Reichel…

Hi,

Quoted 29 lines · Tom Rix

clang with W=1 reports drivers/power/supply/twl4030_charger.c:242:16: error: variable
'cur_reg' set but not used [-Werror,-Wunused-but-set-variable]

        unsigned reg, cur_reg;
                      ^

This variable is not used so remove it.

---
 drivers/power/supply/twl4030_charger.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/power/supply/twl4030_charger.c +1 -1
index 7adfd69fe649..5fa5b2311330 100644
@@ -239,7 +239,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
 {
 	int status;
 	int cur;
-	unsigned reg, cur_reg;
+	unsigned reg;
 	u8 bcictl1, oldreg, fullreg;
 	bool cgain = false;
 	u8 boot_bci;
@@ -357,11 +357,9 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
 	status = twl4030_bci_read(TWL4030_BCIIREF1, &oldreg);
 	if (status < 0)
 		return status;
Quoted 9 lines

drivers/power/supply/twl4030_charger.c static int twl4030_charger_update_current(struct twl4030_bci *bci) · line 363

Quoted 6 lines
drivers/power/supply/twl4030_charger.c +0 -2
-	cur_reg = oldreg;
 	status = twl4030_bci_read(TWL4030_BCIIREF2, &oldreg);
 	if (status < 0)
 		return status;
-	cur_reg |= oldreg << 8;
 	if (reg != oldreg) {  

I think the correct fix would be checking for (reg != cur_reg) here.

yes, makes more sense.

Regards,
Andreas