[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] PCI/ATS: tidy {en,dis}able_ats_device() a little



commit 31bebd739bfe6ac2c33ff5bfa4b4c2bac2cc670b
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Jan 7 16:00:37 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jan 8 08:07:19 2026 +0100

    PCI/ATS: tidy {en,dis}able_ats_device() a little
    
    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 <jbeulich@xxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 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);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.