Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vfio: selftests: Add a helper for matching vendor+device IDs

Add a helper function for matching a device against a given vendor and
device ID. This will be used in a subsequent commit to match devices
against drivers.

Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20250822212518.4156428-12-dmatlack@google.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

authored by

David Matlack and committed by
Alex Williamson
50d8fe80 92494780

+8 -3
+7
tools/testing/selftests/vfio/lib/include/vfio_util.h
··· 167 167 iova_t __to_iova(struct vfio_pci_device *device, void *vaddr); 168 168 iova_t to_iova(struct vfio_pci_device *device, void *vaddr); 169 169 170 + static inline bool vfio_pci_device_match(struct vfio_pci_device *device, 171 + u16 vendor_id, u16 device_id) 172 + { 173 + return (vendor_id == vfio_pci_config_readw(device, PCI_VENDOR_ID)) && 174 + (device_id == vfio_pci_config_readw(device, PCI_DEVICE_ID)); 175 + } 176 + 170 177 #endif /* SELFTESTS_VFIO_LIB_INCLUDE_VFIO_UTIL_H */
+1 -3
tools/testing/selftests/vfio/vfio_pci_device_test.c
··· 56 56 /* Check that Vendor and Device match what the kernel reports. */ 57 57 vendor = read_pci_id_from_sysfs("vendor"); 58 58 device = read_pci_id_from_sysfs("device"); 59 - 60 - ASSERT_EQ(vendor, vfio_pci_config_readw(self->device, PCI_VENDOR_ID)); 61 - ASSERT_EQ(device, vfio_pci_config_readw(self->device, PCI_DEVICE_ID)); 59 + ASSERT_TRUE(vfio_pci_device_match(self->device, vendor, device)); 62 60 63 61 printf("Vendor: %04x, Device: %04x\n", vendor, device); 64 62