Skip to contentSkip to conversation

i2c: recovery: remove bogus check if SDA GPIO is set to output

PATCH In review Wolfram Sang 2 participants 2 messages Jul 12, 2018 – Jul 13, 2018 I2C

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: recovery: remove bogus check if SDA GPIO is set to output

This check did not work as intended. I2C is open drain, so this function will likely always have presented the GPIO as input because gpiod_get_direction doesn't know about open drain states. Remove this check for now. We can add it again once we know how to get more precise information about the GPIO.

---
 drivers/i2c/i2c-core-base.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/i2c/i2c-core-base.c +1 -3
index 57538d72f2e5..4debf921ab5c 100644
@@ -269,9 +269,7 @@ static void i2c_init_recovery(struct i2c_adapter *adap)
 		bri->set_scl = set_scl_gpio_value;
 		if (bri->sda_gpiod) {
 			bri->get_sda = get_sda_gpio_value;
-			/* FIXME: add proper flag instead of '0' once available */
-			if (gpiod_get_direction(bri->sda_gpiod) == 0)
-				bri->set_sda = set_sda_gpio_value;
+			bri->set_sda = set_sda_gpio_value;
 		}
 		return;
 	}
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Wolfram Sang

This check did not work as intended. I2C is open drain, so this function will likely always have presented the GPIO as input because gpiod_get_direction doesn't know about open drain states. Remove this check for now. We can add it again once we know how to get more precise information about the GPIO.

Quoted 22 lines
---
 drivers/i2c/i2c-core-base.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/i2c/i2c-core-base.c +1 -3
index 57538d72f2e5..4debf921ab5c 100644
@@ -269,9 +269,7 @@ static void i2c_init_recovery(struct i2c_adapter *adap)
 		bri->set_scl = set_scl_gpio_value;
 		if (bri->sda_gpiod) {
 			bri->get_sda = get_sda_gpio_value;
-			/* FIXME: add proper flag instead of '0' once available */
-			if (gpiod_get_direction(bri->sda_gpiod) == 0)
-				bri->set_sda = set_sda_gpio_value;
+			bri->set_sda = set_sda_gpio_value;
 		}
 		return;
 	}
Signature · 1 line
2.11.0