lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6c840fda-c897-1306-160b-9e9c14fb8340@synopsys.com>
Date:   Tue, 29 Dec 2020 08:17:28 +0000
From:   Artur Petrosyan <Arthur.Petrosyan@...opsys.com>
To:     Jules Maselbas <jmaselbas@...ray.eu>
CC:     Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH] usb: dwc2: Try usb_get_phy_by_phandle instead of
 usb_get_phy

Hi Jules,

On 12/26/2020 17:45, Jules Maselbas wrote:
> Hi Artur,
> 
> On Fri, Dec 25, 2020 at 11:41:04AM +0000, Artur Petrosyan wrote:
>>> @@ -251,7 +251,12 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
>>>    	}
>>>    
>>>    	if (!hsotg->phy) {
>>> -		hsotg->uphy = devm_usb_get_phy(hsotg->dev, USB_PHY_TYPE_USB2);
>>> +		if (hsotg->dev->of_node)
>>> +			i = of_property_match_string(hsotg->dev->of_node, "phy-names", "usb2-phy");
>>
>> According the device tree you have provided the value of "i" will always
>> be "0".
> Yes
> 
>>> +		if (hsotg->dev->of_node && i >= 0)
>>> +			hsotg->uphy = devm_usb_get_phy_by_phandle(hsotg->dev, "phys", i);
>>
>> Why do you use the value of "i" while in "<&usb_phy0>" you have only one
>> phy. If you had several phy-names and the value of "i" gets more than 0,
>> then based on your usb_phy0 "devm_usb_get_phy_by_phandle" function will
>> return error. So, maybe it would be more correct (based on your device
>> tree), to use below command
>> hsotg->uphy = devm_usb_get_phy_by_phandle(hsotg->dev, "phys", 0);
> Yes I could use 0 instead of i, but I would like this to work not only
> for my case where the "usb2-phy" phandle comes first.
> 
> I've tried to follow what's done in phy-core.c, as done by the function
> phy_get. Where it first call "of_property_match_string" and then get the
> phy with the matched index.
> 
> I don't see how, in my case, the function "devm_usb_get_phy_by_phandle" can
> be called with i greater than 0, and returning an error.

I have noticed that there might be no need to check for "i >= 0" at all 
because "of_parse_phandle()" function has a check for index to not be 
less then 0.

> 
> Best,
> Jules
> 

Regards,
Artur

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ