[Qemu-devel] [RFC v2 1/6] pci: Inline pci_host_bus_register() inside pci_bus_init()

Eduardo Habkost posted 6 patches 8 years, 9 months ago
[Qemu-devel] [RFC v2 1/6] pci: Inline pci_host_bus_register() inside pci_bus_init()
Posted by Eduardo Habkost 8 years, 9 months ago
There's no need for a separate function just to append an item to
pci_host_bridges.

Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/pci/pci.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 259483b1c0..328f36cd21 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -312,13 +312,6 @@ static void pcibus_reset(BusState *qbus)
     }
 }
 
-static void pci_host_bus_register(DeviceState *host)
-{
-    PCIHostState *host_bridge = PCI_HOST_BRIDGE(host);
-
-    QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next);
-}
-
 PCIBus *pci_find_primary_bus(void)
 {
     PCIBus *primary_bus = NULL;
@@ -369,6 +362,8 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
                          MemoryRegion *address_space_io,
                          uint8_t devfn_min)
 {
+    PCIHostState *phb = PCI_HOST_BRIDGE(parent);
+
     assert(PCI_FUNC(devfn_min) == 0);
     bus->devfn_min = devfn_min;
     bus->address_space_mem = address_space_mem;
@@ -377,7 +372,7 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
     /* host bridge */
     QLIST_INIT(&bus->child);
 
-    pci_host_bus_register(parent);
+    QLIST_INSERT_HEAD(&pci_host_bridges, phb, next);
 }
 
 bool pci_bus_is_express(PCIBus *bus)
-- 
2.11.0.259.g40922b1


Re: [Qemu-devel] [RFC v2 1/6] pci: Inline pci_host_bus_register() inside pci_bus_init()
Posted by David Gibson 8 years, 9 months ago
On Tue, Apr 18, 2017 at 07:17:19PM -0300, Eduardo Habkost wrote:
1;4601;0c> There's no need for a separate function just to append an item to
> pci_host_bridges.
> 
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Marcel Apfelbaum <marcel@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

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

> ---
>  hw/pci/pci.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 259483b1c0..328f36cd21 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -312,13 +312,6 @@ static void pcibus_reset(BusState *qbus)
>      }
>  }
>  
> -static void pci_host_bus_register(DeviceState *host)
> -{
> -    PCIHostState *host_bridge = PCI_HOST_BRIDGE(host);
> -
> -    QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next);
> -}
> -
>  PCIBus *pci_find_primary_bus(void)
>  {
>      PCIBus *primary_bus = NULL;
> @@ -369,6 +362,8 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
>                           MemoryRegion *address_space_io,
>                           uint8_t devfn_min)
>  {
> +    PCIHostState *phb = PCI_HOST_BRIDGE(parent);
> +
>      assert(PCI_FUNC(devfn_min) == 0);
>      bus->devfn_min = devfn_min;
>      bus->address_space_mem = address_space_mem;
> @@ -377,7 +372,7 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
>      /* host bridge */
>      QLIST_INIT(&bus->child);
>  
> -    pci_host_bus_register(parent);
> +    QLIST_INSERT_HEAD(&pci_host_bridges, phb, next);
>  }
>  
>  bool pci_bus_is_express(PCIBus *bus)

-- 
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
Re: [Qemu-devel] [RFC v2 1/6] pci: Inline pci_host_bus_register() inside pci_bus_init()
Posted by Marcel Apfelbaum 8 years, 9 months ago
On 04/19/2017 01:17 AM, Eduardo Habkost wrote:
> There's no need for a separate function just to append an item to
> pci_host_bridges.
>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Marcel Apfelbaum <marcel@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/pci/pci.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 259483b1c0..328f36cd21 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -312,13 +312,6 @@ static void pcibus_reset(BusState *qbus)
>      }
>  }
>
> -static void pci_host_bus_register(DeviceState *host)
> -{
> -    PCIHostState *host_bridge = PCI_HOST_BRIDGE(host);
> -
> -    QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next);
> -}
> -
>  PCIBus *pci_find_primary_bus(void)
>  {
>      PCIBus *primary_bus = NULL;
> @@ -369,6 +362,8 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
>                           MemoryRegion *address_space_io,
>                           uint8_t devfn_min)
>  {
> +    PCIHostState *phb = PCI_HOST_BRIDGE(parent);
> +
>      assert(PCI_FUNC(devfn_min) == 0);
>      bus->devfn_min = devfn_min;
>      bus->address_space_mem = address_space_mem;
> @@ -377,7 +372,7 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
>      /* host bridge */
>      QLIST_INIT(&bus->child);
>
> -    pci_host_bus_register(parent);
> +    QLIST_INSERT_HEAD(&pci_host_bridges, phb, next);
>  }
>
>  bool pci_bus_is_express(PCIBus *bus)
>


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

Thanks,
Marcel