diff mbox series

[v3,11/18] hw/isa: Simplify isa_address_space[_io]()

Message ID 20230302224058.43315-12-philmd@linaro.org
State New
Headers show
Series hw/ide: Untangle ISA/PCI abuses of ide_init_ioport() | expand

Commit Message

Philippe Mathieu-Daudé March 2, 2023, 10:40 p.m. UTC
We don't have any caller passing a NULL device argument,
so we can simplify, avoiding to access the global 'isabus'.

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

Comments

Mark Cave-Ayland April 26, 2023, 1:18 p.m. UTC | #1
On 02/03/2023 22:40, Philippe Mathieu-Daudé wrote:

> We don't have any caller passing a NULL device argument,
> so we can simplify, avoiding to access the global 'isabus'.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/isa/isa-bus.c | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
> index 9c8224afa5..3036341d3b 100644
> --- a/hw/isa/isa-bus.c
> +++ b/hw/isa/isa-bus.c
> @@ -252,20 +252,14 @@ static char *isabus_get_fw_dev_path(DeviceState *dev)
>   
>   MemoryRegion *isa_address_space(ISADevice *dev)
>   {
> -    if (dev) {
> -        return isa_bus_from_device(dev)->address_space;
> -    }
> -
> -    return isabus->address_space;
> +    assert(dev);
> +    return isa_bus_from_device(dev)->address_space;
>   }
>   
>   MemoryRegion *isa_address_space_io(ISADevice *dev)
>   {
> -    if (dev) {
> -        return isa_bus_from_device(dev)->address_space_io;
> -    }
> -
> -    return isabus->address_space_io;
> +    assert(dev);
> +    return isa_bus_from_device(dev)->address_space_io;
>   }
>   
>   type_init(isabus_register_types)

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


ATB,

Mark.
diff mbox series

Patch

diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index 9c8224afa5..3036341d3b 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -252,20 +252,14 @@  static char *isabus_get_fw_dev_path(DeviceState *dev)
 
 MemoryRegion *isa_address_space(ISADevice *dev)
 {
-    if (dev) {
-        return isa_bus_from_device(dev)->address_space;
-    }
-
-    return isabus->address_space;
+    assert(dev);
+    return isa_bus_from_device(dev)->address_space;
 }
 
 MemoryRegion *isa_address_space_io(ISADevice *dev)
 {
-    if (dev) {
-        return isa_bus_from_device(dev)->address_space_io;
-    }
-
-    return isabus->address_space_io;
+    assert(dev);
+    return isa_bus_from_device(dev)->address_space_io;
 }
 
 type_init(isabus_register_types)