summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2016-04-19 15:18:31 +0000
committerloos <loos@FreeBSD.org>2016-04-19 15:18:31 +0000
commit5404d56e1463efa28400e89b3f3a3745dfe26007 (patch)
tree5a6672f0495ec57f65b90555bb65e14e50f993ab /lib
parent41d99db047ce9bdf5f871128e665fdbfb8ca0e9a (diff)
downloadFreeBSD-src-5404d56e1463efa28400e89b3f3a3745dfe26007.zip
FreeBSD-src-5404d56e1463efa28400e89b3f3a3745dfe26007.tar.gz
Use GPIOTOGGLE to toggle the pin state instead of read, modify and write.
Diffstat (limited to 'lib')
-rw-r--r--lib/libgpio/gpio.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libgpio/gpio.c b/lib/libgpio/gpio.c
index 7ec0955..8170822 100644
--- a/lib/libgpio/gpio.c
+++ b/lib/libgpio/gpio.c
@@ -181,14 +181,14 @@ gpio_pin_set(gpio_handle_t handle, gpio_pin_t pin, gpio_value_t value)
int
gpio_pin_toggle(gpio_handle_t handle, gpio_pin_t pin)
{
- gpio_value_t value;
+ struct gpio_req gpreq;
- value = gpio_pin_get(handle, pin);
- if (value == GPIO_VALUE_INVALID)
+ bzero(&gpreq, sizeof(gpreq));
+ gpreq.gp_pin = pin;
+ if (ioctl(handle, GPIOTOGGLE, &gpreq) < 0)
return (-1);
- value = !value;
- return (gpio_pin_set(handle, pin, value));
+ return (0);
}
int
OpenPOWER on IntegriCloud