lkml.org 
[lkml]   [2018]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] arm: common: use match_string() helper to simplify the code
Date
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
\
 
 \ /
  Last update: 2018-09-14 17:18    [W:0.064 / U:7.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site