Skip to contentSkip to conversation

at91: at91-ohci: fix set/get power

PATCH New Jean-Christophe PLAGNIOL-VILLARD 4 participants 6 messages Nov 12, 2011 – Nov 15, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index ba3a46b..95a9fec 100644
@@ -223,6 +223,9 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int
 	if (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
#1 lore raw

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 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

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
index ba3a46b..95a9fec 100644
@@ -223,6 +223,9 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int
 	if (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
#2 lore raw

PATCH 1/1 at91: at91-ohci: fix set/get power

In reply to Jean-Christophe PLAGNIOL-VILLARD

Le Sat, 12 Nov 2011 16:46:13 +0100,
Jean-Christophe PLAGNIOL-VILLARD <[email protected]> a ?crit :

Quoted 6 lines

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

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw

PATCH 1/1 at91: at91-ohci: fix set/get power

In reply to Jean-Christophe PLAGNIOL-VILLARD

hi,

Quoted 5 lines

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

+ ? ? ? if (pdata->vbus_pin[port] <= 0)
+ ? ? ? ? ? ? ? return;

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

          return;

Regards,
Andrew Victor

#4 lore raw

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
#5 lore raw

PATCH 1/1 at91: at91-ohci: fix set/get power

In reply to Andrew Victor
Quoted 11 lines · Andrew Victor

hi,

Quoted 5 lines

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

+ ? ? ? 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.