Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp494186imm; Thu, 31 May 2018 04:27:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI17G5Eub3Is2aMsH8QunQh4qWrZURsl2SdnQNWVzDmeFs8AvyUy+mAB3xnkeSnjCnot5b6 X-Received: by 2002:a65:480a:: with SMTP id h10-v6mr5074109pgs.403.1527766032181; Thu, 31 May 2018 04:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527766032; cv=none; d=google.com; s=arc-20160816; b=J42z2iujimT1PETpLyEMADMC2gLW/FxQldx//DF9EUKlH1Re8sQ0OkZFi1nDao0u+V MLdTYmRWWZVdMGldiOFQafpClCqJGsxxjU6KkxL7KkLeC7VgOZXDeBnr7L3O19XDOqSk nP0Lrzz/FTFvIJ0HoW6CHg/muJnO4Wv9on5z+dqGDygUnFxgQwf2jGcOalk76FYF2VL4 1CDa+yoRJMiVVINAGdQTodioVxd5Tyy4fnre9G5MwjIfnGNjFjTsqBNGZrWzHzgAexvx IbgCd1lIptw+cp/HUY0tuVEUyPliOowFf3ZoCAY4zAE1s/mwCfSZ3IyLJYMPReqkaqFL +E2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=rxeHTKmqjBvrTtPg5dy/Ra5UycRNPDMPYMQvWG5VEfs=; b=PCdxMQvRt3VCnuZlEF4wm/c7/UbGuB7qnl2b4NpPNjMJZgFywgIRfS32Af9xzmIifP xnbH++oQMZBVm+JpIcJwWtChYpkS3CqnEbTl8iTmU1gNQPWkELrBMqHtl888Ix7wsP43 KXfYSYQYfk+TCXFA+qu7nKajw33/kDuGlYipsj+TmNzdW6utUw0lTQtBylm9wQpQqJK5 6ZvvkzVmmv2HUewMyoMeUaEJF9l22oZ6MlOpW5W53yQ8KKsnDJO08bOmA5SFLbQOuRkQ jMGkJPgnbVjy50fIb1kiMJj4jMRh21ipiSrWqtYRR+/ldwTmOFqHLg2sgF4Tl/l/B/RU Z9tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l139-v6si37696096pfd.51.2018.05.31.04.26.58; Thu, 31 May 2018 04:27:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754809AbeEaLWr (ORCPT + 99 others); Thu, 31 May 2018 07:22:47 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8220 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754567AbeEaLWi (ORCPT ); Thu, 31 May 2018 07:22:38 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B9CCAD3036A48; Thu, 31 May 2018 19:22:24 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 19:22:18 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , "Ganesh Goudar" , Subject: [PATCH v2 04/21] cxgb4: use match_string() helper Date: Thu, 31 May 2018 19:11:09 +0800 Message-ID: <1527765086-19873-5-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org match_string() returns the index of an array for a matching string, which can be used instead of open coded variant. Cc: Ganesh Goudar Cc: netdev@vger.kernel.org Signed-off-by: Yisheng Xie --- v2: - no change from v1. drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c index 9da6f57..bd61610 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c @@ -782,17 +782,11 @@ static int cudbg_get_mem_region(struct adapter *padap, if (rc) return rc; - for (i = 0; i < ARRAY_SIZE(cudbg_region); i++) { - if (!strcmp(cudbg_region[i], region_name)) { - found = 1; - idx = i; - break; - } - } - if (!found) - return -EINVAL; + rc = match_string(cudbg_region, ARRAY_SIZE(cudbg_region), region_name); + if (rc < 0) + return rc; - found = 0; + idx = rc; for (i = 0; i < meminfo->mem_c; i++) { if (meminfo->mem[i].idx >= ARRAY_SIZE(cudbg_region)) continue; /* Skip holes */ -- 1.7.12.4