linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] at91: at91-ohci: fix set/get power
@ 2011-11-12 15:46 Jean-Christophe PLAGNIOL-VILLARD
  2011-11-14 10:57 ` Nicolas Ferre
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-11-12 15:46 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
---
 drivers/usb/host/ohci-at91.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index ba3a46b..95a9fec 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -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;
 }
 
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] at91: at91-ohci: fix set/get power
  2011-11-12 15:46 [PATCH] at91: at91-ohci: fix set/get power Jean-Christophe PLAGNIOL-VILLARD
@ 2011-11-14 10:57 ` Nicolas Ferre
  2011-11-14 18:22 ` Thomas Petazzoni
  2011-11-14 20:39 ` Andrew Victor
  2 siblings, 0 replies; 6+ messages in thread
From: Nicolas Ferre @ 2011-11-14 10:57 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/12/2011 04:46 PM, Jean-Christophe PLAGNIOL-VILLARD :
> 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
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  drivers/usb/host/ohci-at91.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index ba3a46b..95a9fec 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -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;
>  }
>  


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] at91: at91-ohci: fix set/get power
  2011-11-12 15:46 [PATCH] at91: at91-ohci: fix set/get power Jean-Christophe PLAGNIOL-VILLARD
  2011-11-14 10:57 ` Nicolas Ferre
@ 2011-11-14 18:22 ` Thomas Petazzoni
  2011-11-14 20:39 ` Andrew Victor
  2 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2011-11-14 18:22 UTC (permalink / raw)
  To: linux-arm-kernel

Le Sat, 12 Nov 2011 16:46:13 +0100,
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a ?crit :

> 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
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>

Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] at91: at91-ohci: fix set/get power
  2011-11-12 15:46 [PATCH] at91: at91-ohci: fix set/get power Jean-Christophe PLAGNIOL-VILLARD
  2011-11-14 10:57 ` Nicolas Ferre
  2011-11-14 18:22 ` Thomas Petazzoni
@ 2011-11-14 20:39 ` Andrew Victor
  2011-11-14 20:51   ` Thomas Petazzoni
  2011-11-15  0:59   ` Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 2 replies; 6+ messages in thread
From: Andrew Victor @ 2011-11-14 20:39 UTC (permalink / raw)
  To: linux-arm-kernel

hi,

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] at91: at91-ohci: fix set/get power
  2011-11-14 20:39 ` Andrew Victor
@ 2011-11-14 20:51   ` Thomas Petazzoni
  2011-11-15  0:59   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2011-11-14 20:51 UTC (permalink / raw)
  To: linux-arm-kernel

Le Mon, 14 Nov 2011 22:39:21 +0200,
Andrew Victor <avictor.za@gmail.com> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] at91: at91-ohci: fix set/get power
  2011-11-14 20:39 ` Andrew Victor
  2011-11-14 20:51   ` Thomas Petazzoni
@ 2011-11-15  0:59   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-11-15  0:59 UTC (permalink / raw)
  To: linux-arm-kernel

On 22:39 Mon 14 Nov     , Andrew Victor wrote:
> hi,
> 
> > 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-15  0:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-12 15:46 [PATCH] at91: at91-ohci: fix set/get power Jean-Christophe PLAGNIOL-VILLARD
2011-11-14 10:57 ` Nicolas Ferre
2011-11-14 18:22 ` Thomas Petazzoni
2011-11-14 20:39 ` Andrew Victor
2011-11-14 20:51   ` Thomas Petazzoni
2011-11-15  0:59   ` Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).