Module Name:    src
Committed By:   phx
Date:           Tue Sep  1 19:25:32 UTC 2015

Modified Files:
        src/sys/dev/gpio: gpioiic.c

Log Message:
i2c_acquire_bus() should return 0 on success.
Fixed bug in gpioiic_bb_set_bits(), which was introduced with the SDA/SCL-
reverse feature.
Now the driver is confirmed to work. Tested with Raspberry Pi GPIO.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/gpio/gpioiic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/gpio/gpioiic.c
diff -u src/sys/dev/gpio/gpioiic.c:1.6 src/sys/dev/gpio/gpioiic.c:1.7
--- src/sys/dev/gpio/gpioiic.c:1.6	Sat Oct 27 17:18:16 2012
+++ src/sys/dev/gpio/gpioiic.c	Tue Sep  1 19:25:32 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: gpioiic.c,v 1.6 2012/10/27 17:18:16 chs Exp $ */
+/* $NetBSD: gpioiic.c,v 1.7 2015/09/01 19:25:32 phx Exp $ */
 /*	$OpenBSD: gpioiic.c,v 1.8 2008/11/24 12:12:12 mbalmer Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gpioiic.c,v 1.6 2012/10/27 17:18:16 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpioiic.c,v 1.7 2015/09/01 19:25:32 phx Exp $");
 
 /*
  * I2C bus bit-banging through GPIO pins.
@@ -232,10 +232,10 @@ gpioiic_i2c_acquire_bus(void *cookie, in
 	struct gpioiic_softc *sc = cookie;
 
 	if (flags & I2C_F_POLL)
-		return 0;
+		return 1;
 
 	rw_enter(&sc->sc_i2c_lock, RW_WRITER);
-	return 1;
+	return 0;
 }
 
 void
@@ -286,8 +286,8 @@ gpioiic_bb_set_bits(void *cookie, uint32
 
 	gpio_pin_write(sc->sc_gpio, &sc->sc_map, sc->sc_pin_sda,
 	    bits & GPIOIIC_SDA ? GPIO_PIN_HIGH : GPIO_PIN_LOW);
-	gpio_pin_write(sc->sc_gpio, &sc->sc_map, GPIOIIC_PIN_SCL,
-	    bits & GPIOIIC_SCL ? GPIO_PIN_HIGH : sc->sc_pin_scl);
+	gpio_pin_write(sc->sc_gpio, &sc->sc_map, sc->sc_pin_scl,
+	    bits & GPIOIIC_SCL ? GPIO_PIN_HIGH : GPIO_PIN_LOW);
 }
 
 void

Reply via email to