From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Thomas Huth" <thuth@redhat.com>,
"Michael Tokarev" <mjt@tls.msk.ru>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Subject: [PATCH 1/3] hw/pci: Have various pci_bus*() methods take a const PCIBus argument
Date: Tue, 7 Jul 2026 10:40:48 +0200 [thread overview]
Message-ID: <20260707084050.32137-2-philmd@oss.qualcomm.com> (raw)
In-Reply-To: <20260707084050.32137-1-philmd@oss.qualcomm.com>
Mark the PCIBus pointer argument const when methods
don't need to update the structure referenced.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
include/hw/pci/pci.h | 10 +++++-----
include/hw/pci/pci_bus.h | 10 +++++-----
hw/pci-bridge/pci_expander_bridge.c | 4 ++--
hw/pci/pci.c | 18 +++++++++---------
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index f2448e941a0..f05d4d867b4 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -308,8 +308,8 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq,
void *irq_opaque, int nirq);
void pci_bus_map_irqs(PCIBus *bus, pci_map_irq_fn map_irq);
void pci_bus_irqs_cleanup(PCIBus *bus);
-int pci_bus_get_irq_level(PCIBus *bus, int irq_num);
-uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus);
+int pci_bus_get_irq_level(const PCIBus *bus, int irq_num);
+uint32_t pci_bus_get_slot_reserved_mask(const PCIBus *bus);
void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask);
void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask);
bool pci_bus_add_fw_cfg_extra_pci_roots(FWCfgState *fw_cfg,
@@ -345,14 +345,14 @@ static inline PCIBus *pci_get_bus(const PCIDevice *dev)
{
return PCI_BUS(qdev_get_parent_bus(DEVICE(dev)));
}
-int pci_bus_num(PCIBus *s);
-void pci_bus_range(PCIBus *bus, int *min_bus, int *max_bus);
+int pci_bus_num(const PCIBus *s);
+void pci_bus_range(const PCIBus *bus, int *min_bus, int *max_bus);
static inline int pci_dev_bus_num(const PCIDevice *dev)
{
return pci_bus_num(pci_get_bus(dev));
}
-int pci_bus_numa_node(PCIBus *bus);
+int pci_bus_numa_node(const PCIBus *bus);
void pci_for_each_device(PCIBus *bus, int bus_num,
pci_bus_dev_fn fn,
void *opaque);
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index c7384467888..7a3f2e4dde9 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -15,8 +15,8 @@ struct PCIBusClass {
BusClass parent_class;
/*< public >*/
- int (*bus_num)(PCIBus *bus);
- uint16_t (*numa_node)(PCIBus *bus);
+ int (*bus_num)(const PCIBus *bus);
+ uint16_t (*numa_node)(const PCIBus *bus);
};
enum PCIBusFlags {
@@ -58,17 +58,17 @@ struct PCIBus {
Notifier machine_done;
};
-static inline bool pci_bus_is_cxl(PCIBus *bus)
+static inline bool pci_bus_is_cxl(const PCIBus *bus)
{
return !!(bus->flags & PCI_BUS_CXL);
}
-static inline bool pci_bus_is_root(PCIBus *bus)
+static inline bool pci_bus_is_root(const PCIBus *bus)
{
return !!(bus->flags & PCI_BUS_IS_ROOT);
}
-static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
+static inline bool pci_bus_allows_extended_config_space(const PCIBus *bus)
{
return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
}
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index 40ffbc4e082..f981c47edee 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -68,14 +68,14 @@ bool cxl_get_hb_passthrough(PCIHostState *hb)
return host->passthrough;
}
-static int pxb_bus_num(PCIBus *bus)
+static int pxb_bus_num(const PCIBus *bus)
{
PXBDev *pxb = PXB_DEV(bus->parent_dev);
return pxb->bus_nr;
}
-static uint16_t pxb_bus_numa_node(PCIBus *bus)
+static uint16_t pxb_bus_numa_node(const PCIBus *bus)
{
PXBDev *pxb = PXB_DEV(bus->parent_dev);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index d3191609e28..b04e94a150b 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -225,7 +225,7 @@ static void pci_bus_unrealize(BusState *qbus)
vmstate_unregister(NULL, &vmstate_pcibus, bus);
}
-static int pcibus_num(PCIBus *bus)
+static int pcibus_num(const PCIBus *bus)
{
if (pci_bus_is_root(bus)) {
return 0; /* pci host bridge */
@@ -233,7 +233,7 @@ static int pcibus_num(PCIBus *bus)
return bus->parent_dev->config[PCI_SECONDARY_BUS];
}
-static uint16_t pcibus_numa_node(PCIBus *bus)
+static uint16_t pcibus_numa_node(const PCIBus *bus)
{
return NUMA_NODE_UNASSIGNED;
}
@@ -411,7 +411,7 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
pci_bus_change_irq_level(bus, irq_num, change);
}
-int pci_bus_get_irq_level(PCIBus *bus, int irq_num)
+int pci_bus_get_irq_level(const PCIBus *bus, int irq_num)
{
assert(irq_num >= 0);
assert(irq_num < bus->nirq);
@@ -781,13 +781,13 @@ void pci_unregister_root_bus(PCIBus *bus)
pci_root_bus_cleanup(bus);
}
-int pci_bus_num(PCIBus *s)
+int pci_bus_num(const PCIBus *s)
{
return PCI_BUS_GET_CLASS(s)->bus_num(s);
}
/* Returns the min and max bus numbers of a PCI bus hierarchy */
-void pci_bus_range(PCIBus *bus, int *min_bus, int *max_bus)
+void pci_bus_range(const PCIBus *bus, int *min_bus, int *max_bus)
{
int i;
*min_bus = *max_bus = pci_bus_num(bus);
@@ -802,7 +802,7 @@ void pci_bus_range(PCIBus *bus, int *min_bus, int *max_bus)
}
}
-int pci_bus_numa_node(PCIBus *bus)
+int pci_bus_numa_node(const PCIBus *bus)
{
return PCI_BUS_GET_CLASS(bus)->numa_node(bus);
}
@@ -1304,17 +1304,17 @@ uint16_t pci_requester_id(PCIDevice *dev)
return pci_req_id_cache_extract(&dev->requester_id_cache);
}
-static bool pci_bus_devfn_available(PCIBus *bus, int devfn)
+static bool pci_bus_devfn_available(const PCIBus *bus, int devfn)
{
return !(bus->devices[devfn]);
}
-static bool pci_bus_devfn_reserved(PCIBus *bus, int devfn)
+static bool pci_bus_devfn_reserved(const PCIBus *bus, int devfn)
{
return bus->slot_reserved_mask & (1UL << PCI_SLOT(devfn));
}
-uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus)
+uint32_t pci_bus_get_slot_reserved_mask(const PCIBus *bus)
{
return bus->slot_reserved_mask;
}
--
2.53.0
next prev parent reply other threads:[~2026-07-07 8:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 8:40 [PATCH 0/3] hw/pci: Consider reserved slots mask when checking PCI bus is full Philippe Mathieu-Daudé
2026-07-07 8:40 ` Philippe Mathieu-Daudé [this message]
2026-07-07 9:11 ` [PATCH 1/3] hw/pci: Have various pci_bus*() methods take a const PCIBus argument Thomas Huth
2026-07-07 8:40 ` [PATCH 2/3] hw/qdev: Introduce BusClass::is_full() handler Philippe Mathieu-Daudé
2026-07-07 8:40 ` [PATCH 3/3] hw/pci: Consider reserved slots mask when checking PCI bus is full Philippe Mathieu-Daudé
2026-07-07 10:20 ` Michael S. Tsirkin
2026-07-07 12:53 ` Philippe Mathieu-Daudé
2026-07-07 13:43 ` Michael S. Tsirkin
2026-07-07 22:05 ` [PATCH 0/3] " Mark Cave-Ayland
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=20260707084050.32137-2-philmd@oss.qualcomm.com \
--to=philmd@oss.qualcomm.com \
--cc=atar4qemu@gmail.com \
--cc=berrange@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mjt@tls.msk.ru \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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.