Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp45190imm; Fri, 25 May 2018 13:55:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo53blcH7vZnEsubxIG+sBndbd0pMnSnnSSb4NPsEMGipvzEQH8vB3I2aH95psDD8Vgwdvp X-Received: by 2002:a63:4383:: with SMTP id q125-v6mr3249157pga.412.1527281756685; Fri, 25 May 2018 13:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527281756; cv=none; d=google.com; s=arc-20160816; b=envJKU5weAYcxtfv00XNDEhILQd2wIZ4uMtCfGhaLtIq3wTactKJnRRRijoyPGNQo6 ehhstbDULSAm+Uoy3LyiF6spg3BdA1OMLx1qfDDQw/ObLkKFSsaZ2kLE9pI/Q7X8lObq V9GVQR4Mz/Mk7haIrKc95DuL7dx5wQa+0QuaJZwaLs09yBpekHccUrj+EYtsCoys8bC/ dZFka4Z93vG+PDg0PDniIPqVudbDv8ffoXga9xD3RdEx67fyHwg05HR5sxdFjSUDGiXh Eyn43IzfYKermfzZDM6n7N1OYQVXpsPxQ0PztWEpeKvmPWb+2AGDgkvO3nJIxJNpQt0/ g6Lw== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=XcdT71PNonM6EBAI0NMALTZNVIR3aIOHInMh3comWlg=; b=ydzAEJV1tLorQF7Ljaw+4II/uyp6KR8tvcOeL005mSwF14I+Xp48uKzrDxLUMFLF1Z r6NEaUM3nK5D7/6OfohcBekC/84U4gmf1rBReU2VXmzhQLBHpXRo2Ocsym9kjykGIlSO BZLGLG5tdoAJzWbRXwn9Sp98gq4CUWCxQ4MKEgU49i18rQoJoR7gLcbMGRJiG1tjVMTM 5FjHHVDPHDujZSdgSkO6revob0ZdZmYeMcEumdJ/AcIsVq5MzIm1tKkBu0TuRUJwkYQ8 QWHeclJu5Y7BqOcsH0zq/SULh5Xf9AfV1bwteIsmtbou91FE3zBWClZordZCsZZ0fGyU flpA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5-v6si3821186pll.525.2018.05.25.13.55.41; Fri, 25 May 2018 13:55:56 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968460AbeEYUze (ORCPT + 99 others); Fri, 25 May 2018 16:55:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48430 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968275AbeEYUzd (ORCPT ); Fri, 25 May 2018 16:55:33 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88F0D30CAE36; Fri, 25 May 2018 20:55:33 +0000 (UTC) Received: from w520.home (ovpn-116-135.phx2.redhat.com [10.3.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E9E193D92; Fri, 25 May 2018 20:55:33 +0000 (UTC) Date: Fri, 25 May 2018 14:55:32 -0600 From: Alex Williamson To: Yisheng Xie Cc: , Subject: Re: [PATCH 08/33] vfio: use match_string() helper Message-ID: <20180525145532.1de2e94f@w520.home> In-Reply-To: <1526903890-35761-9-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-9-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 25 May 2018 20:55:33 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 May 2018 19:57:45 +0800 Yisheng Xie wrote: > 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(-) Applied to the vfio next branch for v4.18 with Andy's R-b. Thanks, Alex > 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; > } > > /*