Subject: [PATCH] at91: at91-ohci: fix set/get power

From: [email-masked] (Thomas Petazzoni)
Date: Mon, 14 Nov 2011 21:51:29 +0100

Le Mon, 14 Nov 2011 22:39:21 +0200,
Andrew Victor <[email-masked]> a ?crit :

> Shouldn't that rather be:
>    if (!gpio_is_valid(pdata->vbus_pin[port]))
>           return;

No, because gpio_is_valid() accept 0 as a valid GPIO. Therefore, when
you don't set anything for the .vbus_pin field, the values are zero,
and gpio_is_valid() will tell you that it's a valid GPIO. If we wanted
to use gpio_is_valid(), we would have to do something like .vbus_pin =
{ -EINVAL, -EINVAL } in every board for which the vbus pin isn't used.
It's a quite unfortunate behaviour of the current gpio subsystem.

Regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com