diff options
author | Peter Rosin <peda@axentia.se> | 2016-12-22 02:43:55 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-05 13:32:29 -0500 |
commit | 8f12dc24490bde0d604b8bdfca05ea4b06a624a7 (patch) | |
tree | 881e2d902e13b5d489cca3b2607541bcf78da0d6 /drivers/usb | |
parent | 674aea07e38200ea6f31ff6d5f200f0cf6cdb325 (diff) |
usb: ohci-at91: use descriptor-based gpio APIs correctly
The gpiod_get* function family does not want the -gpio suffix.
Use devm_gpiod_get_index_optional instead of devm_gpiod_get_optional.
The descriptor based APIs handle active high/low automatically.
The vbus-gpios are output, request enable while getting the gpio.
Don't try to get any vbus-gpios for ports outside num-ports.
WTF? Big sigh.
Fixes: 054d4b7b577d ("usb: ohci-at91: Use descriptor-based gpio APIs")
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/host/ohci-at91.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index be9e63836881..414e3c376dbb 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -43,7 +43,6 @@ struct at91_usbh_data { | |||
43 | struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS]; | 43 | struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS]; |
44 | u8 ports; /* number of ports on root hub */ | 44 | u8 ports; /* number of ports on root hub */ |
45 | u8 overcurrent_supported; | 45 | u8 overcurrent_supported; |
46 | u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS]; | ||
47 | u8 overcurrent_status[AT91_MAX_USBH_PORTS]; | 46 | u8 overcurrent_status[AT91_MAX_USBH_PORTS]; |
48 | u8 overcurrent_changed[AT91_MAX_USBH_PORTS]; | 47 | u8 overcurrent_changed[AT91_MAX_USBH_PORTS]; |
49 | }; | 48 | }; |
@@ -266,8 +265,7 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int | |||
266 | if (!valid_port(port)) | 265 | if (!valid_port(port)) |
267 | return; | 266 | return; |
268 | 267 | ||
269 | gpiod_set_value(pdata->vbus_pin[port], | 268 | gpiod_set_value(pdata->vbus_pin[port], enable); |
270 | pdata->vbus_pin_active_low[port] ^ enable); | ||
271 | } | 269 | } |
272 | 270 | ||
273 | static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) | 271 | static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) |
@@ -275,8 +273,7 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) | |||
275 | if (!valid_port(port)) | 273 | if (!valid_port(port)) |
276 | return -EINVAL; | 274 | return -EINVAL; |
277 | 275 | ||
278 | return gpiod_get_value(pdata->vbus_pin[port]) ^ | 276 | return gpiod_get_value(pdata->vbus_pin[port]); |
279 | pdata->vbus_pin_active_low[port]; | ||
280 | } | 277 | } |
281 | 278 | ||
282 | /* | 279 | /* |
@@ -533,18 +530,17 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
533 | pdata->ports = ports; | 530 | pdata->ports = ports; |
534 | 531 | ||
535 | at91_for_each_port(i) { | 532 | at91_for_each_port(i) { |
536 | pdata->vbus_pin[i] = devm_gpiod_get_optional(&pdev->dev, | 533 | if (i >= pdata->ports) |
537 | "atmel,vbus-gpio", | 534 | break; |
538 | GPIOD_IN); | 535 | |
536 | pdata->vbus_pin[i] = | ||
537 | devm_gpiod_get_index_optional(&pdev->dev, "atmel,vbus", | ||
538 | i, GPIOD_OUT_HIGH); | ||
539 | if (IS_ERR(pdata->vbus_pin[i])) { | 539 | if (IS_ERR(pdata->vbus_pin[i])) { |
540 | err = PTR_ERR(pdata->vbus_pin[i]); | 540 | err = PTR_ERR(pdata->vbus_pin[i]); |
541 | dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err); | 541 | dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err); |
542 | continue; | 542 | continue; |
543 | } | 543 | } |
544 | |||
545 | pdata->vbus_pin_active_low[i] = gpiod_get_value(pdata->vbus_pin[i]); | ||
546 | |||
547 | ohci_at91_usb_set_power(pdata, i, 1); | ||
548 | } | 544 | } |
549 | 545 | ||
550 | at91_for_each_port(i) { | 546 | at91_for_each_port(i) { |
@@ -552,8 +548,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
552 | break; | 548 | break; |
553 | 549 | ||
554 | pdata->overcurrent_pin[i] = | 550 | pdata->overcurrent_pin[i] = |
555 | devm_gpiod_get_optional(&pdev->dev, | 551 | devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc", |
556 | "atmel,oc-gpio", GPIOD_IN); | 552 | i, GPIOD_IN); |
557 | if (IS_ERR(pdata->overcurrent_pin[i])) { | 553 | if (IS_ERR(pdata->overcurrent_pin[i])) { |
558 | err = PTR_ERR(pdata->overcurrent_pin[i]); | 554 | err = PTR_ERR(pdata->overcurrent_pin[i]); |
559 | dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err); | 555 | dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err); |