[U-Boot] [PATCH] M28: Added guarding for reserved bits in GPIO driver
Marek Vasut
marek.vasut at gmail.com
Wed Nov 23 11:59:47 CET 2011
> > Careful here !!
> >
> > The driver _should_ work for MX233 too! What I'd like to see is you
> > introducing a function like:
> >
> > int mxs_gpio_is_valid(gpio)
> > {
> > char mxs_banks[PINCTRL_BANKS] = PINCTRL_BANK_COUNTS;
> >
> > if (PAD_PIN(gpio) > mxs_bank[PAD_BANK(gpio)])
> > return -EINVAL;
> >
> > return 0;
> > }
>
> There's a bit of a paradox here: If a name is translated into a pin, bank
> numbers above 7 and pin numbers above 31 will have wrapped around in
> translation and won't be caught here. I could check for wrapping in the
> translating function and check for valid numbers within the assigned bit
> range here, but I'd rather not see validity check spread over two
> functions.
>
> > And define PINCTRL_BANK_COUNTS in the section of mxs_gpio.c where all the
> > remaining mx28 and mx233 specific defines are hoarded (near the top of
> > the file).
>
> At that spot I've put in Mike's (very similar) solution now:
> static const int mxs_bank_pins[] = {
> MXS_BANK0_PINS,
> MXS_BANK1_PINS,
> MXS_BANK2_PINS,
> #ifdef(CONFIG_MX28)
> MXS_BANK3_PINS,
> MXS_BANK4_PINS,
> #endif
> };
>
> I'm considering to remove the macro PINCTRL_BANKS now, and use
> ARRAY_SIZE(mxs_bank_pins) instead, as it yields the same number and leads
> to a single point of definition.
And are you sure the amound of pins in bank 0, 1, 2 is the same on mx233 and
mx28 ?
More information about the U-Boot
mailing list