mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jules Maselbas <jmaselbas@kalray.eu>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@kalray.eu>
Subject: [PATCH v2] fixup! usb: dwc2: Add support for optional usb phy
Date: Mon, 14 Dec 2020 12:03:57 +0100	[thread overview]
Message-ID: <20201214110357.20469-1-jmaselbas@kalray.eu> (raw)
In-Reply-To: <20201210103104.3816-1-jmaselbas@kalray.eu>

In this fixup I've changed to call order for phy initialisation:
phy_init and then phy_power_on. Same for the deinitiailisation:
phy_power_off then phy_exit. Which seems to be the correct way.

Also fix the exit path.

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/usb/dwc2/dwc2.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index 5e95e8b22..98f9b30b6 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -56,13 +56,12 @@ static int dwc2_probe(struct device_d *dev)
 		return ret;
 	}
 
-	if (dwc2->phy) {
-		ret = phy_power_on(dwc2->phy);
-		if (ret == 0)
-			ret = phy_init(dwc2->phy);
-		if (ret)
-			goto error;
-	}
+	ret = phy_init(dwc2->phy);
+	if (ret)
+		goto err_phy_init;
+	ret = phy_power_on(dwc2->phy);
+	if (ret)
+		goto err_phy_power;
 
 	ret = dwc2_check_core_version(dwc2);
 	if (ret)
@@ -93,9 +92,15 @@ static int dwc2_probe(struct device_d *dev)
 	else
 		ret = dwc2_set_mode(dwc2, dwc2->dr_mode);
 
+	if (ret)
+		goto error;
+
+	return 0;
 error:
-	if (dwc2->phy)
-		phy_power_off(dwc2->phy);
+	phy_power_off(dwc2->phy);
+err_phy_power:
+	phy_exit(dwc2->phy);
+err_phy_init:
 
 	return ret;
 }
@@ -103,16 +108,12 @@ error:
 static void dwc2_remove(struct device_d *dev)
 {
 	struct dwc2 *dwc2 = dev->priv;
-	int ret;
 
 	dwc2_host_uninit(dwc2);
 	dwc2_gadget_uninit(dwc2);
 
-	if (dwc2->phy) {
-		ret = phy_exit(dwc2->phy);
-		if (ret == 0)
-			phy_power_off(dwc2->phy);
-	}
+	phy_power_off(dwc2->phy);
+	phy_exit(dwc2->phy);
 }
 
 static const struct of_device_id dwc2_platform_dt_ids[] = {
-- 
2.17.1



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-12-14 11:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 10:31 [PATCH v2 1/4] " Jules Maselbas
2020-12-10 10:31 ` [PATCH v2 2/4] usb: dwc2: Remove unnecessary functions declaration Jules Maselbas
2020-12-10 10:31 ` [PATCH v2 3/4] usb: dwc2: Fix dr_mode check in dwc2_get_dr_mode Jules Maselbas
2020-12-10 10:31 ` [PATCH v2 4/4] usb: dwc2: Rename dwc2_core_snpsid to dwc2_check_core_version Jules Maselbas
2020-12-11 15:36 ` [PATCH v2 1/4] usb: dwc2: Add support for optional usb phy Sascha Hauer
2020-12-11 16:21   ` Jules Maselbas
2020-12-14 11:03 ` Jules Maselbas [this message]
2020-12-16  8:21 ` Sascha Hauer

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=20201214110357.20469-1-jmaselbas@kalray.eu \
    --to=jmaselbas@kalray.eu \
    --cc=barebox@lists.infradead.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