Linux USB
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: Pawel Laszczak <pawell@cadence.com>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
	"mathias.nyman@intel.com" <mathias.nyman@intel.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>, "rogerq@ti.com" <rogerq@ti.com>,
	Jun Li <jun.li@nxp.com>
Subject: Re: [PATCH v5 1/9] usb: cdns3: introduce set_phy_power_on{off} APIs
Date: Fri, 14 Aug 2020 05:29:32 +0000	[thread overview]
Message-ID: <20200814052840.GB22554@b29397-desktop> (raw)
In-Reply-To: <DM6PR07MB55298C1258149664502DCDCFDD430@DM6PR07MB5529.namprd07.prod.outlook.com>

On 20-08-13 12:09:58, Pawel Laszczak wrote:
> 
> >
> >Since we have both USB2 and USB3 PHYs for cdns3 controller, it is
> >better we have unity APIs to handle both USB2 and USB3's power, it
> >could simplify code for error handling and further power management
> >implementation.
> >
> >Reviewed-by: Jun Li <jun.li@nxp.com>
> >Signed-off-by: Peter Chen <peter.chen@nxp.com>
> >---
> > drivers/usb/cdns3/core.c | 43 ++++++++++++++++++++++++++--------------
> > 1 file changed, 28 insertions(+), 15 deletions(-)
> >
> >diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
> >index 19bbb5b7e6b6..8818935d157b 100644
> >--- a/drivers/usb/cdns3/core.c
> >+++ b/drivers/usb/cdns3/core.c
> >@@ -384,6 +384,27 @@ static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role)
> > 	return ret;
> > }
> >
> >+static int set_phy_power_on(struct cdns3 *cdns)
> >+{
> >+	int ret;
> >+
> >+	ret = phy_power_on(cdns->usb2_phy);
> >+	if (ret)
> >+		return ret;
> >+
> >+	ret = phy_power_on(cdns->usb3_phy);
> >+	if (ret)
> >+		phy_power_off(cdns->usb2_phy);
> >+
> >+	return ret;
> >+}
> >+
> >+static void set_phy_power_off(struct cdns3 *cdns)
> >+{
> >+	phy_power_off(cdns->usb3_phy);
> >+	phy_power_off(cdns->usb2_phy);
> >+}
> >+
> > /**
> >  * cdns3_probe - probe for cdns3 core device
> >  * @pdev: Pointer to cdns3 core platform device
> >@@ -477,14 +498,10 @@ static int cdns3_probe(struct platform_device *pdev)
> > 	if (ret)
> > 		goto err1;
> >
> >-	ret = phy_power_on(cdns->usb2_phy);
> >+	ret = set_phy_power_on(cdns);
> > 	if (ret)
> > 		goto err2;
> >
> >-	ret = phy_power_on(cdns->usb3_phy);
> >-	if (ret)
> >-		goto err3;
> >-
> > 	sw_desc.set = cdns3_role_set;
> > 	sw_desc.get = cdns3_role_get;
> > 	sw_desc.allow_userspace_control = true;
> >@@ -496,16 +513,16 @@ static int cdns3_probe(struct platform_device *pdev)
> > 	if (IS_ERR(cdns->role_sw)) {
> > 		ret = PTR_ERR(cdns->role_sw);
> > 		dev_warn(dev, "Unable to register Role Switch\n");
> >-		goto err4;
> >+		goto err3;
> > 	}
> >
> > 	ret = cdns3_drd_init(cdns);
> > 	if (ret)
> >-		goto err5;
> >+		goto err4;
> >
> > 	ret = cdns3_core_init_role(cdns);
> > 	if (ret)
> >-		goto err5;
> >+		goto err4;
> >
> > 	device_set_wakeup_capable(dev, true);
> > 	pm_runtime_set_active(dev);
> >@@ -522,14 +539,11 @@ static int cdns3_probe(struct platform_device *pdev)
> > 	dev_dbg(dev, "Cadence USB3 core: probe succeed\n");
> >
> > 	return 0;
> >-err5:
> >+err4:
> > 	cdns3_drd_exit(cdns);
> > 	usb_role_switch_unregister(cdns->role_sw);
> >-err4:
> >-	phy_power_off(cdns->usb3_phy);
> >-
> > err3:
> >-	phy_power_off(cdns->usb2_phy);
> >+	set_phy_power_off(cdns);
> > err2:
> > 	phy_exit(cdns->usb3_phy);
> > err1:
> 
> Dan Carpenter suggested me to use more meaningful labels instead err1 .. err5.

Yes, it is reasonable, we could follow this rule when design the new
function.

Peter
>  
> Reviewed-by: Pawel Laszczak<pawell@cadence.com>
> 
> Pawel
> 
> >@@ -553,8 +567,7 @@ static int cdns3_remove(struct platform_device *pdev)
> > 	pm_runtime_put_noidle(&pdev->dev);
> > 	cdns3_exit_roles(cdns);
> > 	usb_role_switch_unregister(cdns->role_sw);
> >-	phy_power_off(cdns->usb2_phy);
> >-	phy_power_off(cdns->usb3_phy);
> >+	set_phy_power_off(cdns);
> > 	phy_exit(cdns->usb2_phy);
> > 	phy_exit(cdns->usb3_phy);
> > 	return 0;
> >--
> >2.17.1
> 

-- 

Thanks,
Peter Chen

  reply	other threads:[~2020-08-14  5:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07  7:49 [PATCH v5 0/9] usb: some PM changes for cdns3 and xhci-plat Peter Chen
2020-07-07  7:49 ` [PATCH v5 1/9] usb: cdns3: introduce set_phy_power_on{off} APIs Peter Chen
2020-08-13 12:09   ` Pawel Laszczak
2020-08-14  5:29     ` Peter Chen [this message]
2020-07-07  7:49 ` [PATCH v5 2/9] usb: cdns3: add runtime PM support Peter Chen
2020-08-13 13:10   ` Pawel Laszczak
2020-07-07  7:49 ` [PATCH v5 3/9] usb: cdns3: imx: add glue layer runtime pm implementation Peter Chen
2020-08-13 13:20   ` Pawel Laszczak
2020-07-07  7:49 ` [PATCH v5 4/9] usb: host: xhci-plat: add platform data support Peter Chen
2020-07-07  7:49 ` [PATCH v5 5/9] usb: host: xhci-plat: add .suspend_quirk for struct xhci_plat_priv Peter Chen
2020-07-07  7:49 ` [PATCH v5 6/9] usb: host: xhci-plat: delete the unnecessary code Peter Chen
2020-07-07  7:49 ` [PATCH v5 7/9] usb: host: xhci-plat: add priv quirk for skip PHY initialization Peter Chen
2020-07-24  6:24   ` Peter Chen
2020-07-07  7:49 ` [PATCH v5 8/9] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Peter Chen
2020-08-17  4:39   ` Pawel Laszczak
2020-07-07  7:49 ` [PATCH v5 9/9] usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT Peter Chen
2020-08-17  4:37   ` Pawel Laszczak
2020-07-17  6:13 ` [PATCH v5 0/9] usb: some PM changes for cdns3 and xhci-plat Peter Chen

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=20200814052840.GB22554@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jun.li@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=pawell@cadence.com \
    --cc=rogerq@ti.com \
    /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