Subject: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

From: [email-masked] (Matt Porter)
Date: Wed, 27 Nov 2013 17:36:50 -0500

On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
> On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
> > Hi,
> > 
> > On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
> > > If a generic phy is present, call phy_init()/phy_exit(). This supports
> > > generic phys that must be soft reset before power on.
> > > 
> > > Signed-off-by: Matt Porter <[email-masked]>
> > > ---
> > >  drivers/usb/gadget/s3c-hsotg.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
> > > index da3879b..8dfe33f 100644
> > > --- a/drivers/usb/gadget/s3c-hsotg.c
> > > +++ b/drivers/usb/gadget/s3c-hsotg.c
> > > @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
> > >  		goto err_supplies;
> > >  	}
> > >  
> > > +	if (hsotg->phy)
> > 
> > IS_ERR? If your phy_get fails *phy* will have a error value..
> 
> Yes, thanks. I'll fix these and also note that the same issue exists in
> Kamil's patch for these same hsotg->phy conditional uses. I'll work with
> Kamil to either get those addressed there or in a follow on fix.

I spoke too soon. If devm_phy_get fails, we don't set hsotg->phy and probe
defer thus not reaching this point. Since hsotg->phy is either NULL or a
valid struct phy *, this is correct as is throughout the driver.

> > 
> > > +		phy_init(hsotg->phy);
> > > +
> > >  	/* usb phy enable */
> > >  	s3c_hsotg_phy_enable(hsotg);
> > >  
> > > @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
> > >  	}
> > >  
> > >  	s3c_hsotg_phy_disable(hsotg);
> > > +	if (hsotg->phy)
> > 
> > same here.
> 
> Ok.

Same above, this will be NULL on failure (but is only applicable at this
point on the platform data path.

-Matt