off by one error, maxpins

Luiz Otavio O Souza lists.br at gmail.com
Fri Sep 6 02:20:48 UTC 2013


Yes, please commit it.

And by the way... There is another bug in that code, the gpio driver
automatically adjust itself to the number of GPIO pins available on SoC:

ar71xx_gpiovar.h:#define AR71XX_GPIO_PINS 12
ar71xx_gpiovar.h:#define AR724X_GPIO_PINS 18
ar71xx_gpiovar.h:#define AR91XX_GPIO_PINS 22
ar933xreg.h:#define AR933X_GPIO_COUNT 30
ar934xreg.h:#define AR934X_GPIO_COUNT 23

But the size of the gpio_pins struct is statically defined (and with a
small size for most of the supported SoC):

struct ar71xx_gpio_softc {
        ....
        struct gpio_pin         gpio_pins[AR71XX_GPIO_PINS];
};

I'll write a patch to allocate this structure dynamically based on the SoC
we're running on.

Luiz


On 5 September 2013 20:14, Adrian Chadd <adrian at freebsd.org> wrote:

> Commit ahoy. :)
>
>
> -a
>
>
> On 5 September 2013 15:47, Sean Bruno <sean_bruno at yahoo.com> wrote:
>
> > On Thu, 2013-09-05 at 16:42 -0600, Warner Losh wrote:
> > > Shouldn't npins and/or maxpin just be bumped by 1 instead?
> > >
> > > Warner
> > >
> > > On Sep 5, 2013, at 4:38 PM, Sean Bruno wrote:
> > >
> > > > http://people.freebsd.org/~sbruno/maxpin_plus_one.txt
> > > >
> >
> > It looks like its  *intentionally* assigned as the h/w specific (GPIO
> > COUNT) -1 in ar71xx_gpio_pin_max()
> >
> > Userland assumes that this value is a 0-based thing.
> >
> _______________________________________________
> freebsd-embedded at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-embedded
> To unsubscribe, send any mail to "freebsd-embedded-unsubscribe at freebsd.org
> "
>


More information about the freebsd-embedded mailing list