On Wed, Jun 12, 2013 at 10:56:46AM -0600, Stephen Warren wrote:
On 06/12/2013 10:46 AM, Mark Brown wrote:
Unfortunately gpio_is_valid() is unhelpful for platform data since often zero is a valid GPIO but it's also the default "do nothing" platform data. It's therefore better to either include a check for non-zero as well or have code that takes a zero in the platform data and sets it to a negative value instead.
I think people filling in platform data should simply be required to put a valid/correct value in that field. There aren't any users of this, so it's not like adding a new field where backwards-compatibility might be a concern (and even then, updating all users of this platform data type wouldn't be hard), and it should be obvious if you get it wrong.
It's not idiomatic to do it this way, it'll catch people out - sadly the effects are often non-obvious, depending on what actually happens with the GPIO. Were it not for renumbering pain it'd probably be most sensible to just make 0 never a valid GPIO :/