Remove the hardcoded limit for the number of gpio_pins that can be used.

Allocate it dynamically.

Approved by:	adrian (mentor)
This commit is contained in:
Luiz Otavio O Souza 2013-09-06 23:47:50 +00:00
parent 8d900240b0
commit ebcbd8aeff
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=255335
2 changed files with 10 additions and 2 deletions

View File

@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/rman.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/gpio.h>
@ -418,6 +419,13 @@ ar71xx_gpio_attach(device_t dev)
"pinon", &pinon) != 0)
pinon = 0;
device_printf(dev, "gpio pinmask=0x%x\n", mask);
for (j = 0; j <= maxpin; j++) {
if ((mask & (1 << j)) == 0)
continue;
sc->gpio_npins++;
}
sc->gpio_pins = malloc(sizeof(*sc->gpio_pins) * sc->gpio_npins,
M_DEVBUF, M_WAITOK | M_ZERO);
for (i = 0, j = 0; j <= maxpin; j++) {
if ((mask & (1 << j)) == 0)
continue;
@ -429,7 +437,6 @@ ar71xx_gpio_attach(device_t dev)
ar71xx_gpio_pin_configure(sc, &sc->gpio_pins[i], DEFAULT_CAPS);
i++;
}
sc->gpio_npins = i;
for (i = 0; i < sc->gpio_npins; i++) {
j = sc->gpio_pins[i].gp_pin;
if ((pinon & (1 << j)) != 0)
@ -455,6 +462,7 @@ ar71xx_gpio_detach(device_t dev)
bus_release_resource(dev, SYS_RES_MEMORY, sc->gpio_mem_rid,
sc->gpio_mem_res);
free(sc->gpio_pins, M_DEVBUF);
mtx_destroy(&sc->gpio_mtx);
return(0);

View File

@ -64,7 +64,7 @@ struct ar71xx_gpio_softc {
int gpio_irq_rid;
void *gpio_ih;
int gpio_npins;
struct gpio_pin gpio_pins[AR71XX_GPIO_PINS];
struct gpio_pin *gpio_pins;
};
#endif /* __AR71XX_GPIOVAR_H__ */