diff mbox series

[RFC,11/11] hw/isa: Rename isabus singleton as 'g_isabus'

Message ID 20210518215545.1793947-12-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series hw/isa: Remove dependencies on ISA bus singleton | expand

Commit Message

Philippe Mathieu-Daudé May 18, 2021, 9:55 p.m. UTC
To make explicit the isabus singleton isn't used anywhere else,
move it's static declaration locally to isa_bus_new() and rename
it as 'g_isabus'.

Unfortunately we provide the get_system_io() call which expose
an unique I/O bus to a machine, and the ISA bus rely on this I/O
bus, so we can not remove the ISA bus singleton until we remove
the get_system_io() API.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/isa/isa-bus.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Stefan Hajnoczi May 19, 2021, 4:18 p.m. UTC | #1
On Tue, May 18, 2021 at 11:55:45PM +0200, Philippe Mathieu-Daudé wrote:
> @@ -55,7 +53,10 @@ static const TypeInfo isa_bus_info = {
>  ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space,
>                      MemoryRegion *address_space_io, Error **errp)
>  {
> -    if (isabus) {
> +    static ISABus *g_isabus;

QEMU doesn't use Hungarian notation, g_isabus isn't a global variable so
the prefix is confusing, and g_ conflicts with GLib's namespace so the
rename is odd. I suggest keeping the name unchanged and making the
commit message "remove the global isabus variable".
diff mbox series

Patch

diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index a19e3688c28..422eb9615f4 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -26,8 +26,6 @@ 
 #include "sysemu/sysemu.h"
 #include "hw/isa/isa.h"
 
-static ISABus *isabus;
-
 static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent);
 static char *isabus_get_fw_dev_path(DeviceState *dev);
 
@@ -55,7 +53,10 @@  static const TypeInfo isa_bus_info = {
 ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space,
                     MemoryRegion *address_space_io, Error **errp)
 {
-    if (isabus) {
+    static ISABus *g_isabus;
+    ISABus *isabus;
+
+    if (g_isabus) {
         error_setg(errp, "Can't create a second ISA bus");
         return NULL;
     }
@@ -67,6 +68,7 @@  ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space,
     isabus = ISA_BUS(qbus_create(TYPE_ISA_BUS, dev, NULL));
     isabus->address_space = address_space;
     isabus->address_space_io = address_space_io;
+    g_isabus = isabus;
     return isabus;
 }