Subject: Re: [PATCH v2 03/10] usb: ehci-orion: avoid double PHY initialization

From: Miquel Raynal <[email-masked]>
Date: Mon, 21 Jan 2019 11:00:47 +0100

Hi Sergei,

Sergei Shtylyov <[email-masked]> wrote on Fri, 11
Jan 2019 21:03:01 +0300:

> Hello!
> 
> On 01/11/2019 04:31 PM, Miquel Raynal wrote:
> 
> > No need to initialize the PHY from the driver's probe. It is done by
> > the core automatically and doing it twice would increment the
> > phy->powercount counter to 2 instead of 1. During later suspend
> > operation, the counter will be decremented to one, no phy->power_off()
> > will occur and worst than that, the following phy->power_on() at  
> 
>    Worse.

Noted

> 
> > resume time will be also skipped, failing the whole S2RAM operation.
> > 
> > Signed-off-by: Miquel Raynal <[email-masked]>
> > ---
> >  drivers/usb/host/ehci-orion.c | 26 +++-----------------------
> >  1 file changed, 3 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
> > index 1ad72647a069..3109f082949e 100644
> > --- a/drivers/usb/host/ehci-orion.c
> > +++ b/drivers/usb/host/ehci-orion.c
> > @@ -257,15 +257,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
> >  	if (IS_ERR(priv->phy)) {
> >  		err = PTR_ERR(priv->phy);
> >  		if (err != -ENOSYS)
> > -			goto err_phy_get;
> > -	} else {
> > -		err = phy_init(priv->phy);
> > -		if (err)
> > -			goto err_phy_init;
> > -
> > -		err = phy_power_on(priv->phy);
> > -		if (err)
> > -			goto err_phy_power_on;
> > +			goto err_dis_clk;  
> 
>    Familiar code in unfamiliar place. Somebody must have blindly copied it... :-)

Actually a git blame shows that this code is there since 2014, 4 years
before the HCD core supported PHYs. This driver was probably forgotten
during the process. 

Thanks,
Miquèl

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel