Re: [PATCH v3 9/9] usb: chipidea: add support to the generic PHY framework in ChipIdea

From: Antoine Ténart
Date: Fri Aug 29 2014 - 10:22:27 EST


Hi,

On Tue, Aug 26, 2014 at 06:42:42PM +0800, Peter Chen wrote:
> On Fri, Aug 22, 2014 at 05:50:20PM +0200, Antoine Ténart wrote:
> >
> > /**
> > + * _ci_usb_phy_init: initialize phy taking in account both phy and usb_phy
> > + * interfaces
> > + * @ci: the controller
> > + *
> > + * This function returns an error code if the phy failed to init
> > + */
> > +static int _ci_usb_phy_init(struct ci_hdrc *ci)
> > +{
> > + int ret;
> > +
> > + if (ci->phy) {
> > + ret = phy_init(ci->phy);
> > + if (ret) {
> > + phy_exit(ci->phy);
> > + return ret;
> > + }
> > + ret = phy_power_on(ci->phy);
>
> phy_exit is needed to call after phy_power_on failed

I was pretty sure I made the change. Sorry for the noise, I'll fix that
in the next version.

> >
> > - if (ci->platdata->usb_phy)
> > + if (ci->platdata->phy)
> > + ci->phy = ci->platdata->phy;
> > + else if (ci->platdata->usb_phy)
> > ci->usb_phy = ci->platdata->usb_phy;
> > else
> > - ci->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
> > + ci->phy = devm_phy_get(dev, "usb-phy");
> >
> > - if (IS_ERR(ci->usb_phy)) {
> > - ret = PTR_ERR(ci->usb_phy);
> > + if (IS_ERR(ci->phy)) {
> > /*
> > * if -ENXIO is returned, it means PHY layer wasn't
> > * enabled, so it makes no sense to return -EPROBE_DEFER
> > * in that case, since no PHY driver will ever probe.
> > */
> > - if (ret == -ENXIO)
> > - return ret;
> > + if (PTR_ERR(ci->phy) == -ENXIO)
> > + return -ENXIO;
> >
> > - dev_err(dev, "no usb2 phy configured\n");
> > - return -EPROBE_DEFER;
> > + ci->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
> > + if (IS_ERR(ci->usb_phy)) {
> > + dev_err(dev, "no usb2 phy configured\n");
> > + return -EPROBE_DEFER;
> > + }
> > }
>
> I am a little puzzled of your above change, if ci->phy == NULL, any chances
> for devm_usb_get_phy(dev, USB_PHY_TYPE_USB2) is invoded?

Right, now that there's two PHY pointers we need to check if ci->phy is
NULL too.

> > diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
> > index 5a7ea93011dd..9e9da190a144 100644
> > --- a/drivers/usb/chipidea/debug.c
> > +++ b/drivers/usb/chipidea/debug.c
> > @@ -219,7 +219,9 @@ static int ci_otg_show(struct seq_file *s, void *unused)
> > fsm = &ci->fsm;
> >
> > /* ------ State ----- */
> > - usb_otg_state_string(ci->usb_phy->otg.state));
> > + if (ci->usb_phy)
> > + seq_printf(s, "OTG state: %s\n\n",
>
> Why above line is added? Did you delete wrongly before?

I'll fix that.

> > + usb_otg_state_string(ci->usb_phy->otg->state));
> >

Antoine

--
Antoine Ténart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/