[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1526903890-35761-9-git-send-email-xieyisheng1@huawei.com>
Date: Mon, 21 May 2018 19:57:45 +0800
From: Yisheng Xie <xieyisheng1@...wei.com>
To: <linux-kernel@...r.kernel.org>
CC: Yisheng Xie <xieyisheng1@...wei.com>,
Alex Williamson <alex.williamson@...hat.com>,
<kvm@...r.kernel.org>
Subject: [PATCH 08/33] vfio: use match_string() helper
match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.
Cc: Alex Williamson <alex.williamson@...hat.com>
Cc: kvm@...r.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@...wei.com>
---
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
Powered by blists - more mailing lists