Skip to contentSkip to conversation

gpio: sx150x: fix error code value

PATCH In review Vasiliy Kulikov 2 participants 2 messages Sep 12, 2010 – Sep 13, 2010

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

PATCH 1/1 gpio: sx150x: fix error code value

The return code of sx150x_get_io() is propagated as error code, so it should look like standard code.

---
Compile tested.

 drivers/gpio/sx150x.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpio/sx150x.c +1 -1
index b42f42c..b0eed89 100644
@@ -179,7 +179,7 @@ static int sx150x_get_io(struct sx150x_chip *chip, unsigned offset)
 	sx150x_find_cfg(offset, 1, &reg, &mask, &shift);
 	err = sx150x_i2c_read(chip->client, reg, &data);
 	if (err >= 0)
-		err = (data & mask) != 0 ? 1 : 0;
+		err = (data & mask) != 0 ? -EIO : 0;
 
 	return err;
 }
Signature · 1 line
1.7.0.4
#1 lore raw

Review

Quoted 5 lines
  	err = sx150x_i2c_read(chip->client, reg,&data);
  	if (err>= 0)
(quoted diff) +1 -1
-		err = (data&  mask) != 0 ? 1 : 0;
+		err = (data&  mask) != 0 ? -EIO : 0;

This doesn't work. The IO pins are gpio data pins, which are used as 0 or 1 data values (see sx150x_gpio_get). Returning -EIO whenever an attempt is made to gpio_get_value on a non-zero gpio line will break things.

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.