Skip to contentSkip to conversation

gpio: twl4030: Remove redundant assignment

PATCH In review Alexander Shiyan 4 participants 6 messages Feb 15, 2014 – Feb 27, 2014 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: twl4030: Remove redundant assignment

Variable "status" is never used, so remove it.

---
 drivers/gpio/gpio-twl4030.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpio-twl4030.c +3 -3
index 8b88ca2..fa15beb 100644
@@ -139,7 +139,6 @@ static u8 cached_leden;
 static void twl4030_led_set_value(int led, int value)
 {
 	u8 mask = LEDEN_LEDAON | LEDEN_LEDAPWM;
-	int status;
 
 	if (led)
 		mask <<= 1;
@@ -148,8 +147,9 @@ static void twl4030_led_set_value(int led, int value)
 		cached_leden &= ~mask;
 	else
 		cached_leden |= mask;
-	status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
-				  TWL4030_LED_LEDEN_REG);
+
+	twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
+			 TWL4030_LED_LEDEN_REG);
 }
 
 static int twl4030_set_gpio_direction(int gpio, int is_input)
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 20 lines · Alexander Shiyan

Variable "status" is never used, so remove it.

---
 drivers/gpio/gpio-twl4030.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpio-twl4030.c +0 -1
index 8b88ca2..fa15beb 100644
@@ -139,7 +139,6 @@ static u8 cached_leden;
 static void twl4030_led_set_value(int led, int value)
 {
        u8 mask = LEDEN_LEDAON | LEDEN_LEDAPWM;
-       int status;
 
        if (led)
                mask <<= 1;

drivers/gpio/gpio-twl4030.c static void twl4030_led_set_value(int led, int value) · line 152

Quoted 8 lines
drivers/gpio/gpio-twl4030.c +3 -2
@@ -148,8 +147,9 @@ static void twl4030_led_set_value(int led, int value)
                cached_leden &= ~mask;
        else
                cached_leden |= mask;
-       status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
-                                 TWL4030_LED_LEDEN_REG);
+
+       twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
+                        TWL4030_LED_LEDEN_REG);

Isn't the right fix to actually *check* this status instead?

TI dudes?

Yours,
Linus Walleij

#2 lore raw

Hi,

Quoted 33 lines · Linus Walleij
Quoted 20 lines · Alexander Shiyan

Variable "status" is never used, so remove it.

---
 drivers/gpio/gpio-twl4030.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpio-twl4030.c +0 -1
index 8b88ca2..fa15beb 100644
@@ -139,7 +139,6 @@ static u8 cached_leden;
 static void twl4030_led_set_value(int led, int value)
 {
        u8 mask = LEDEN_LEDAON | LEDEN_LEDAPWM;
-       int status;
 
        if (led)
                mask <<= 1;

drivers/gpio/gpio-twl4030.c static void twl4030_led_set_value(int led, int value) · line 152

Quoted 8 lines
drivers/gpio/gpio-twl4030.c +3 -2
@@ -148,8 +147,9 @@ static void twl4030_led_set_value(int led, int value)
                cached_leden &= ~mask;
        else
                cached_leden |= mask;
-       status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
-                                 TWL4030_LED_LEDEN_REG);
+
+       twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
+                        TWL4030_LED_LEDEN_REG);

Isn't the right fix to actually *check* this status instead?

Quoted 1 line

TI dudes?

Yes we should check for error. But the only action we can take is maybe print an error message as all the users of this function return void. e.g. twl_set().

It seems the set() hook of struct gpio_chip also doesn't expect any return value. Wondering if that should change.

cheers,
-roger

#3 lore raw
Quoted 9 lines · Roger Quadros
Quoted 8 lines · Linus Walleij
Quoted 5 lines · Alexander Shiyan
drivers/gpio/gpio-twl4030.c +3 -2
-       status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
-                                 TWL4030_LED_LEDEN_REG);
+
+       twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
+                        TWL4030_LED_LEDEN_REG);
Quoted 8 lines
Quoted 3 lines

Isn't the right fix to actually *check* this status instead?

TI dudes?

Yes we should check for error. But the only action we can take is maybe print an error message as all the users of this function return void. e.g. twl_set().

It seems the set() hook of struct gpio_chip also doesn't expect any return value. Wondering if that should change.

I think in this case simply printing an error and bailing out is just fine, people will be able to debug from there.

Yours,
Linus Walleij

#4 lore raw
Quoted 14 lines · Linus Walleij
Quoted 13 lines · Roger Quadros
Quoted 11 lines · Linus Walleij

drivers/gpio/gpio-twl4030.c static void twl4030_led_set_value(int led, int value) · line 152

Quoted 5 lines · Alexander Shiyan
drivers/gpio/gpio-twl4030.c +3 -2
-       status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
-                                 TWL4030_LED_LEDEN_REG);
+
+       twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
+                        TWL4030_LED_LEDEN_REG);

Isn't the right fix to actually *check* this status instead?

TI dudes?

Quoted 7 lines
Quoted 4 lines

Yes we should check for error. But the only action we can take is maybe print an error message as all the users of this function return void. e.g. twl_set().

It seems the set() hook of struct gpio_chip also doesn't expect any return value. Wondering if that should change.

I think in this case simply printing an error and bailing out is just fine, people will be able to debug from there.

FWIW: if a write to twl4030 fails we are anyways in a big trouble. This is the PMIC in the system, so it is likely that we do not even boot in such case.

Signature · 5 lines
Péter
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
In reply to Linus Walleij

Четверг, 27 февраля 2014, 10:24 +01:00 от Linus Walleij <[email protected]>:

Quoted 14 lines · Roger Quadros
Quoted 13 lines · Linus Walleij
Quoted 11 lines · Alexander Shiyan

drivers/gpio/gpio-twl4030.c static void twl4030_led_set_value(int led, int value) · line 152

Quoted 6 lines
drivers/gpio/gpio-twl4030.c +3 -2
-       status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
-                                 TWL4030_LED_LEDEN_REG);
+
+       twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
+                        TWL4030_LED_LEDEN_REG);

Isn't the right fix to actually *check* this status instead?

TI dudes?

Quoted 7 lines
Quoted 4 lines

Yes we should check for error. But the only action we can take is maybe print an error message as all the users of this function return void. e.g. twl_set().

It seems the set() hook of struct gpio_chip also doesn't expect any return value. Wondering if that should change.

I think in this case simply printing an error and bailing out is just fine, people will be able to debug from there.

WARN_ON_ONCE() is enough?
v2?

---