netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: davem@davemloft.net
Cc: linux@arm.linux.org.uk, B38611@freescale.com,
	netdev@vger.kernel.org,
	Fabio Estevam <fabio.estevam@freescale.com>
Subject: [PATCH net-next 2/3] fec: Do not set fep->clk_enet_out to NULL on error
Date: Mon,  1 Sep 2014 22:12:54 -0300	[thread overview]
Message-ID: <1409620375-20284-3-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1409620375-20284-1-git-send-email-festevam@gmail.com>

From: Fabio Estevam <fabio.estevam@freescale.com>

There is no need to set fep->clk_enet_out to NULL when devm_clk_get() returns an
error. We can simply use IS_ERR() instead, which makes the code simpler.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 76e4f56..e87cc66 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1605,7 +1605,7 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
 		ret = clk_prepare_enable(fep->clk_ipg);
 		if (ret)
 			goto failed_clk_ipg;
-		if (fep->clk_enet_out) {
+		if (!IS_ERR(fep->clk_enet_out)) {
 			ret = clk_prepare_enable(fep->clk_enet_out);
 			if (ret)
 				goto failed_clk_enet_out;
@@ -1624,7 +1624,7 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
 	} else {
 		clk_disable_unprepare(fep->clk_ahb);
 		clk_disable_unprepare(fep->clk_ipg);
-		if (fep->clk_enet_out)
+		if (!IS_ERR(fep->clk_enet_out))
 			clk_disable_unprepare(fep->clk_enet_out);
 		if (!IS_ERR(fep->clk_ptp)) {
 			mutex_lock(&fep->ptp_clk_mutex);
@@ -1636,7 +1636,7 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
 
 	return 0;
 failed_clk_ptp:
-	if (fep->clk_enet_out)
+	if (!IS_ERR(fep->clk_enet_out))
 		clk_disable_unprepare(fep->clk_enet_out);
 failed_clk_enet_out:
 		clk_disable_unprepare(fep->clk_ipg);
@@ -2632,8 +2632,6 @@ fec_probe(struct platform_device *pdev)
 
 	/* enet_out is optional, depends on board */
 	fep->clk_enet_out = devm_clk_get(&pdev->dev, "enet_out");
-	if (IS_ERR(fep->clk_enet_out))
-		fep->clk_enet_out = NULL;
 
 	fep->ptp_clk_on = false;
 	mutex_init(&fep->ptp_clk_mutex);
-- 
1.9.1

  parent reply	other threads:[~2014-09-02  1:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02  1:12 [PATCH net-next 0/3] fec: Do not use NULL pointer to indicate error Fabio Estevam
2014-09-02  1:12 ` [PATCH net-next 1/3] fec: Do not set fep->clk_ptp to NULL on error Fabio Estevam
2014-09-02  1:12 ` Fabio Estevam [this message]
2014-09-02  1:12 ` [PATCH net-next 3/3] fec: Do not set fep->reg_phy " Fabio Estevam
2014-09-02  1:37 ` [PATCH net-next 0/3] fec: Do not use NULL pointer to indicate error fugang.duan
2014-09-02 20:48 ` David Miller

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=1409620375-20284-3-git-send-email-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=B38611@freescale.com \
    --cc=davem@davemloft.net \
    --cc=fabio.estevam@freescale.com \
    --cc=linux@arm.linux.org.uk \
    --cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).