All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] phy: core: Fix error checking in (devm_)phy_optional_get
Date: Tue, 07 Apr 2015 19:43:15 +0800	[thread overview]
Message-ID: <1428406995.5137.1.camel@phoenix> (raw)

Don't pass valid pointer to PTR_ERR, use PTR_ERR(phy) only when
IS_ERR(phy) is true.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/phy/phy-core.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 3791838f..f112fff 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -530,8 +530,10 @@ struct phy *phy_optional_get(struct device *dev, const char *string)
 {
 	struct phy *phy = phy_get(dev, string);
 
-	if (PTR_ERR(phy) == -ENODEV)
-		phy = NULL;
+	if (IS_ERR(phy)) {
+		if (PTR_ERR(phy) == -ENODEV)
+			phy = NULL;
+	}
 
 	return phy;
 }
@@ -584,8 +586,10 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string)
 {
 	struct phy *phy = devm_phy_get(dev, string);
 
-	if (PTR_ERR(phy) == -ENODEV)
-		phy = NULL;
+	if (IS_ERR(phy)) {
+		if (PTR_ERR(phy) == -ENODEV)
+			phy = NULL;
+	}
 
 	return phy;
 }
-- 
1.9.1




             reply	other threads:[~2015-04-07 11:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 11:43 Axel Lin [this message]
2015-04-07 14:21 ` [PATCH] phy: core: Fix error checking in (devm_)phy_optional_get Kishon Vijay Abraham I
2015-04-07 23:32   ` Axel Lin

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=1428406995.5137.1.camel@phoenix \
    --to=axel.lin@ingics.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.