From 8d900240b040a51c4432f8a63dab87bc56038625 Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Fri, 6 Sep 2013 23:39:56 +0000 Subject: [PATCH] Fix an off-by-one bug in ar71xx_gpio and bcm2835_gpio which makes the last pin unavailable. Reported and tested by: sbruno (ar71xx) Approved by: adrian (mentor) Pointy hat to: loos --- sys/arm/broadcom/bcm2835/bcm2835_gpio.c | 2 +- sys/mips/atheros/ar71xx_gpio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c index 9ddb44b2a792..267e3f99401f 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c @@ -729,7 +729,7 @@ bcm_gpio_attach(device_t dev) goto fail; /* Initialize the software controlled pins. */ - for (i = 0, j = 0; j < BCM_GPIO_PINS - 1; j++) { + for (i = 0, j = 0; j < BCM_GPIO_PINS; j++) { if (bcm_gpio_pin_is_ro(sc, j)) continue; snprintf(sc->sc_gpio_pins[i].gp_name, GPIOMAXNAME, diff --git a/sys/mips/atheros/ar71xx_gpio.c b/sys/mips/atheros/ar71xx_gpio.c index 6ad8df4242a7..0c2e5287d0c8 100644 --- a/sys/mips/atheros/ar71xx_gpio.c +++ b/sys/mips/atheros/ar71xx_gpio.c @@ -418,7 +418,7 @@ ar71xx_gpio_attach(device_t dev) "pinon", &pinon) != 0) pinon = 0; device_printf(dev, "gpio pinmask=0x%x\n", mask); - for (i = 0, j = 0; j < maxpin; j++) { + for (i = 0, j = 0; j <= maxpin; j++) { if ((mask & (1 << j)) == 0) continue; snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,