All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel@redhat.com>
To: qemu-devel@nongnu.org
Cc: marcel@redhat.com, pbonzini@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH V7 10/24] hw/pci: made pci_bus_num a PCIBusClass method
Date: Mon, 25 May 2015 18:33:48 +0300	[thread overview]
Message-ID: <1432568042-19553-11-git-send-email-marcel@redhat.com> (raw)
In-Reply-To: <1432568042-19553-1-git-send-email-marcel@redhat.com>

From: Marcel Apfelbaum <marcel.a@redhat.com>

Refactoring it as a method of PCIBusClass will allow
different implementations for subclasses.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
---
 hw/pci/pci.c             | 13 ++++++++++---
 include/hw/pci/pci_bus.h |  1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 132d19e..2f24f74 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -93,6 +93,14 @@ static bool pcibus_is_root(PCIBus *bus)
     return !bus->parent_dev;
 }
 
+static int pcibus_num(PCIBus *bus)
+{
+    if (pcibus_is_root(bus)) {
+        return 0; /* pci host bridge */
+    }
+    return bus->parent_dev->config[PCI_SECONDARY_BUS];
+}
+
 static void pci_bus_class_init(ObjectClass *klass, void *data)
 {
     BusClass *k = BUS_CLASS(klass);
@@ -106,6 +114,7 @@ static void pci_bus_class_init(ObjectClass *klass, void *data)
     k->reset = pcibus_reset;
 
     pbc->is_root = pcibus_is_root;
+    pbc->bus_num = pcibus_num;
 }
 
 static const TypeInfo pci_bus_info = {
@@ -390,9 +399,7 @@ PCIBus *pci_register_bus(DeviceState *parent, const char *name,
 
 int pci_bus_num(PCIBus *s)
 {
-    if (pci_bus_is_root(s))
-        return 0;       /* pci host bridge */
-    return s->parent_dev->config[PCI_SECONDARY_BUS];
+    return PCI_BUS_GET_CLASS(s)->bus_num(s);
 }
 
 static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index b5ba9c4..7b9939e 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -14,6 +14,7 @@ typedef struct PCIBusClass {
     /*< public >*/
 
     bool (*is_root)(PCIBus *bus);
+    int (*bus_num)(PCIBus *bus);
 } PCIBusClass;
 
 struct PCIBus {
-- 
2.1.0

  parent reply	other threads:[~2015-05-25 15:34 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25 15:33 [Qemu-devel] [PATCH V7 00/24] hw/pc: implement multiple primary busses for pc machines Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 01/24] acpi: add aml_or() term Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 02/24] acpi: add aml_add() term Marcel Apfelbaum
2015-05-26  6:09   ` Shannon Zhao
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 03/24] acpi: add aml_lless() term Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 04/24] acpi: add aml_index() term Marcel Apfelbaum
2015-05-26  6:12   ` Shannon Zhao
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 05/24] acpi: add aml_shiftleft() term Marcel Apfelbaum
2015-05-26  6:15   ` Shannon Zhao
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 06/24] acpi: add aml_shiftright() term Marcel Apfelbaum
2015-05-26  6:16   ` Shannon Zhao
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 07/24] acpi: add aml_increment() term Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 08/24] acpi: add aml_while() term Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 09/24] hw/pci: made pci_bus_is_root a PCIBusClass method Marcel Apfelbaum
2015-05-25 15:33 ` Marcel Apfelbaum [this message]
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 11/24] hw/i386: query only for q35/pc when looking for pci host bridge Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 12/24] hw/pci: extend PCI config access to support devices behind PXB Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 13/24] hw/acpi: add support for i440fx 'snooping' root busses Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 14/24] hw/apci: add _PRT method for extra PCI " Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 15/24] hw/acpi: add _CRS method for extra " Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 16/24] hw/acpi: remove from root bus 0 the crs resources used by other buses Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 17/24] hw/pci: removed 'rootbus nr is 0' assumption from qmp_pci_query Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 18/24] hw/pci: introduce PCI Expander Bridge (PXB) Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 19/24] hw/pci: inform bios if the system has extra pci root buses Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 20/24] hw/pxb: add map_irq func Marcel Apfelbaum
2015-05-25 15:33 ` [Qemu-devel] [PATCH V7 21/24] hw/pci: add support for NUMA nodes Marcel Apfelbaum
2015-05-25 15:34 ` [Qemu-devel] [PATCH V7 22/24] hw/pxb: add numa_node parameter Marcel Apfelbaum
2015-05-25 15:34 ` [Qemu-devel] [PATCH V7 23/24] apci: fix PXB behaviour if used with unsupported BIOS Marcel Apfelbaum
2015-05-31 18:12   ` Michael S. Tsirkin
2015-06-01  9:44     ` Marcel Apfelbaum
2015-06-01 11:40       ` Gerd Hoffmann
2015-06-01 12:17         ` Michael S. Tsirkin
2015-06-01 12:21           ` Marcel Apfelbaum
2015-06-01 12:27             ` Michael S. Tsirkin
2015-06-01 13:05               ` Marcel Apfelbaum
2015-06-01 13:28                 ` Laszlo Ersek
2015-06-01 13:48                   ` Marcel Apfelbaum
2015-06-01 15:37                     ` Laszlo Ersek
2015-06-02 11:37                       ` Marcel Apfelbaum
2015-06-02 15:24                         ` Laszlo Ersek
2015-06-02 15:51                           ` Marcel Apfelbaum
2015-06-01 12:24           ` Gerd Hoffmann
2015-06-01 12:27             ` Michael S. Tsirkin
2015-06-01 12:57               ` Gerd Hoffmann
2015-06-01 13:26                 ` Michael S. Tsirkin
2015-05-25 15:34 ` [Qemu-devel] [PATCH V7 24/24] docs: Add PXB documentation Marcel Apfelbaum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432568042-19553-11-git-send-email-marcel@redhat.com \
    --to=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.