Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp801439imm; Mon, 21 May 2018 14:45:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqA/HE5kziazh0ieFRUflu+c22QXK5liYG7FQOSAkD6n2D55JQ2+pgxFUiYSfyTkHq1enBY X-Received: by 2002:a65:4ac8:: with SMTP id c8-v6mr12046550pgu.246.1526939101167; Mon, 21 May 2018 14:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939101; cv=none; d=google.com; s=arc-20160816; b=gu/dro3YY5bjrunPjYD4HM9KjCL8tYOa2W5IDd8plwg6cpTQ8xj4pMi7p+mxtKCD02 4oRL49xRdgtJZLyE/x8gPBRTyQxAQVx/f2DJJjJULKo8LFoc6mfOXtchP7es1fFe1SJm VxALN/sTsFBVjsp7RyiO+vPEo8V5ij0E50eywuC2JFzW2A1bTBpaWy1pA3bdGQjRK9ky arcUjklof+yQGZcl5pPIflHAIIF2d9extzfDiyRld9tTwSaTq4WWZCqfK1mER2dpNPuP wyavic93hJ6dxlIsIwNLXKtf0EmNGA5OkZX+30J9Ad8+yDSxZFHi3zVWD3o4IswtD94W v1Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=4o4uzGS77IaaOJXC0UvHh8KJCLkqaDDDYA/KQ7bCy28=; b=iAMGTPnw+8nsMID+eWgCocVE1t4vl57I57ykf3mOYf3ZmE7DZbgtxcF1U2zbDGPXym 7tDt051BkVCcSWXb8upHq6TcidyqwfNU8kpW6VRdsPtSkpyPsr46upXPFmLgw1utHnq0 K6Qkub1q0aMTLyMowV7TlW9r5zSjJhCXbh+0RyoJpP3gOVLGjTaYHzIiabuqVHaukqFJ sWv9aPb84nxjsq+XgrLpJD0bF+gKKCt7XMqe638+Qwp9OXWbxYjHKFYJQn7rwnpUSWbl lk+VeCYe9aCQ3KN1jcfRJlelksKTh8j0cJaVOnn1WWo6dlurDvUv1t0pAcwlxWQBX4YI 1kaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AqH3oMzD; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2-v6si2640457plo.577.2018.05.21.14.44.46; Mon, 21 May 2018 14:45:01 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AqH3oMzD; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754581AbeEUVne (ORCPT + 99 others); Mon, 21 May 2018 17:43:34 -0400 Received: from mail-qk0-f174.google.com ([209.85.220.174]:40487 "EHLO mail-qk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751694AbeEUVnX (ORCPT ); Mon, 21 May 2018 17:43:23 -0400 Received: by mail-qk0-f174.google.com with SMTP id r139-v6so823253qke.7; Mon, 21 May 2018 14:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=4o4uzGS77IaaOJXC0UvHh8KJCLkqaDDDYA/KQ7bCy28=; b=AqH3oMzDcfWrpiA6JTPMKMHOMf8dXbkV+umrClrOLuRnTDwt4zZhJy67hIEhOmgl+t sRwqjr/yMRgkMzhgQt8HW7ayHmgQ68Zktr8iYbdXBs5tM57fDH+1CK3A2iF5loQXdlJ1 eNnm6emlnZdAiIQYuuMj7s5jhq/HSezYLKTnHDqXYR9RXEFZivTdByYj7h1D3tBbD7gX G7FHXbT+uBFZAGxYWKvWp/uvATnB5sksNiSo3EHqP1FCfpSm6uDeyMb7JoMGjQaaZtL8 dPdsAFFNbA/Ifn1PwNk4n3ezTaHprHkjtVkwKTFBxSK0TOSNoPSU++UJZ17i4q/6wWIK qT6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=4o4uzGS77IaaOJXC0UvHh8KJCLkqaDDDYA/KQ7bCy28=; b=lGSNsh5sBSY/pBxItPpObxw49T7kI9ujfxBzk35IcM0Fa/4IUShh2RrMv0/MpGnmDv VSrIA5bTS5aV0ZaE29BF1PEhm6pi7al4i1zyt6tMHt0OjE/fjwhFkC4R64+BGq6apt02 BEnaWAQbg8IqGrObMbkpnopfBg/tSqsiiiPPgtTDivLst9PJ0tzVPvYeiGyBfdMapkVA FsM+TNrDbGenynJHFTSsGo+1AWIiaQPnnXEs+jGBfBQC5Y1XnDOkOOw7GSF86eahvwdP UpZEKkwLhd63sx9FYaC/3tnrC3IZKP3i3iF2k17delQ3u+oO7p0IOS4AX/di68/TOP3x jV8Q== X-Gm-Message-State: ALKqPwctBGMZGCKD2fJ+9+MxdbMIyy2NTdTwOD0lv9rTo1wcqkUawdUD vdIkb0mYADZgo+iFoUba/4i1TD1PRkM5eL5rxxw= X-Received: by 2002:a37:cbc1:: with SMTP id u62-v6mr17926571qkl.83.1526939002131; Mon, 21 May 2018 14:43:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.152.150 with HTTP; Mon, 21 May 2018 14:43:21 -0700 (PDT) In-Reply-To: <1526903890-35761-8-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-8-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 22 May 2018 00:43:21 +0300 Message-ID: Subject: Re: [PATCH 07/33] iwlwifi: mvm: use match_string() helper To: Yisheng Xie Cc: Linux Kernel Mailing List , Kalle Valo , Intel Linux Wireless , Johannes Berg , Emmanuel Grumbach , "open list:TI WILINK WIRELES..." , netdev Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > + 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. > > ret = 0; -- With Best Regards, Andy Shevchenko