From patchwork Fri Sep 14 15:05:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhong jiang X-Patchwork-Id: 10600925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57AAF14DB for ; Fri, 14 Sep 2018 15:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F93A2B933 for ; Fri, 14 Sep 2018 15:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13D0B2B93D; Fri, 14 Sep 2018 15:18:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AE5C02B933 for ; Fri, 14 Sep 2018 15:18:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=JlPGPaI9cpCrC2qnJ2JKt06VQdWAJOeGw1eL/92KW6I=; b=LQ3/kMt+jCTwPw ma785y0CRrvwu+uYHgznN6QLJSPdFC0SP5ZK7LZrl3jYugYN53o5aNURP0TpFOr5oAYibW8mJj7W8 +jTz49R+6H1BJsVIuE8G0XRo6cKpRY4QZqcAkvdSfUMJtloqMPGnG7AbN6qgiUd5EyEFITJtQJ0Ce X5z1Aoaa/lra2os6hzQ2S493NEhnIINsTfwohgLBiHCC1o7YNBjA+dlIf7QaTufJOzVpb6uN1DaAD BDtsMUkjzUgIBzR4iBpNu7NQ4YXgQ1lR1M63Yu8UnmzP+ACZGfhOGXtgsuUCDhEPsoYBM1DfOxzhd zjSoJzpP5SEQClkzASqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g0prI-0004Ho-QP; Fri, 14 Sep 2018 15:18:12 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g0prF-0004Fv-5F for linux-arm-kernel@lists.infradead.org; Fri, 14 Sep 2018 15:18:10 +0000 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C4D986C6111FB; Fri, 14 Sep 2018 23:17:38 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Fri, 14 Sep 2018 23:17:35 +0800 From: zhong jiang To: , , Subject: [PATCH] arm: common: use match_string() helper to simplify the code Date: Fri, 14 Sep 2018 23:05:19 +0800 Message-ID: <1536937519-31611-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180914_081809_413529_547411F8 X-CRM114-Status: UNSURE ( 9.05 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gregory.clement@bootlin.com, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;