Re: [PATCH] extcon: arizona: Only set GPIO if it has been requested

From: Mark Brown
Date: Tue Nov 27 2012 - 01:35:24 EST


On Tue, Nov 27, 2012 at 08:26:35AM +0900, Chanwoo Choi wrote:
> On 11/26/2012 08:28 PM, Mark Brown wrote:

> > + if (arizona->pdata.micd_pol_gpio > 0)
> > + gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
> > + info->micd_modes[mode].gpio);

> Why not use gpio_is_valid() function to test arizona->pdata.micd_pol_gpio ?

Zero is normally a valid GPIO (since it's an index into a big array
after all) but this is unhelpful when checking to see if someone filled
in platform data as it's also the default value for uninitialised member
variables. It's much more likely that someone didn't fill in a GPIO
than that GPIO 0 got assigned to this.

Attachment: signature.asc
Description: Digital signature