Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Apr 2016 15:18:31 +0000 (UTC)
From:      Luiz Otavio O Souza <loos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r298272 - head/lib/libgpio
Message-ID:  <201604191518.u3JFIVFA042221@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: loos
Date: Tue Apr 19 15:18:31 2016
New Revision: 298272
URL: https://svnweb.freebsd.org/changeset/base/298272

Log:
  Use GPIOTOGGLE to toggle the pin state instead of read, modify and write.

Modified:
  head/lib/libgpio/gpio.c

Modified: head/lib/libgpio/gpio.c
==============================================================================
--- head/lib/libgpio/gpio.c	Tue Apr 19 15:08:35 2016	(r298271)
+++ head/lib/libgpio/gpio.c	Tue Apr 19 15:18:31 2016	(r298272)
@@ -181,14 +181,14 @@ gpio_pin_set(gpio_handle_t handle, gpio_
 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604191518.u3JFIVFA042221>