[Qemu-devel] [PATCH v2 4/4] pci: msix: move 'MSIX_CAP_LENGTH' to header file

Li Qiang posted 4 patches 6 years, 5 months ago
Maintainers: Eric Farman <farman@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Cornelia Huck <cohuck@redhat.com>, Christian Borntraeger <borntraeger@de.ibm.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Alex Williamson <alex.williamson@redhat.com>, Pierre Morel <pmorel@linux.ibm.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Farhan Ali <alifm@linux.ibm.com>, "Michael S. Tsirkin" <mst@redhat.com>
[Qemu-devel] [PATCH v2 4/4] pci: msix: move 'MSIX_CAP_LENGTH' to header file
Posted by Li Qiang 6 years, 5 months ago
'MSIX_CAP_LENGTH' is defined in two .c file. Move it
to hw/pci/msix.h file to reduce duplicated code.

CC: qemu-trivial@nongnu.org
Signed-off-by: Li Qiang <liq3ea@163.com>
---
 hw/pci/msix.c         | 2 --
 hw/vfio/pci.c         | 2 --
 include/hw/pci/msix.h | 2 ++
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index 4e336416a7..d39dcf32e8 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -24,8 +24,6 @@
 #include "qapi/error.h"
 #include "trace.h"
 
-#define MSIX_CAP_LENGTH 12
-
 /* MSI enable bit and maskall bit are in byte 1 in FLAGS register */
 #define MSIX_CONTROL_OFFSET (PCI_MSIX_FLAGS + 1)
 #define MSIX_ENABLE_MASK (PCI_MSIX_FLAGS_ENABLE >> 8)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 08729e5875..8e555db12e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -35,8 +35,6 @@
 #include "trace.h"
 #include "qapi/error.h"
 
-#define MSIX_CAP_LENGTH 12
-
 #define TYPE_VFIO_PCI "vfio-pci"
 #define PCI_VFIO(obj)    OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI)
 
diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h
index 1f27658d35..08acfa836e 100644
--- a/include/hw/pci/msix.h
+++ b/include/hw/pci/msix.h
@@ -4,6 +4,8 @@
 #include "qemu-common.h"
 #include "hw/pci/pci.h"
 
+#define MSIX_CAP_LENGTH 12
+
 void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
 MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector);
 int msix_init(PCIDevice *dev, unsigned short nentries,
-- 
2.17.1



Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 4/4] pci: msix: move 'MSIX_CAP_LENGTH' to header file
Posted by Laurent Vivier 6 years, 5 months ago
On 21/05/2019 17:15, Li Qiang wrote:
> 'MSIX_CAP_LENGTH' is defined in two .c file. Move it
> to hw/pci/msix.h file to reduce duplicated code.
> 
> CC: qemu-trivial@nongnu.org
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>   hw/pci/msix.c         | 2 --
>   hw/vfio/pci.c         | 2 --
>   include/hw/pci/msix.h | 2 ++
>   3 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/pci/msix.c b/hw/pci/msix.c
> index 4e336416a7..d39dcf32e8 100644
> --- a/hw/pci/msix.c
> +++ b/hw/pci/msix.c
> @@ -24,8 +24,6 @@
>   #include "qapi/error.h"
>   #include "trace.h"
>   
> -#define MSIX_CAP_LENGTH 12
> -
>   /* MSI enable bit and maskall bit are in byte 1 in FLAGS register */
>   #define MSIX_CONTROL_OFFSET (PCI_MSIX_FLAGS + 1)
>   #define MSIX_ENABLE_MASK (PCI_MSIX_FLAGS_ENABLE >> 8)
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 08729e5875..8e555db12e 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -35,8 +35,6 @@
>   #include "trace.h"
>   #include "qapi/error.h"
>   
> -#define MSIX_CAP_LENGTH 12
> -
>   #define TYPE_VFIO_PCI "vfio-pci"
>   #define PCI_VFIO(obj)    OBJECT_CHECK(VFIOPCIDevice, obj, TYPE_VFIO_PCI)
>   
> diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h
> index 1f27658d35..08acfa836e 100644
> --- a/include/hw/pci/msix.h
> +++ b/include/hw/pci/msix.h
> @@ -4,6 +4,8 @@
>   #include "qemu-common.h"
>   #include "hw/pci/pci.h"
>   
> +#define MSIX_CAP_LENGTH 12
> +
>   void msix_set_message(PCIDevice *dev, int vector, MSIMessage msg);
>   MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector);
>   int msix_init(PCIDevice *dev, unsigned short nentries,
> 

Applied to my trivial-patches branch.

Thanks,
Laurent