[PATCH v2 5/7] usb: onboard-hub: Bail out if peer hub is already probed
Marek Vasut
marex at denx.de
Tue Oct 1 14:07:22 CEST 2024
On 10/1/24 7:20 AM, Abbarapu, Venkatesh wrote:
> Hi Marek,
>
>> -----Original Message-----
>> From: Marek Vasut <marex at denx.de>
>> Sent: Saturday, September 28, 2024 2:12 AM
>> To: Abbarapu, Venkatesh <venkatesh.abbarapu at amd.com>; u-boot at lists.denx.de
>> Cc: Simek, Michal <michal.simek at amd.com>; fabrice.gasnier at foss.st.com; git
>> (AMD-Xilinx) <git at amd.com>
>> Subject: Re: [PATCH v2 5/7] usb: onboard-hub: Bail out if peer hub is already probed
>>
>> On 9/27/24 9:01 AM, Venkatesh Yadav Abbarapu wrote:
>>> The .bind function is implemented to bind the correct "half" of the
>>> hub that the driver wants to bind, and returning -ENODEV for the other
>>> "half".
>>>
>>> Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu at amd.com>
>>> ---
>>> common/usb_onboard_hub.c | 20 ++++++++++++++++++++
>>> 1 file changed, 20 insertions(+)
>>>
>>> diff --git a/common/usb_onboard_hub.c b/common/usb_onboard_hub.c index
>>> 00808ed45e..9c50ca09c9 100644
>>> --- a/common/usb_onboard_hub.c
>>> +++ b/common/usb_onboard_hub.c
>>> @@ -162,6 +162,25 @@ err:
>>> return ret;
>>> }
>>>
>>> +static int usb_onboard_hub_bind(struct udevice *dev) {
>>> + struct ofnode_phandle_args phandle;
>>> + const void *fdt = gd->fdt_blob;
>>> + int ret, off;
>>> +
>>> + if (dev_read_phandle_with_args(dev, "peer-hub", NULL, 0, 0,
>>> +&phandle)) {
>>
>> Return the error code:
>>
>> ret = dev_read_phandle_with_args()
>> if (ret) {
>> ...
>> return ret;
>> }
>>
>>> + dev_err(dev, "peer-hub not specified\n");
>>> + return -ENOENT;
>>> + }
>>> +
>>> + off = ofnode_to_offset(phandle.node);
>>> + ret = fdt_node_check_compatible(fdt, off, "usb424,5744");
>>
>> return fdt_node_check_compatible(...);
> The return value of fdt_node_check_compatible is "0" in success case and "1" in failure.
There is more:
scripts/dtc/libfdt/libfdt.h
982 * returns:
983 * 0, if the node has a 'compatible' property listing the
given string
984 * 1, if the node has a 'compatible' property, but it does
not list
985 * the given string
986 * -FDT_ERR_NOTFOUND, if the given node has no 'compatible'
property
987 * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a
BEGIN_NODE tag
988 * -FDT_ERR_BADMAGIC,
989 * -FDT_ERR_BADVERSION,
990 * -FDT_ERR_BADSTATE,
991 * -FDT_ERR_BADSTRUCTURE, standard meanings
> I can't return fdt_node_check_compatible() directly as need to return -ENODEV for other half of the hub.
OK
More information about the U-Boot
mailing list