Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1058267imm; Mon, 21 May 2018 20:31:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrX5sbwhN+8gBVDIEahzIFJ9KnyPGk4qyGw7PAt/ham1Qim5IL1gp0j81MOuABmzBmzOGzj X-Received: by 2002:a17:902:6b09:: with SMTP id o9-v6mr23539638plk.256.1526959867468; Mon, 21 May 2018 20:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526959867; cv=none; d=google.com; s=arc-20160816; b=g6NhuH0ZqYrQBd/cSmzFnHtQx27f2k45IvTR67hMaiPZfkUIGEoUqKfPiUNdc3dTXA qN+IXjv9H8esHo1o4yvCtnZ8bSihOMJLdMyrEMns86BuILCSfNOvRdJIgyPaGVhLmSvz 2oTqKUnmkmSDtLwg0nk41SwZU8PJx+3XzAqPO8MFW3I1oU1rBIwO1jBgfacuu9iAQWnP LTWy6cmABj0Yqc0mUHd/WGRyOXXifOmoJ0s0gq8A4Ncn9q6p4LqOJn/80voz9N3KxNco neMznT6QyHmV2zv4U7WhuiVm58ONKI/iw5Yd3d4MotSEr3x0sXh/qMlH7xwVzUKZ6t7l nYTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=4Oj1eq36yvPqhgfqqzovpvyJ+ruK1ztpCbulSk76ACM=; b=MrrnlZcPxrF6gJf7vm61d9nTrHQIXSRMqJ3wTYpLvxALbNFs5EBUAEmENb8buynhnd U08BS82coiRHS2jq74c60+Uz2GRNmL4C9hS/06ewXPKtq3LWBKcxmRnENlH8gj5Y52TJ ERJR354E/Jzjaj+zUXampjzuyVZC0EjQ/AUVJFCXlH/u36CUNNrADFvrVymyLjzSmIX5 Wkqf2LjFpD5RahkOdj+v7McI+aTmbLk/rGyBdub0+srsn2GEdNf6ATDSYH769UouWaR6 /11tM1UZZyMJbMzbX0Q44yKD8KWk5AddNAbmUEruWqNzjjrJZxRJ0xcbLD+Fd5NkFy0F vMZA== 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 z14-v6si12055573pgc.617.2018.05.21.20.30.52; Mon, 21 May 2018 20:31:07 -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 S1752644AbeEVDa1 (ORCPT + 99 others); Mon, 21 May 2018 23:30:27 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8126 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751271AbeEVDaY (ORCPT ); Mon, 21 May 2018 23:30:24 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 88DE8ACB3AFA9; Tue, 22 May 2018 11:30:09 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.382.0; Tue, 22 May 2018 11:30:07 +0800 Subject: Re: [PATCH 07/33] iwlwifi: mvm: use match_string() helper To: Andy Shevchenko References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-8-git-send-email-xieyisheng1@huawei.com> CC: Linux Kernel Mailing List , Kalle Valo , Intel Linux Wireless , "Johannes Berg" , Emmanuel Grumbach , "open list:TI WILINK WIRELES..." , netdev From: Yisheng Xie Message-ID: <63a78572-b7d3-9cc7-9e22-5bd19cad3333@huawei.com> Date: Tue, 22 May 2018 11:30:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On 2018/5/22 5:43, Andy Shevchenko wrote: > On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie wrote: >> match_string() returns the index of an array for a matching string, >> which can be used intead of open coded variant. > >> 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)) > >> + bt_force_ant_mode = match_string(modes_str, >> + ARRAY_SIZE(modes_str), buf); > > One line? hmm, if use ret instead it will no over 80 chars. > >> + if (bt_force_ant_mode < 0) >> return -EINVAL; > > I would rather use > > ret = match_string(); > if (ret < 0) > return ret; > > bt_force_... = ret; > > But it's up tu Loca. OK, I will change it if Loca agree your opinion. Thanks Yisheng > >> >> ret = 0; > > >