From patchwork Mon May 21 11:57:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Yisheng X-Patchwork-Id: 10415065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A0C0600CC for ; Mon, 21 May 2018 12:21:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48E0C28867 for ; Mon, 21 May 2018 12:21:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B31628832; Mon, 21 May 2018 12:21:20 +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 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 A6B5128832 for ; Mon, 21 May 2018 12:21:19 +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:References:In-Reply-To: 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: List-Owner; bh=tUVYXv5Vlp+MTzft3jufLE7TQi0s4SXsBxncLI/gt/w=; b=jXTDxomoM7KGjN uwJxF2XaPgGswHDdnywH2L465VhXxEQsHulmg5p0GV7JaCIfZ6xgO9Cbihc57qetcp31GWlK/au2l g+vGsKIwvkFSUY9QUk1bt2y5qtqlWfsGUenEz6wTL6nkD1IHmzGaUZoCfsfCXk0oVp1cMhmiUtr0P w2fBfWKwZh5MnfIbP7xYSW/m52FqXeszei+n4jDz9Rq2gOyIO1BtzgH9PUvrbVinH3mQkzXzeZHPq J4Q3dzF8ihCFLrqQ9sB+sb7I06+Dbj4G6LwBK/w4d9qIH52gyoSJBtwh5jiCgmxvoQ6x65735c0rQ PfU0+tMR0d06Lxsue+CQ==; 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 1fKjoN-0006e8-HP; Mon, 21 May 2018 12:21:11 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKjo1-0004pr-W6; Mon, 21 May 2018 12:20:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ez04wZYc6KbgZ3LMpt4WhnheiP1XOyMC2BCQlLSXcWQ=; b=SqiJnGnFYflEL9147itW5pfuI +LlKBfz3/qKlzXOn/8BUb9OgLY9gBgk4wC42xkml5CvhllrUxJLBqNFIrN3JSFgjAFVPjSsaJEZoU L3fNiPRubpGkdiHuMvoHorGoIzOMvQzUsxCEwWChkYDTz2Y6zBwKqrtKB7MRXq/Sk9h29i6SkpGne ZvIz3wiIoxnF2GaVrOZpnI2Y8Ygh+bTQh7XyQtt/7W3/x8LXz1l8deZUUcODfqSUW+XJJ3PrN7VQF xtrZZVJW1Ps5nDReKBaU0tzvb1Jsc3bgWOcUff/FxEhpLxFZjlfSnpZffurcnqTptxcgjLc1ZDgXX TEGvmwqLA==; Received: from [45.249.212.35] (helo=huawei.com) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKjd1-00047C-2I; Mon, 21 May 2018 12:09:29 +0000 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 627861B41F4AB; Mon, 21 May 2018 20:09:01 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Mon, 21 May 2018 20:08:53 +0800 From: Yisheng Xie To: Subject: [PATCH 12/33] clk: bcm2835: use match_string() helper Date: Mon, 21 May 2018 19:57:49 +0800 Message-ID: <1526903890-35761-13-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> 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-20180521_130927_534928_FA3C3607 X-CRM114-Status: GOOD ( 11.64 ) 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: Yisheng Xie , Stefan Wahren , Stephen Boyd , Michael Turquette , Eric Anholt , linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.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 intead of open coded variant. Cc: Michael Turquette Cc: Stephen Boyd Cc: Eric Anholt Cc: Stefan Wahren Cc: linux-clk@vger.kernel.org Cc: linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Yisheng Xie Reviewed-by: Eric Anholt --- drivers/clk/bcm/clk-bcm2835.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index fa0d5c8..a27c0d2 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1395,8 +1395,7 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, struct bcm2835_clock *clock; struct clk_init_data init; const char *parents[1 << CM_SRC_BITS]; - size_t i, j; - int ret; + int i, ret; /* * Replace our strings referencing parent clocks with the @@ -1405,12 +1404,11 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, for (i = 0; i < data->num_mux_parents; i++) { parents[i] = data->parents[i]; - for (j = 0; j < ARRAY_SIZE(cprman_parent_names); j++) { - if (strcmp(parents[i], cprman_parent_names[j]) == 0) { - parents[i] = cprman->real_parent_names[j]; - break; - } - } + ret = match_string(cprman_parent_names, + ARRAY_SIZE(cprman_parent_names), + parents[i]); + if (ret >= 0) + parents[i] = cprman->real_parent_names[ret]; } memset(&init, 0, sizeof(init));