mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Meng Tang <tangmeng@uniontech.com>
To: davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Meng Tang <tangmeng@uniontech.com>
Subject: [PATCH] net: tulip: de4x5: Optimize if branch in de4x5_parse_params
Date: Tue, 15 Mar 2022 15:49:52 +0800	[thread overview]
Message-ID: <20220315074952.6577-1-tangmeng@uniontech.com> (raw)

In the de4x5_parse_params, 'if (strstr(p, "BNC_AUI"))' condition and
'if (strstr(p, "BNC_AUI"))' condition are both execute the statement
'lp->params.autosense = BNC', these two conditions can be combined.

In addition, in the current code logic, when p = "BNC", the judgments
need to be executed four times. In order to simplify the execution
process and keep the original code design, I used the statement which
is 'if (strstr(p, "BNC") || strstr(p, "BNC_AUI"))' to deal with it,
after that once 'strstr(p, "BNC")' is established, we no longer need
to judge whether 'strstr(p, "BNC_AUI")' is true(not NULL).

In this way, we can execute the judgment statement one time less.

Signed-off-by: Meng Tang <tangmeng@uniontech.com>
---
 drivers/net/ethernet/dec/tulip/de4x5.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
index 71730ef4cd57..5900b8ef7f6f 100644
--- a/drivers/net/ethernet/dec/tulip/de4x5.c
+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
@@ -5208,9 +5208,7 @@ de4x5_parse_params(struct net_device *dev)
 		lp->params.autosense = TP_NW;
 	    } else if (strstr(p, "TP")) {
 		lp->params.autosense = TP;
-	    } else if (strstr(p, "BNC_AUI")) {
-		lp->params.autosense = BNC;
-	    } else if (strstr(p, "BNC")) {
+	    } else if (strstr(p, "BNC") || strstr(p, "BNC_AUI")) {
 		lp->params.autosense = BNC;
 	    } else if (strstr(p, "AUI")) {
 		lp->params.autosense = AUI;
-- 
2.20.1




             reply	other threads:[~2022-03-15  7:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15  7:49 Meng Tang [this message]
2022-03-15 18:41 ` Jakub Kicinski

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=20220315074952.6577-1-tangmeng@uniontech.com \
    --to=tangmeng@uniontech.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®