Skip to contentSkip to conversation

x86/pci: Use C99 style types for fixed integrals

PATCH In review Frediano Ziglio 3 participants 3 messages Jun 13, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pci: Use C99 style types for fixed integrals

Just code style change.

---
 xen/include/xen/pci.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
xen/include/xen/pci.h +13 -13
index ef60196653..f22bbc2776 100644
@@ -89,8 +89,8 @@ struct pci_dev_info {
     bool is_extfn;
     bool is_virtfn;
     struct {
-        u8 bus;
-        u8 devfn;
+        uint8_t bus;
+        uint8_t devfn;
     } physfn;
 };
 
@@ -209,26 +209,26 @@ static always_inline bool pcidevs_trylock(void)
 #define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) ((void)(d))
 #endif
 
-bool pci_known_segment(u16 seg);
-bool pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func);
+bool pci_known_segment(uint16_t seg);
+bool pci_device_detect(uint16_t seg, uint8_t bus, uint8_t dev, uint8_t func);
 int scan_pci_devices(void);
-enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn);
-int find_upstream_bridge(u16 seg, u8 *bus, u8 *devfn, u8 *secbus);
+enum pdev_type pdev_type(uint16_t seg, uint8_t bus, uint8_t devfn);
+int find_upstream_bridge(uint16_t seg, uint8_t *bus, uint8_t *devfn, uint8_t *secbus);
 
 void setup_hwdom_pci_devices(struct domain *d,
                              int (*handler)(uint8_t devfn,
                                             struct pci_dev *pdev));
 int pci_release_devices(struct domain *d);
-int pci_add_segment(u16 seg);
-const unsigned long *pci_get_ro_map(u16 seg);
-int pci_add_device(u16 seg, u8 bus, u8 devfn,
+int pci_add_segment(uint16_t seg);
+const unsigned long *pci_get_ro_map(uint16_t seg);
+int pci_add_device(uint16_t seg, uint8_t bus, uint8_t devfn,
                    const struct pci_dev_info *info, nodeid_t node);
-int pci_remove_device(u16 seg, u8 bus, u8 devfn);
+int pci_remove_device(uint16_t seg, uint8_t bus, uint8_t devfn);
 int pci_ro_device(int seg, int bus, int devfn);
 int pci_hide_device(unsigned int seg, unsigned int bus, unsigned int devfn);
 struct pci_dev *pci_get_pdev(const struct domain *d, pci_sbdf_t sbdf);
 struct pci_dev *pci_get_real_pdev(pci_sbdf_t sbdf);
-void pci_check_disable_device(u16 seg, u8 bus, u8 devfn);
+void pci_check_disable_device(uint16_t seg, uint8_t bus, uint8_t devfn);
 
 /*
  * Iterate without locking or preemption over all PCI devices known by Xen.
@@ -246,9 +246,9 @@ void pci_conf_write32(pci_sbdf_t sbdf, unsigned int reg, uint32_t data);
 uint32_t pci_conf_read(uint32_t cf8, uint8_t offset, uint8_t bytes);
 void pci_conf_write(uint32_t cf8, uint8_t offset, uint8_t bytes, uint32_t data);
 int pci_mmcfg_read(unsigned int seg, unsigned int bus,
-                   unsigned int devfn, int reg, int len, u32 *value);
+                   unsigned int devfn, int reg, int len, uint32_t *value);
 int pci_mmcfg_write(unsigned int seg, unsigned int bus,
-                    unsigned int devfn, int reg, int len, u32 value);
+                    unsigned int devfn, int reg, int len, uint32_t value);
 unsigned int pci_find_cap_offset(pci_sbdf_t sbdf, unsigned int cap);
 unsigned int pci_find_next_cap_ttl(pci_sbdf_t sbdf, unsigned int pos,
                                    const unsigned int caps[], unsigned int n,
Signature · 1 line
2.43.0
#1 lore raw
Quoted 5 lines · Frediano Ziglio

Just code style change.

---
 xen/include/xen/pci.h | 26 +++++++++++++-------------

I think if you change the types of the declarations in pci.h you should also change the types of the definitions in pci.c.

Thanks, Roger.

#2 lore raw
In reply to Frediano Ziglio
Quoted 6 lines · Frediano Ziglio

Just code style change.

---
 xen/include/xen/pci.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Aiui Eclair will object to declarations now (again?) going out of sync with definitions.

Quoted 16 lines
xen/include/xen/pci.h +2 -2
@@ -89,8 +89,8 @@ struct pci_dev_info {
     bool is_extfn;
     bool is_virtfn;
     struct {
-        u8 bus;
-        u8 devfn;
+        uint8_t bus;
+        uint8_t devfn;
     } physfn;
 };
 
@@ -209,26 +209,26 @@ static always_inline bool pcidevs_trylock(void)
 #define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) ((void)(d))
 #endif

xen/include/xen/pci.h static always_inline bool pcidevs_trylock(void) · line 216

Quoted 10 lines
xen/include/xen/pci.h +4 -4
 
-bool pci_known_segment(u16 seg);
-bool pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func);
+bool pci_known_segment(uint16_t seg);
+bool pci_device_detect(uint16_t seg, uint8_t bus, uint8_t dev, uint8_t func);
 int scan_pci_devices(void);
-enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn);
-int find_upstream_bridge(u16 seg, u8 *bus, u8 *devfn, u8 *secbus);
+enum pdev_type pdev_type(uint16_t seg, uint8_t bus, uint8_t devfn);
+int find_upstream_bridge(uint16_t seg, uint8_t *bus, uint8_t *devfn, uint8_t *secbus);

As you make style adjustments, please also obey to other aspects of style, like line length here.

Overall, while I don't mind the change, I'm not sure all of it is worthwhile. We're still only halfway through converting functions taking (s,b,d,f) tuples to take either struct pci_dev * or sbdf_t instead. Going straight to there where possible might be a more desirable approach.

Jan