Re: [PATCH v3 10/12] hikey960: Support usb functionality of Hikey960
From: Chen Yu
Date: Sun Mar 03 2019 - 20:55:54 EST
Hi Chunfeng Yun,
On 2019/3/4 9:47, Chunfeng Yun wrote:
>> +
>> + hisi_hikey_usb->role_sw = usb_role_switch_get(dev);
>> + if (!hisi_hikey_usb->role_sw)
>> + return -EPROBE_DEFER;
> Here return EPROBE_DEFFER means the related device_connection is
> registered after this probe is called, right?
> if not, use IS_ERR_OR_NULL then return PTR_ERR is enough
Yes, the driver which register the usb_role_switch may finish probe after
this driver is probed for the first time.
>> + else if (IS_ERR(hisi_hikey_usb->role_sw))
>> + return PTR_ERR(hisi_hikey_usb->role_sw);
>> +
>> + ret = usb_role_switch_register_notifier(hisi_hikey_usb->role_sw,
>> + &hisi_hikey_usb->nb);
>> + if (ret) {
>> + usb_role_switch_put(hisi_hikey_usb->role_sw);
>> + return ret;
>> + }
>> +
>> + platform_set_drvdata(pdev, hisi_hikey_usb);
>> +
>> + return 0;
>> +}
>> +
>
>
> .
>