Author: gonzo
Date: Mon Feb 25 08:04:47 2013
New Revision: 247252
URL: http://svnweb.freebsd.org/changeset/base/247252

Log:
  - Fix off-by-one error when returning max pin number
  - Fix GPIOGET for output pins. Requesting state for
      output pin is valid operation, get the state from
      TI_GPIO_DATAOUTX register

Modified:
  head/sys/arm/ti/ti_gpio.c

Modified: head/sys/arm/ti/ti_gpio.c
==============================================================================
--- head/sys/arm/ti/ti_gpio.c   Mon Feb 25 02:41:38 2013        (r247251)
+++ head/sys/arm/ti/ti_gpio.c   Mon Feb 25 08:04:47 2013        (r247252)
@@ -281,7 +281,7 @@ ti_gpio_pin_max(device_t dev, int *maxpi
                        banks++;
        }
 
-       *maxpin = (banks * PINS_PER_BANK);
+       *maxpin = (banks * PINS_PER_BANK) - 1;
 
        TI_GPIO_UNLOCK(sc);
 
@@ -541,13 +541,11 @@ ti_gpio_pin_get(device_t dev, uint32_t p
        /* Sanity check the pin is not configured as an output */
        val = ti_gpio_read_4(sc, bank, TI_GPIO_OE);
 
-       if ((val & mask) == mask) {
-               TI_GPIO_UNLOCK(sc);
-               return (EINVAL);
-       }
-
        /* Read the value on the pin */
-       *value = (ti_gpio_read_4(sc, bank, TI_GPIO_DATAIN) & mask) ? 1 : 0;
+       if (val & mask)
+               *value = (ti_gpio_read_4(sc, bank, TI_GPIO_DATAOUT) & mask) ? 1 
: 0;
+       else
+               *value = (ti_gpio_read_4(sc, bank, TI_GPIO_DATAIN) & mask) ? 1 
: 0;
 
        TI_GPIO_UNLOCK(sc);
 
@@ -728,6 +726,7 @@ ti_gpio_attach(device_t dev)
        /* Finish of the probe call */
        device_add_child(dev, "gpioc", device_get_unit(dev));
        device_add_child(dev, "gpiobus", device_get_unit(dev));
+
        return (bus_generic_attach(dev));
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to