Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp495524imm; Thu, 31 May 2018 04:28:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlu6XTPRf+eJQZRcTmlwSgJfX09pLVmedQFie92eMLMMoSpzUxqQANkAqaR6b+SY8Gf+JO X-Received: by 2002:a17:902:8207:: with SMTP id x7-v6mr6637610pln.100.1527766127230; Thu, 31 May 2018 04:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527766127; cv=none; d=google.com; s=arc-20160816; b=gNx/i//2yAI6W1rXHiJVeKA9kCKu5BtElVOD5EXIEBbEAaQ5C0j6QLjKsfHko45Fi+ swrcSzcWtbf6H7sdquAlrZlyPQzbIfJtTorgCYjzOpt/wb6I5Lu5C1humv3IGQqwrXev jh+tBsMZBMja9W/EZGBV9yTUgicvhWUQfekUxkWDu4UVUr0PIg1nAykwF9gtd4cZ2Sr1 /rr5d7P3+nrsMeV2KKOBP4WFGpHQDOJGimOwzUx1hIw4ZOWFh2qSCPu9VvP8vVJh+VvG HsoRjaCqoFibitfbKI8h4NFIb4SpRfXJVbyspp14pNlb3+X2p3K7KQFeK3AcoT8OZDpo J5Mg== 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=hbS4p+OkmSLa+/TqpYBOoGZxbilDJ/50z5RdxU4K6Ec=; b=ACgx/hT7Sy7soJrGkABratA61NJHO/c60lR1JyvWx/0dSFS625Xm3glhBgk2bWp8p2 Sxq/5k+X2CTXiJVEgDgTVsMi0dds+UypB6ODOAhoSBFUqGtQjPRCfT0KSqZv5ZhN1XSc rjMhvygSfTRpv1Z37CetwnqVKC2EJEafOD9T80BD6O+2ybK0VYcWGRAZN1dYSrWpPKgN cQOa40E+IL9fPbCK36u3Jdy+k1v7RoQNoptKQ6eoZkfZDLsyeNlsVQu0Y4dKKhjvZXqu I1EZdxhySuJx5L1D4kUla1x58y1tkuZ+OPw75G6tyBwlnAgb5+W2PUqrpOU6qIYpCWw9 naew== 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 u13-v6si9038424pfh.282.2018.05.31.04.28.33; Thu, 31 May 2018 04:28:47 -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 S1754985AbeEaL1F (ORCPT + 99 others); Thu, 31 May 2018 07:27:05 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8226 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754723AbeEaLWl (ORCPT ); Thu, 31 May 2018 07:22:41 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 19703C6F5CE71; Thu, 31 May 2018 19:22:25 +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:20 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , "Kalle Valo" , Intel Linux Wireless , Johannes Berg , Emmanuel Grumbach , , Subject: [PATCH v2 06/21] iwlwifi: mvm: use match_string() helper Date: Thu, 31 May 2018 19:11:11 +0800 Message-ID: <1527765086-19873-7-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: Kalle Valo Cc: Intel Linux Wireless Cc: Johannes Berg Cc: Emmanuel Grumbach Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Yisheng Xie --- v2: - let ret get return value of match_string - per Andy drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c index 0e6401c..d7ac511 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c @@ -671,16 +671,11 @@ static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf, }; int ret, bt_force_ant_mode; - for (bt_force_ant_mode = 0; - bt_force_ant_mode < ARRAY_SIZE(modes_str); - bt_force_ant_mode++) { - if (!strcmp(buf, modes_str[bt_force_ant_mode])) - break; - } - - if (bt_force_ant_mode >= ARRAY_SIZE(modes_str)) - return -EINVAL; + ret = match_string(modes_str, ARRAY_SIZE(modes_str), buf); + if (ret < 0) + return ret; + bt_force_ant_mode = ret; ret = 0; mutex_lock(&mvm->mutex); if (mvm->bt_force_ant_mode == bt_force_ant_mode) -- 1.7.12.4