diff options
author | Yisheng Xie <xieyisheng1@huawei.com> | 2018-05-21 14:57:45 +0300 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2018-06-08 19:24:33 +0300 |
commit | e77addf018f0c8d947ddc0bef2cd6d4791da7dde (patch) | |
tree | 8bb90082ddb4b0312c18c08af2f9ae2459c322be /drivers/vfio | |
parent | 6a62c1dfb5c7f6719361180fd0fdf45b15a35d95 (diff) | |
download | linux-e77addf018f0c8d947ddc0bef2cd6d4791da7dde.tar.xz |
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@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/vfio.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 721f97f8dac1..64833879f75d 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -630,8 +630,6 @@ static const char * const vfio_driver_whitelist[] = { "pci-stub" }; 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; } /* |