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

Frediano Ziglio posted 1 patch 4 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20250613101249.164199-1-frediano.ziglio@cloud.com
xen/include/xen/pci.h | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
[PATCH] x86/pci: Use C99 style types for fixed integrals
Posted by Frediano Ziglio 4 months, 2 weeks ago
Just code style change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
---
 xen/include/xen/pci.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index ef60196653..f22bbc2776 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -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,
-- 
2.43.0
Re: [PATCH] x86/pci: Use C99 style types for fixed integrals
Posted by Jan Beulich 4 months, 2 weeks ago
On 13.06.2025 12:12, Frediano Ziglio wrote:
> Just code style change.
> 
> Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
> ---
>  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.

> --- a/xen/include/xen/pci.h
> +++ b/xen/include/xen/pci.h
> @@ -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);

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
Re: [PATCH] x86/pci: Use C99 style types for fixed integrals
Posted by Roger Pau Monné 4 months, 2 weeks ago
On Fri, Jun 13, 2025 at 11:12:47AM +0100, Frediano Ziglio wrote:
> Just code style change.
> 
> Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
> ---
>  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.