From: zhong jiang <zhongjiang@huawei.com>
To: <jason@lakedaemon.net>, <andrew@lunn.ch>,
<sebastian.hesselbarth@gmail.com>
Cc: <gregory.clement@bootlin.com>, <linux@armlinux.org.uk>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] arm: common: use match_string() helper to simplify the code
Date: Fri, 14 Sep 2018 23:05:19 +0800 [thread overview]
Message-ID: <1536937519-31611-1-git-send-email-zhongjiang@huawei.com> (raw)
match_string() returns the index of an array for a matching string,
which can be used instead of open coded implementation.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
arch/arm/plat-orion/common.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
index a2399fd..d705ffa 100644
--- a/arch/arm/plat-orion/common.c
+++ b/arch/arm/plat-orion/common.c
@@ -479,17 +479,14 @@ void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
void __init orion_ge00_switch_init(struct dsa_chip_data *d)
{
- unsigned int i;
+ int index;
if (!IS_BUILTIN(CONFIG_PHYLIB))
return;
- for (i = 0; i < ARRAY_SIZE(d->port_names); i++) {
- if (!strcmp(d->port_names[i], "cpu")) {
- d->netdev[i] = &orion_ge00.dev;
- break;
- }
- }
+ index = match_string(d->port_names, ARRAY_SIZE(d->port_names), "cpu");
+ if (index >= 0)
+ d->netdev[index] = &orion_ge00.dev;
orion_ge00_switch_board_info.mdio_addr = d->sw_addr;
orion_ge00_switch_board_info.platform_data = d;
--
1.7.12.4
next reply other threads:[~2018-09-14 15:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-14 15:05 zhong jiang [this message]
2018-09-14 23:52 ` [PATCH] arm: common: use match_string() helper to simplify the code kbuild test robot
2018-09-15 6:46 ` zhong jiang
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=1536937519-31611-1-git-send-email-zhongjiang@huawei.com \
--to=zhongjiang@huawei.com \
--cc=andrew@lunn.ch \
--cc=gregory.clement@bootlin.com \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=sebastian.hesselbarth@gmail.com \
/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).