Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Dec 2014 19:56:05 +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: r276315 - head/sys/arm/ti
Message-ID:  <201412271956.sBRJu53t070954@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: loos
Date: Sat Dec 27 19:56:04 2014
New Revision: 276315
URL: https://svnweb.freebsd.org/changeset/base/276315

Log:
  Fix a off-by-one bug.
  
  Pointy hat to:	loos

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

Modified: head/sys/arm/ti/ti_gpio.c
==============================================================================
--- head/sys/arm/ti/ti_gpio.c	Sat Dec 27 18:54:39 2014	(r276314)
+++ head/sys/arm/ti/ti_gpio.c	Sat Dec 27 19:56:04 2014	(r276315)
@@ -334,7 +334,7 @@ static int
 ti_gpio_valid_pin(struct ti_gpio_softc *sc, int pin)
 {
 
-	if (pin > sc->sc_maxpin ||
+	if (pin >= sc->sc_maxpin ||
 	    TI_GPIO_BANK(pin) >= ti_max_gpio_banks() ||
 	    sc->sc_mem_res[TI_GPIO_BANK(pin)] == NULL) {
 		return (EINVAL);
@@ -755,6 +755,7 @@ ti_gpio_attach(device_t dev)
 	sc->sc_dev = dev;
 	TI_GPIO_LOCK_INIT(sc);
 	ti_gpio_pin_max(dev, &sc->sc_maxpin);
+	sc->sc_maxpin++;
 
 	/* There are up to 6 different GPIO register sets located in different
 	 * memory areas on the chip.  The memory range should have been set for



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