All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch] igb: cleanup igb_enable_mas() a bit
Date: Thu, 19 Mar 2015 13:31:29 +0000	[thread overview]
Message-ID: <20150319133129.GA15502@mwanda> (raw)

Static checkers complain about this because we do:

	if (!(connsw & E1000_CONNSW_SERDESD)) {
		...
	} else if (connsw & E1000_CONNSW_SERDESD) {
		...
	} else {
		...
	}

Once you eliminate that E1000_CONNSW_SERDESD is set and not set then
there aren't any other possibilities so the else statement is dead
code.

This function always returns zero so if you delete the "ret_val"
variable, the code is shorter and more clear.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index f366b3b..8dd581f 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -1840,11 +1840,10 @@ static s32 igb_enable_mas(struct igb_adapter *adapter)
 {
 	struct e1000_hw *hw = &adapter->hw;
 	u32 connsw;
-	s32 ret_val = 0;
 
 	connsw = rd32(E1000_CONNSW);
-	if (!(hw->phy.media_type = e1000_media_type_copper))
-		return ret_val;
+	if (hw->phy.media_type != e1000_media_type_copper)
+		return 0;
 
 	/* configure for SerDes media detect */
 	if (!(connsw & E1000_CONNSW_SERDESD)) {
@@ -1852,15 +1851,8 @@ static s32 igb_enable_mas(struct igb_adapter *adapter)
 		connsw |= E1000_CONNSW_AUTOSENSE_EN;
 		wr32(E1000_CONNSW, connsw);
 		wrfl();
-	} else if (connsw & E1000_CONNSW_SERDESD) {
-		/* already SerDes, no need to enable anything */
-		return ret_val;
-	} else {
-		netdev_info(adapter->netdev,
-			"MAS: Unable to configure feature, disabling..\n");
-		adapter->flags &= ~IGB_FLAG_MAS_ENABLE;
 	}
-	return ret_val;
+	return 0;
 }
 
 void igb_reset(struct igb_adapter *adapter)

             reply	other threads:[~2015-03-19 13:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19 13:31 Dan Carpenter [this message]
2015-03-19 20:54 ` [patch] igb: cleanup igb_enable_mas() a bit Jeff Kirsher

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=20150319133129.GA15502@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@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.