[PATCH 1/2] usb: host: ehci-generic: Make usage of clock/reset bulk() API

Patrice CHOTARD patrice.chotard at foss.st.com
Thu May 5 16:48:20 CEST 2022


Hi Marek

On 5/5/22 15:44, Marek Vasut wrote:
> On 5/5/22 15:17, Patrice Chotard wrote:
> 
> [...]
> 
>> @@ -81,68 +79,31 @@ static int ehci_usb_probe(struct udevice *dev)
>>       struct generic_ehci *priv = dev_get_priv(dev);
>>       struct ehci_hccr *hccr;
>>       struct ehci_hcor *hcor;
>> -    int i, err, ret, clock_nb, reset_nb;
>> +    int err, ret;
>>         err = 0;
>> -    priv->clock_count = 0;
>> -    clock_nb = ofnode_count_phandle_with_args(dev_ofnode(dev), "clocks",
>> -                          "#clock-cells", 0);
>> -    if (clock_nb > 0) {
>> -        priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
>> -                        GFP_KERNEL);
>> -        if (!priv->clocks)
>> -            return -ENOMEM;
>> -
>> -        for (i = 0; i < clock_nb; i++) {
>> -            err = clk_get_by_index(dev, i, &priv->clocks[i]);
>> -
>> -            if (err < 0)
>> -                break;
>> -            err = clk_enable(&priv->clocks[i]);
>> -            if (err && err != -ENOSYS) {
>> -                dev_err(dev, "failed to enable clock %d\n", i);
>> -                clk_free(&priv->clocks[i]);
>> -                goto clk_err;
>> -            }
>> -            priv->clock_count++;
>> -        }
>> -    } else {
>> -        if (clock_nb != -ENOENT) {
>> -            dev_err(dev, "failed to get clock phandle(%d)\n",
>> -                clock_nb);
>> -            return clock_nb;
>> -        }
>> +    ret = clk_get_bulk(dev, &priv->clocks);
>> +    if (ret) {
>> +        dev_err(dev, "Failed to get clocks\n");
> 
> Print the error code in the error message, so the user can immediately determine what went wrong without rebuilding the code with extra debug prints (and that goes for other messages and other drivers too, the error code is useful there).
> 
> dev_err(dev, "Failed to get clocks (ret=%d)\n", ret);
> 
> [...]

Right, i will add the ret value in dev_err();
Thanks
Patrice


More information about the U-Boot mailing list