From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Wed, 23 Nov 2011 11:59:47 +0100 Subject: [U-Boot] [PATCH] M28: Added guarding for reserved bits in GPIO driver In-Reply-To: References: <201111221920.59749.marek.vasut@gmail.com> Message-ID: <201111231159.47291.marek.vasut@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > > 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 ?