Skip to content

Commit

Permalink
USB: at91: at91-ohci: fix set/get power
Browse files Browse the repository at this point in the history
in commit aa6e52a 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>
Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jean-Christophe PLAGNIOL-VILLARD authored and Greg Kroah-Hartman committed Nov 14, 2011
1 parent 5dc2470 commit 770f0ba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/usb/host/ohci-at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 770f0ba

Please sign in to comment.