[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 12/18] hw/isa: Reduce 'isabus' singleton scope to isa_bus_

From: Mark Cave-Ayland
Subject: Re: [PATCH v3 12/18] hw/isa: Reduce 'isabus' singleton scope to isa_bus_new()
Date: Wed, 26 Apr 2023 14:19:15 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

On 02/03/2023 22:40, Philippe Mathieu-Daudé wrote:

Previous commit ensured when entering isa_register_portio_list(),
'dev' is not NULL. Being a TYPE_ISA_DEVICE, the device must sit
on a ISA bus. This means isa_bus_new() as already been called
and 'isabus' can not be NULL.

Simplify by removing the 'isabus' NULL check in
isa_register_portio_list(). 'isabus' is now only used in
isa_bus_new(). Reduce its scope by only declaring it the
function using it (this will allows us to create multiple
ISA buses later).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
  hw/isa/isa-bus.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index 3036341d3b..8e3ca3785e 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -25,8 +25,6 @@
  #include "sysemu/sysemu.h"
  #include "hw/isa/isa.h"
-static ISABus *isabus;
  static char *isabus_get_fw_dev_path(DeviceState *dev);
static void isa_bus_class_init(ObjectClass *klass, void *data)
@@ -52,6 +50,8 @@ static const TypeInfo isa_bus_info = {
  ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space,
                      MemoryRegion *address_space_io, Error **errp)
+    static ISABus *isabus;
      if (isabus) {
          error_setg(errp, "Can't create a second ISA bus");
          return NULL;
@@ -132,10 +132,6 @@ int isa_register_portio_list(ISADevice *dev,
      assert(piolist && !piolist->owner);
- if (!isabus) {
-        return -ENODEV;
-    }
      /* START is how we should treat DEV, regardless of the actual
         contents of the portio array.  This is how the old code
         actually handled e.g. the FDC device.  */

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]