Re: [PATCH v12 2/4] selftests/vfio: Add generic PCI command register helpers

David Matlack
2026-04-06T23:19:58Z

> diff --git a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
> index 2858885a89bb..e5e290eed510 100644
> --- a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
> +++ b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
> @@ -65,6 +65,16 @@ void vfio_pci_config_access(struct vfio_pci_device *device, bool write,
> #define vfio_pci_config_writew(_d, _o, _v) vfio_pci_config_write(_d, _o, _v, u16)
> #define vfio_pci_config_writel(_d, _o, _v) vfio_pci_config_write(_d, _o, _v, u32)
>
> +#define vfio_pci_cmd_set(_device, _bits) do { \
> + u16 __cmd = vfio_pci_config_readw((_device), PCI_COMMAND); \
> + vfio_pci_config_writew((_device), PCI_COMMAND, __cmd | (_bits));\
> +} while (0)
> +
> +#define vfio_pci_cmd_clear(_device, _bits) do { \
> + u16 __cmd = vfio_pci_config_readw((_device), PCI_COMMAND); \
> + vfio_pci_config_writew((_device), PCI_COMMAND, __cmd & ~(_bits));\
> +} while (0)

Whoops, missed this in my previous email.

These should be static inline instead of macros.