Skip to content

Commit

Permalink
ARM: at91/ohci: use gpio_is_valid to check the gpio
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
  • Loading branch information
Jean-Christophe PLAGNIOL-VILLARD authored and Arnd Bergmann committed Nov 29, 2011
1 parent 1d6dc06 commit 8a7a49d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/usb/host/ohci-at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ 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)
if (!gpio_is_valid(pdata->vbus_pin[port]))
return;

gpio_set_value(pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable);
Expand All @@ -234,7 +234,7 @@ 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)
if (!gpio_is_valid(pdata->vbus_pin[port]))
return -EINVAL;

return gpio_get_value(pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted;
Expand Down Expand Up @@ -465,7 +465,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)

if (pdata) {
for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
if (pdata->vbus_pin[i] <= 0)
if (!gpio_is_valid(pdata->vbus_pin[i]))
continue;
gpio_request(pdata->vbus_pin[i], "ohci_vbus");
ohci_at91_usb_set_power(pdata, i, 1);
Expand All @@ -474,7 +474,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) {
int ret;

if (pdata->overcurrent_pin[i] <= 0)
if (!gpio_is_valid(pdata->overcurrent_pin[i]))
continue;
gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent");

Expand All @@ -499,14 +499,14 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)

if (pdata) {
for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
if (pdata->vbus_pin[i] <= 0)
if (!gpio_is_valid(pdata->vbus_pin[i]))
continue;
ohci_at91_usb_set_power(pdata, i, 0);
gpio_free(pdata->vbus_pin[i]);
}

for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) {
if (pdata->overcurrent_pin[i] <= 0)
if (!gpio_is_valid(pdata->overcurrent_pin[i]))
continue;
free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev);
gpio_free(pdata->overcurrent_pin[i]);
Expand Down

0 comments on commit 8a7a49d

Please sign in to comment.