[PATCH v2 2/3] usb: ohci-at91: Enable OHCI functionality and register into DM
Marek Vasut
marex at denx.de
Tue Jan 3 16:34:38 CET 2023
On 1/3/23 15:30, Sergiu Moga wrote:
[...]
> +static int ohci_atmel_probe(struct udevice *dev)
> +{
> + struct at91_usbh_data *pdata = dev_get_plat(dev);
> + struct ohci_at91_priv *ohci_at91 = dev_get_priv(dev);
> + u32 i;
> + int ret;
> + struct ohci_regs *regs = (struct ohci_regs *)dev_read_addr(dev);
Use one space after type for indent.
Also, I think the dev_read_addr() can fail, so you want to check the
return value.
> + pdata->ports = dev_read_u32_default(dev, "num-ports", 3);
> +
> + at91_for_each_port(i, pdata->ports)
> + gpio_request_by_name(dev, "atmel,vbus-gpio", i,
> + &pdata->vbus_pin[i], GPIOD_IS_OUT |
> + GPIOD_IS_OUT_ACTIVE);
> +
> + ret = clk_get_bulk(dev, &ohci_at91->clks);
> + if (ret)
> + goto fail;
> +
> + ret = clk_enable_bulk(&ohci_at91->clks);
> + if (ret)
> + goto fail;
> +
> + ret = at91_start_hc(dev);
> + if (ret)
> + goto fail;
> +
> + return ohci_register(dev, regs);
> +
> +fail:
> + at91_for_each_port(i, pdata->ports)
> + if (dm_gpio_is_valid(&pdata->vbus_pin[i]))
> + gpio_free(pdata->vbus_pin[i].offset);
Add clk_disable in case of failure after at91_start_hc , please check
all the fail paths one more time.
[...]
More information about the U-Boot
mailing list