summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/gpio.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2015-03-19 16:55:22 +0100
committerGreg Kroah-Hartman <greg@kroah.com>2015-03-19 17:30:38 +0100
commit7bfa0781406f9df6cb20ce5134faa19d34cb4e18 (patch)
tree86d7802b2977754ceef44cfa0a04f81480c0ef7b /drivers/staging/greybus/gpio.c
parent64d2f4e5f94a95b23532efcbc3c955b5086bd890 (diff)
greybus: gpio: refuse to set value of input pins
Add warning and refuse to set output value for pin configured as input, as the result of such an operation is undefined. Remove incorrect todo-comment suggesting that the driver could implicitly switch direction as part of the call. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/gpio.c')
-rw-r--r--drivers/staging/greybus/gpio.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
index b18fb7e12a5b..7e51840cd262 100644
--- a/drivers/staging/greybus/gpio.c
+++ b/drivers/staging/greybus/gpio.c
@@ -273,14 +273,18 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
struct gb_gpio_set_value_request request;
int ret;
+ if (ggc->lines[which].direction == 1) {
+ dev_warn(ggc->chip.dev,
+ "refusing to set value of input gpio %u\n", which);
+ return;
+ }
+
request.which = which;
request.value = value_high ? 1 : 0;
ret = gb_operation_sync(ggc->connection, GB_GPIO_TYPE_SET_VALUE,
&request, sizeof(request), NULL, 0);
- if (!ret) {
- /* XXX should this set direction to out? */
+ if (!ret)
ggc->lines[which].value = request.value;
- }
}
static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *ggc,