From 31bebd739bfe6ac2c33ff5bfa4b4c2bac2cc670b Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 7 Jan 2026 16:00:37 +0100 Subject: [PATCH] PCI/ATS: tidy {en,dis}able_ats_device() a little MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use appropriate types for the control register value as well as the capability position. Constify a pointer. Use "else" in favor of encoding the opposite condition of the earlier if(). Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- xen/drivers/passthrough/ats.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/ats.c b/xen/drivers/passthrough/ats.c index 0da183d057..c20bfc8ee7 100644 --- a/xen/drivers/passthrough/ats.c +++ b/xen/drivers/passthrough/ats.c @@ -23,10 +23,9 @@ boolean_param("ats", ats_enabled); int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list) { - u32 value; - int pos; + uint16_t value; + unsigned int pos = pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS); - pos = pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS); BUG_ON(!pos); if ( iommu_verbose ) @@ -35,7 +34,7 @@ int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list) value = pci_conf_read16(pdev->sbdf, pos + ATS_REG_CTL); if ( value & ATS_ENABLE ) { - struct pci_dev *other; + const struct pci_dev *other; list_for_each_entry ( other, ats_list, ats.list ) if ( other == pdev ) @@ -44,8 +43,7 @@ int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list) break; } } - - if ( !(value & ATS_ENABLE) ) + else { value |= ATS_ENABLE; pci_conf_write16(pdev->sbdf, pos + ATS_REG_CTL, value); @@ -69,7 +67,7 @@ int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list) void disable_ats_device(struct pci_dev *pdev) { - u32 value; + uint16_t value; BUG_ON(!pdev->ats.cap_pos);