Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp230196imm; Mon, 21 May 2018 05:15:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrIjOZTGdRuF/Z8R9FH55+AdMtHA6Tt8E5/4Xmh+wWsRzFrbk63ddspKBp/v/BNsqjxhmfb X-Received: by 2002:a17:902:bc4c:: with SMTP id t12-v6mr20442909plz.331.1526904951746; Mon, 21 May 2018 05:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904951; cv=none; d=google.com; s=arc-20160816; b=k+c8MAfUrdGWsVnGLKSiSXLdaxd68PrNubPDYYE6J/QG3TSPmCuDQpgjheED6pSpvR CrzeYev2OLiSr9XPOvWFguN5ncERAl2Xm80FtsEiuec1lC5LH25N362ZNOEeYk5rS+WF ch6QMLUh+o5lNdBhvZvdq6Yblk8WXUc2UjoVJF3MYeKpwACI92EeSr3k/jiYTst1T16k Ai5OfVJ0zPH4hVo7ys2X2zzz2xdUfvf8apVh4SnMiyJhWUd+K4Ohh0VpOwQNh6IVwa9m 9UmL10PEUdiquDnu25MLTECJ+cj4ywTuFxRjjyVYOBXwLG22jvWM5i8eKJe9/HuXcsLL htvA== 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=Kaas2Z9scnr0bchGhBvdEvd4Of6MPO8KJ+nhz8Cw5KY=; b=pc/KQhx0+xf8MDKiH9ftHynYrJrE6r2GYoQERmYNMWk710yojyfPI78sOOmlF2/eWu rySQblVFZNY4ptua6O37+Qv04gMAHVr11jmBQMg0d3dqBCFMygxNg331vrDoeq0OfBe7 z1zxtQzqb/0zYdUPTo92T2W1ZVEnyLTpM3FNAtu8uJ4koxIP52e0IWMWTgieQt9s4HQU RI5BHuLypVpKAITqukwGV2m9JJliTpPTmedSfi920tDVBDJ1PwkBUcxE51T5DFiV5tUS T+UyY5ZkZrCAV47Uw7JwkRrBmyzei4A/U6oKXOnpMOh57aFPJlP7IuQlSrNigtmhlV54 4bbQ== 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 j28-v6si14204980pfe.337.2018.05.21.05.15.34; Mon, 21 May 2018 05:15:51 -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 S1752838AbeEUMJI (ORCPT + 99 others); Mon, 21 May 2018 08:09:08 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:38629 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752198AbeEUMJA (ORCPT ); Mon, 21 May 2018 08:09:00 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id EC2FC217A6C6E; Mon, 21 May 2018 20:08:55 +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:51 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Alex Williamson , Subject: [PATCH 08/33] vfio: use match_string() helper Date: Mon, 21 May 2018 19:57:45 +0800 Message-ID: <1526903890-35761-9-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 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 intead of open coded variant. Cc: Alex Williamson Cc: kvm@vger.kernel.org Signed-off-by: Yisheng Xie --- drivers/vfio/vfio.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 721f97f..6483387 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -630,8 +630,6 @@ static struct vfio_device *vfio_group_get_device(struct vfio_group *group, static bool vfio_dev_whitelisted(struct device *dev, struct device_driver *drv) { - int i; - if (dev_is_pci(dev)) { struct pci_dev *pdev = to_pci_dev(dev); @@ -639,12 +637,9 @@ static bool vfio_dev_whitelisted(struct device *dev, struct device_driver *drv) return true; } - for (i = 0; i < ARRAY_SIZE(vfio_driver_whitelist); i++) { - if (!strcmp(drv->name, vfio_driver_whitelist[i])) - return true; - } - - return false; + return match_string(vfio_driver_whitelist, + ARRAY_SIZE(vfio_driver_whitelist), + drv->name) >= 0; } /* -- 1.7.12.4