at91: at91-ohci: fix set/get power
Subsystems (3)
PATCH 1/1 at91: at91-ohci: fix set/get power
in commit aa6e52a35 we introduce the support of overcurrent notification but the set and get of the power without checking if the gpio is valid or not
--- drivers/usb/host/ohci-at91.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/usb/host/ohci-at91.c +6 -0
@@ -223,6 +223,9 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, intif (port <0 || port >=2 )return ; +if (pdata->vbus_pin[port] <=0 ) +return ; +gpio_set_value (pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable); }
@@ -231,6 +234,9 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)if (port <0 || port >=2 )return -EINVAL ; +if (pdata->vbus_pin[port] <=0 ) +return -EINVAL ; +return gpio_get_value (pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted; }
Signature · 1 line
1.7.7
PATCH 1/1 at91: at91-ohci: fix set/get power
On 11/12/2011 04:46 PM, Jean-Christophe PLAGNIOL-VILLARD :
Quoted 6 lines
in commit
aa6e52a35we introduce the support of overcurrent notification but the set and get of the power without checking if the gpio is valid or notSigned-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Nicolas Ferre <[email protected]>
Quoted 28 lines
--- drivers/usb/host/ohci-at91.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)drivers/usb/host/ohci-at91.c +6
-0@@ -223,6 +223,9 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, intif (port <0 || port >=2 )return ; +if (pdata->vbus_pin[port] <=0 ) +return ; +gpio_set_value (pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable); }@@ -231,6 +234,9 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)if (port <0 || port >=2 )return -EINVAL ; +if (pdata->vbus_pin[port] <=0 ) +return -EINVAL ; +return gpio_get_value (pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted; }
Signature · 1 line
Nicolas Ferre
PATCH 1/1 at91: at91-ohci: fix set/get power
In reply to Jean-Christophe PLAGNIOL-VILLARDLe Sat, 12 Nov 2011 16:46:13 +0100,
Jean-Christophe PLAGNIOL-VILLARD <[email protected]> a ?crit :
Quoted 6 lines
in commit
aa6e52a35we introduce the support of overcurrent notification but the set and get of the power without checking if the gpio is valid or notSigned-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Nicolas Ferre <[email protected]>
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 at91: at91-ohci: fix set/get power
In reply to Jean-Christophe PLAGNIOL-VILLARDhi,
Quoted 5 lines
in commit
aa6e52a35we introduce the support of overcurrent notification but the set and get of the power without checking if the gpio is valid or not+ ? ? ? if (pdata->vbus_pin[port] <= 0)
+ ? ? ? ? ? ? ? return;
Shouldn't that rather be:
if (!gpio_is_valid(pdata->vbus_pin[port]))
return;
Regards,
Andrew Victor
PATCH 1/1 at91: at91-ohci: fix set/get power
Le Mon, 14 Nov 2011 22:39:21 +0200,
Andrew Victor <[email protected]> a ?crit :
Quoted 3 lines
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
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 at91: at91-ohci: fix set/get power
In reply to Andrew VictorQuoted 11 lines · Andrew Victor
hi,
Quoted 5 lines
in commit
aa6e52a35we introduce the support of overcurrent notification but the set and get of the power without checking if the gpio is valid or not+ ? ? ? if (pdata->vbus_pin[port] <= 0)
+ ? ? ? ? ? ? ? return;Shouldn't that rather be:
if (!gpio_is_valid(pdata->vbus_pin[port])) return;
Yes should be but 0 is not a valid gpio on at91
I've a patch serie to fix the gpio support for at91 so we can use gpio_is_valid for 3.3
Best Regards,
J.