diff mbox series

[5/5] hw: Use the PCI_DEVFN() macro from 'hw/pci/pci.h'

Message ID 20201012124506.3406909-6-philmd@redhat.com
State New
Headers show
Series hw: Use PCI macros from 'hw/pci/pci.h' | expand

Commit Message

Philippe Mathieu-Daudé Oct. 12, 2020, 12:45 p.m. UTC
From: Philippe Mathieu-Daudé <f4bug@amsat.org>

We already have a generic PCI_DEVFN() macro in "hw/pci/pci.h"
to pack the PCI slot/function identifiers, use it.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/virt.c          | 3 ++-
 hw/pci-host/uninorth.c | 6 ++----
 2 files changed, 4 insertions(+), 5 deletions(-)

Comments

David Gibson Oct. 13, 2020, 12:45 a.m. UTC | #1
On Mon, Oct 12, 2020 at 02:45:06PM +0200, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>

> 

> We already have a generic PCI_DEVFN() macro in "hw/pci/pci.h"

> to pack the PCI slot/function identifiers, use it.

> 

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


ppc part

Acked-by: David Gibson <david@gibson.dropbear.id.au>


> ---

>  hw/arm/virt.c          | 3 ++-

>  hw/pci-host/uninorth.c | 6 ++----

>  2 files changed, 4 insertions(+), 5 deletions(-)

> 

> diff --git a/hw/arm/virt.c b/hw/arm/virt.c

> index e465a988d68..f601ef0798c 100644

> --- a/hw/arm/virt.c

> +++ b/hw/arm/virt.c

> @@ -1144,7 +1144,8 @@ static void create_pcie_irq_map(const VirtMachineState *vms,

>                       full_irq_map, sizeof(full_irq_map));

>  

>      qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupt-map-mask",

> -                           0x1800, 0, 0, /* devfn (PCI_SLOT(3)) */

> +                           cpu_to_be16(PCI_DEVFN(3, 0)), /* Slot 3 */

> +                           0, 0,

>                             0x7           /* PCI irq */);

>  }

>  

> diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c

> index c21de0ab805..f73d452bdce 100644

> --- a/hw/pci-host/uninorth.c

> +++ b/hw/pci-host/uninorth.c

> @@ -70,10 +70,8 @@ static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)

>          /* ... and then convert them to x86 format */

>          /* config pointer */

>          retval = (reg & (0xff - 7)) | (addr & 7);

> -        /* slot */

> -        retval |= slot << 11;

> -        /* fn */

> -        retval |= func << 8;

> +        /* slot, fn */

> +        retval |= PCI_DEVFN(slot, func) << 8;

>      }

>  

>      trace_unin_get_config_reg(reg, addr, retval);


-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index e465a988d68..f601ef0798c 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1144,7 +1144,8 @@  static void create_pcie_irq_map(const VirtMachineState *vms,
                      full_irq_map, sizeof(full_irq_map));
 
     qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupt-map-mask",
-                           0x1800, 0, 0, /* devfn (PCI_SLOT(3)) */
+                           cpu_to_be16(PCI_DEVFN(3, 0)), /* Slot 3 */
+                           0, 0,
                            0x7           /* PCI irq */);
 }
 
diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c
index c21de0ab805..f73d452bdce 100644
--- a/hw/pci-host/uninorth.c
+++ b/hw/pci-host/uninorth.c
@@ -70,10 +70,8 @@  static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
         /* ... and then convert them to x86 format */
         /* config pointer */
         retval = (reg & (0xff - 7)) | (addr & 7);
-        /* slot */
-        retval |= slot << 11;
-        /* fn */
-        retval |= func << 8;
+        /* slot, fn */
+        retval |= PCI_DEVFN(slot, func) << 8;
     }
 
     trace_unin_get_config_reg(reg, addr, retval);