public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/7] phy: generic: add error trace to detect PHY issue in uclass
Date: Tue, 12 Nov 2019 11:01:39 +0100	[thread overview]
Message-ID: <20191112100145.15940-1-patrick.delaunay@st.com> (raw)

Add an error trace for PHY errors directly in generic phy
functions provided by PHY uclass.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

This patch is requested by Marek Vasut to avoid code duplication
in usb host serie for dwc2:

See http://patchwork.ozlabs.org/patch/1176048/#2297595
[U-Boot,RESEND,1/5] usb: host: dwc2: add phy support


 drivers/phy/phy-uclass.c | 40 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index e201a90c8c..363985b881 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -109,56 +109,86 @@ int generic_phy_get_by_name(struct udevice *dev, const char *phy_name,
 int generic_phy_init(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!phy)
 		return 0;
 	ops = phy_dev_ops(phy->dev);
 
-	return ops->init ? ops->init(phy) : 0;
+	ret = ops->init ? ops->init(phy) : 0;
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",
+			phy->dev->name, ret);
+
+	return ret;
 }
 
 int generic_phy_reset(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!phy)
 		return 0;
 	ops = phy_dev_ops(phy->dev);
 
-	return ops->reset ? ops->reset(phy) : 0;
+	ret = ops->reset ? ops->reset(phy) : 0;
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to reset %s: %d.\n",
+			phy->dev->name, ret);
+
+	return ret;
 }
 
 int generic_phy_exit(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!phy)
 		return 0;
 	ops = phy_dev_ops(phy->dev);
 
-	return ops->exit ? ops->exit(phy) : 0;
+	ret = ops->exit ? ops->exit(phy) : 0;
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",
+			phy->dev->name, ret);
+
+	return ret;
 }
 
 int generic_phy_power_on(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!phy)
 		return 0;
 	ops = phy_dev_ops(phy->dev);
 
-	return ops->power_on ? ops->power_on(phy) : 0;
+	ret = ops->power_on ? ops->power_on(phy) : 0;
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
+			phy->dev->name, ret);
+
+	return ret;
 }
 
 int generic_phy_power_off(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!phy)
 		return 0;
 	ops = phy_dev_ops(phy->dev);
 
-	return ops->power_off ? ops->power_off(phy) : 0;
+	ret = ops->power_off ? ops->power_off(phy) : 0;
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to power off %s: %d.\n",
+			phy->dev->name, ret);
+
+	return ret;
 }
 
 UCLASS_DRIVER(phy) = {
-- 
2.17.1

             reply	other threads:[~2019-11-12 10:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 10:01 Patrick Delaunay [this message]
2019-11-12 10:01 ` [U-Boot] [PATCH 2/7] usb: gadget: dwc2: change trace level for phy errors managed by uclass Patrick Delaunay
2019-11-12 10:01 ` [U-Boot] [PATCH 3/7] board: sunxi: " Patrick Delaunay
2019-11-12 10:01 ` [U-Boot] [PATCH 4/7] usb: host: ohci: " Patrick Delaunay
2019-11-12 10:01 ` [U-Boot] [PATCH 5/7] usb: host: ehci-hcd: " Patrick Delaunay
2019-11-12 10:01 ` [U-Boot] [PATCH 6/7] usb: dwc3: " Patrick Delaunay
2019-11-12 10:01 ` [U-Boot] [PATCH 7/7] ata: dwc-ahci: " Patrick Delaunay

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=20191112100145.15940-1-patrick.delaunay@st.com \
    --to=patrick.delaunay@st.com \
    --cc=u-boot@lists.denx.de \
    /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