diff mbox series

net: tulip: de4x5: Optimize if branch in de4x5_parse_params

Message ID 20220315074952.6577-1-tangmeng@uniontech.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series net: tulip: de4x5: Optimize if branch in de4x5_parse_params | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 3 maintainers not CCed: arnd@arndb.de zhangyue1@kylinos.cn linux-parisc@vger.kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: Statements should start on a tabstop
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Meng Tang March 15, 2022, 7:49 a.m. UTC
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(-)

Comments

Jakub Kicinski March 15, 2022, 6:41 p.m. UTC | #1
On Tue, 15 Mar 2022 15:49:52 +0800 Meng Tang wrote:
> 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>

This is ancient code, let's leave it be.
diff mbox series

Patch

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;