Skip to contentSkip to conversation

gpio: dln2: Fix gpio output value in dln2_gpio_direction_output()

PATCH In review Axel Lin 2 participants 2 messages Dec 17, 2014 – Jan 7, 2015 GPIO

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH v2 1/1 gpio: dln2: Fix gpio output value in dln2_gpio_direction_output()

dln2_gpio_direction_output() ignored the state passed into it. Fix it. Also make dln2_gpio_pin_set_out_val return int, so we can check the error value.

---
v2: Address Octavian's comment.

 drivers/gpio/gpio-dln2.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpio/gpio-dln2.c +11 -4
index 978b51e..2481e8d 100644
@@ -141,16 +141,16 @@ static int dln2_gpio_pin_get_out_val(struct dln2_gpio *dln2, unsigned int pin)
 	return !!ret;
 }
 
-static void dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2,
-				      unsigned int pin, int value)
+static int dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2,
+				     unsigned int pin, int value)
 {
 	struct dln2_gpio_pin_val req = {
 		.pin = cpu_to_le16(pin),
 		.value = value,
 	};
 
-	dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_OUT_VAL, &req,
-			 sizeof(req));
+	return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_OUT_VAL, &req,
+				sizeof(req));
 }
 
 #define DLN2_GPIO_DIRECTION_IN		0
@@ -267,6 +267,13 @@ static int dln2_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
 				      int value)
 {
+	struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
+	int ret;
+
+	ret = dln2_gpio_pin_set_out_val(dln2, offset, value);
+	if (ret < 0)
+		return ret;
+
 	return dln2_gpio_set_direction(chip, offset, DLN2_GPIO_DIRECTION_OUT);
 }
 
Signature · 1 line
1.9.1