Skip to content

Commit 8f12dc2

Browse files
peda-rgregkh
authored andcommitted
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: 054d4b7 ("usb: ohci-at91: Use descriptor-based gpio APIs") Signed-off-by: Peter Rosin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 674aea0 commit 8f12dc2

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

drivers/usb/host/ohci-at91.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct at91_usbh_data {
4343
struct gpio_desc *overcurrent_pin[AT91_MAX_USBH_PORTS];
4444
u8 ports; /* number of ports on root hub */
4545
u8 overcurrent_supported;
46-
u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS];
4746
u8 overcurrent_status[AT91_MAX_USBH_PORTS];
4847
u8 overcurrent_changed[AT91_MAX_USBH_PORTS];
4948
};
@@ -266,17 +265,15 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int
266265
if (!valid_port(port))
267266
return;
268267

269-
gpiod_set_value(pdata->vbus_pin[port],
270-
pdata->vbus_pin_active_low[port] ^ enable);
268+
gpiod_set_value(pdata->vbus_pin[port], enable);
271269
}
272270

273271
static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
274272
{
275273
if (!valid_port(port))
276274
return -EINVAL;
277275

278-
return gpiod_get_value(pdata->vbus_pin[port]) ^
279-
pdata->vbus_pin_active_low[port];
276+
return gpiod_get_value(pdata->vbus_pin[port]);
280277
}
281278

282279
/*
@@ -533,27 +530,26 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
533530
pdata->ports = ports;
534531

535532
at91_for_each_port(i) {
536-
pdata->vbus_pin[i] = devm_gpiod_get_optional(&pdev->dev,
537-
"atmel,vbus-gpio",
538-
GPIOD_IN);
533+
if (i >= pdata->ports)
534+
break;
535+
536+
pdata->vbus_pin[i] =
537+
devm_gpiod_get_index_optional(&pdev->dev, "atmel,vbus",
538+
i, GPIOD_OUT_HIGH);
539539
if (IS_ERR(pdata->vbus_pin[i])) {
540540
err = PTR_ERR(pdata->vbus_pin[i]);
541541
dev_err(&pdev->dev, "unable to claim gpio \"vbus\": %d\n", err);
542542
continue;
543543
}
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);
548544
}
549545

550546
at91_for_each_port(i) {
551547
if (i >= pdata->ports)
552548
break;
553549

554550
pdata->overcurrent_pin[i] =
555-
devm_gpiod_get_optional(&pdev->dev,
556-
"atmel,oc-gpio", GPIOD_IN);
551+
devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc",
552+
i, GPIOD_IN);
557553
if (IS_ERR(pdata->overcurrent_pin[i])) {
558554
err = PTR_ERR(pdata->overcurrent_pin[i]);
559555
dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err);

0 commit comments

Comments
 (0)