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: 054d4b7b57 ("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>
This commit is contained in:
Peter Rosin 2016-12-22 08:43:55 +01:00 committed by Greg Kroah-Hartman
parent 674aea07e3
commit 8f12dc2449
1 changed files with 10 additions and 14 deletions

View File

@ -43,7 +43,6 @@ struct at91_usbh_data {
struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS]; struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS];
u8 ports; /* number of ports on root hub */ u8 ports; /* number of ports on root hub */
u8 overcurrent_supported; u8 overcurrent_supported;
u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS];
u8 overcurrent_status[AT91_MAX_USBH_PORTS]; u8 overcurrent_status[AT91_MAX_USBH_PORTS];
u8 overcurrent_changed[AT91_MAX_USBH_PORTS]; u8 overcurrent_changed[AT91_MAX_USBH_PORTS];
}; };
@ -266,8 +265,7 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int
if (!valid_port(port)) if (!valid_port(port))
return; return;
gpiod_set_value(pdata->vbus_pin[port], gpiod_set_value(pdata->vbus_pin[port], enable);
pdata->vbus_pin_active_low[port] ^ enable);
} }
static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) 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)
if (!valid_port(port)) if (!valid_port(port))
return -EINVAL; return -EINVAL;
return gpiod_get_value(pdata->vbus_pin[port]) ^ return gpiod_get_value(pdata->vbus_pin[port]);
pdata->vbus_pin_active_low[port];
} }
/* /*
@ -533,18 +530,17 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
pdata->ports = ports; pdata->ports = ports;
at91_for_each_port(i) { at91_for_each_port(i) {
pdata->vbus_pin[i] = devm_gpiod_get_optional(&pdev->dev, if (i >= pdata->ports)
"atmel,vbus-gpio", break;
GPIOD_IN);
pdata->vbus_pin[i] =
devm_gpiod_get_index_optional(&pdev->dev, "atmel,vbus",
i, GPIOD_OUT_HIGH);
if (IS_ERR(pdata->vbus_pin[i])) { if (IS_ERR(pdata->vbus_pin[i])) {
err = PTR_ERR(pdata->vbus_pin[i]); err = PTR_ERR(pdata->vbus_pin[i]);
dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err); dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err);
continue; continue;
} }
pdata->vbus_pin_active_low[i] = gpiod_get_value(pdata->vbus_pin[i]);
ohci_at91_usb_set_power(pdata, i, 1);
} }
at91_for_each_port(i) { at91_for_each_port(i) {
@ -552,8 +548,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
break; break;
pdata->overcurrent_pin[i] = pdata->overcurrent_pin[i] =
devm_gpiod_get_optional(&pdev->dev, devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc",
"atmel,oc-gpio", GPIOD_IN); i, GPIOD_IN);
if (IS_ERR(pdata->overcurrent_pin[i])) { if (IS_ERR(pdata->overcurrent_pin[i])) {
err = PTR_ERR(pdata->overcurrent_pin[i]); err = PTR_ERR(pdata->overcurrent_pin[i]);
dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err); dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err);