linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>
To: Jules Maselbas <jmaselbas@kalray.eu>
Cc: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] usb: dwc2: Try usb_get_phy_by_phandle instead of usb_get_phy
Date: Tue, 29 Dec 2020 08:17:28 +0000	[thread overview]
Message-ID: <6c840fda-c897-1306-160b-9e9c14fb8340@synopsys.com> (raw)
In-Reply-To: <20201226134522.fqpsd2fzlri2rcni@tellis.lin.mbt.kalray.eu>

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

      reply	other threads:[~2020-12-29  8:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 16:59 [RFC PATCH] usb: dwc2: Try usb_get_phy_by_phandle instead of usb_get_phy Jules Maselbas
2020-12-25 11:41 ` Artur Petrosyan
2020-12-26 13:45   ` Jules Maselbas
2020-12-29  8:17     ` Artur Petrosyan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c840fda-c897-1306-160b-9e9c14fb8340@synopsys.com \
    --to=arthur.petrosyan@synopsys.com \
    --cc=Minas.Harutyunyan@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jmaselbas@kalray.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).