diff mbox

[v2,1/5] pci: reorganize QEMU_PCI_CAP_*

Message ID d98d6fe4271d4b4e690b220e9a5989f0d10bd191.1415177705.git.hutao@cn.fujitsu.com
State New
Headers show

Commit Message

Hu Tao Nov. 5, 2014, 9:02 a.m. UTC
This makes code more readable.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 include/hw/pci/pci.h | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

Comments

Marcel Apfelbaum Nov. 5, 2014, 5:12 p.m. UTC | #1
On Wed, 2014-11-05 at 17:02 +0800, Hu Tao wrote:
> This makes code more readable.
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  include/hw/pci/pci.h | 39 ++++++++++++++++++++-------------------
>  1 file changed, 20 insertions(+), 19 deletions(-)
> 
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index c352c7b..b18759a 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -142,25 +142,26 @@ enum {
>  
>  /* Bits in cap_present field. */
>  enum {
> -    QEMU_PCI_CAP_MSI = 0x1,
> -    QEMU_PCI_CAP_MSIX = 0x2,
> -    QEMU_PCI_CAP_EXPRESS = 0x4,
> -
> -    /* multifunction capable device */
> -#define QEMU_PCI_CAP_MULTIFUNCTION_BITNR        3
> -    QEMU_PCI_CAP_MULTIFUNCTION = (1 << QEMU_PCI_CAP_MULTIFUNCTION_BITNR),
> -
> -    /* command register SERR bit enabled */
> -#define QEMU_PCI_CAP_SERR_BITNR 4
> -    QEMU_PCI_CAP_SERR = (1 << QEMU_PCI_CAP_SERR_BITNR),
> -    /* Standard hot plug controller. */
> -#define QEMU_PCI_SHPC_BITNR 5
> -    QEMU_PCI_CAP_SHPC = (1 << QEMU_PCI_SHPC_BITNR),
> -#define QEMU_PCI_SLOTID_BITNR 6
> -    QEMU_PCI_CAP_SLOTID = (1 << QEMU_PCI_SLOTID_BITNR),
> -    /* PCI Express capability - Power Controller Present */
> -#define QEMU_PCIE_SLTCAP_PCP_BITNR 7
> -    QEMU_PCIE_SLTCAP_PCP = (1 << QEMU_PCIE_SLTCAP_PCP_BITNR),
> +    QEMU_PCI_CAP_MSI_BITNR = 0,
> +    QEMU_PCI_CAP_MSIX_BITNR,
> +    QEMU_PCI_CAP_EXPRESS_BITNR,
> +    QEMU_PCI_CAP_MULTIFUNCTION_BITNR, /* multifunction capable device */
> +    QEMU_PCI_CAP_SERR_BITNR,          /* command register SERR bit enabled */
> +    QEMU_PCI_SHPC_BITNR,              /* Standard hot plug controller */
> +    QEMU_PCI_SLOTID_BITNR,
> +    QEMU_PCIE_SLTCAP_PCP_BITNR, /* PCI Express capability - Power Controller
> +                                   Present */
> +};
> +
> +enum {
> +    QEMU_PCI_CAP_MSI            = (1 << QEMU_PCI_CAP_MSI_BITNR),
> +    QEMU_PCI_CAP_MSIX           = (1 << QEMU_PCI_CAP_MSIX_BITNR),
> +    QEMU_PCI_CAP_EXPRESS        = (1 << QEMU_PCI_CAP_EXPRESS_BITNR),
> +    QEMU_PCI_CAP_MULTIFUNCTION  = (1 << QEMU_PCI_CAP_MULTIFUNCTION_BITNR),
> +    QEMU_PCI_CAP_SERR           = (1 << QEMU_PCI_CAP_SERR_BITNR),
> +    QEMU_PCI_CAP_SHPC           = (1 << QEMU_PCI_SHPC_BITNR),
> +    QEMU_PCI_CAP_SLOTID         = (1 << QEMU_PCI_SLOTID_BITNR),
> +    QEMU_PCIE_SLTCAP_PCP        = (1 << QEMU_PCIE_SLTCAP_PCP_BITNR),
>  };
>  
>  #define TYPE_PCI_DEVICE "pci-device"

Definitely more readable.

Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
diff mbox

Patch

diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index c352c7b..b18759a 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -142,25 +142,26 @@  enum {
 
 /* Bits in cap_present field. */
 enum {
-    QEMU_PCI_CAP_MSI = 0x1,
-    QEMU_PCI_CAP_MSIX = 0x2,
-    QEMU_PCI_CAP_EXPRESS = 0x4,
-
-    /* multifunction capable device */
-#define QEMU_PCI_CAP_MULTIFUNCTION_BITNR        3
-    QEMU_PCI_CAP_MULTIFUNCTION = (1 << QEMU_PCI_CAP_MULTIFUNCTION_BITNR),
-
-    /* command register SERR bit enabled */
-#define QEMU_PCI_CAP_SERR_BITNR 4
-    QEMU_PCI_CAP_SERR = (1 << QEMU_PCI_CAP_SERR_BITNR),
-    /* Standard hot plug controller. */
-#define QEMU_PCI_SHPC_BITNR 5
-    QEMU_PCI_CAP_SHPC = (1 << QEMU_PCI_SHPC_BITNR),
-#define QEMU_PCI_SLOTID_BITNR 6
-    QEMU_PCI_CAP_SLOTID = (1 << QEMU_PCI_SLOTID_BITNR),
-    /* PCI Express capability - Power Controller Present */
-#define QEMU_PCIE_SLTCAP_PCP_BITNR 7
-    QEMU_PCIE_SLTCAP_PCP = (1 << QEMU_PCIE_SLTCAP_PCP_BITNR),
+    QEMU_PCI_CAP_MSI_BITNR = 0,
+    QEMU_PCI_CAP_MSIX_BITNR,
+    QEMU_PCI_CAP_EXPRESS_BITNR,
+    QEMU_PCI_CAP_MULTIFUNCTION_BITNR, /* multifunction capable device */
+    QEMU_PCI_CAP_SERR_BITNR,          /* command register SERR bit enabled */
+    QEMU_PCI_SHPC_BITNR,              /* Standard hot plug controller */
+    QEMU_PCI_SLOTID_BITNR,
+    QEMU_PCIE_SLTCAP_PCP_BITNR, /* PCI Express capability - Power Controller
+                                   Present */
+};
+
+enum {
+    QEMU_PCI_CAP_MSI            = (1 << QEMU_PCI_CAP_MSI_BITNR),
+    QEMU_PCI_CAP_MSIX           = (1 << QEMU_PCI_CAP_MSIX_BITNR),
+    QEMU_PCI_CAP_EXPRESS        = (1 << QEMU_PCI_CAP_EXPRESS_BITNR),
+    QEMU_PCI_CAP_MULTIFUNCTION  = (1 << QEMU_PCI_CAP_MULTIFUNCTION_BITNR),
+    QEMU_PCI_CAP_SERR           = (1 << QEMU_PCI_CAP_SERR_BITNR),
+    QEMU_PCI_CAP_SHPC           = (1 << QEMU_PCI_SHPC_BITNR),
+    QEMU_PCI_CAP_SLOTID         = (1 << QEMU_PCI_SLOTID_BITNR),
+    QEMU_PCIE_SLTCAP_PCP        = (1 << QEMU_PCIE_SLTCAP_PCP_BITNR),
 };
 
 #define TYPE_PCI_DEVICE "pci-device"