diff mbox series

[1/2] hw/isa: add function to check for existence of device by its type

Message ID 20220220192549.591703-2-liavalb@gmail.com
State New
Headers show
Series hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table | expand

Commit Message

Liav Albani Feb. 20, 2022, 7:25 p.m. UTC
Signed-off-by: Liav Albani <liavalb@gmail.com>
---
 hw/isa/isa-bus.c     | 17 +++++++++++++++++
 include/hw/isa/isa.h |  1 +
 2 files changed, 18 insertions(+)

Comments

Ani Sinha Feb. 21, 2022, 11:12 a.m. UTC | #1
On Mon, Feb 21, 2022 at 12:57 AM Liav Albani <liavalb@gmail.com> wrote:

This patch has no description. Please provide a description.

>
> Signed-off-by: Liav Albani <liavalb@gmail.com>
> ---
>  hw/isa/isa-bus.c     | 17 +++++++++++++++++
>  include/hw/isa/isa.h |  1 +
>  2 files changed, 18 insertions(+)
>
> diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
> index 6c31398dda..39d1768797 100644
> --- a/hw/isa/isa-bus.c
> +++ b/hw/isa/isa-bus.c
> @@ -222,6 +222,23 @@ void isa_build_aml(ISABus *bus, Aml *scope)
>      }
>  }
>
> +bool isa_check_device_existence(const char *typename)
> +{
> +    assert(isabus != NULL);
> +
> +    BusChild *kid;
> +    ISADevice *dev;
> +
> +    QTAILQ_FOREACH(kid, &isabus->parent_obj.children, sibling) {
> +        dev = ISA_DEVICE(kid->child);
> +        const char *object_type = object_get_typename(OBJECT(dev));
> +        if (object_type && strcmp(object_type, typename) == 0) {
> +            return true;
> +        }
> +    }
> +    return false;
> +}
> +
>  static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
>  {
>      ISADevice *d = ISA_DEVICE(dev);
> diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
> index d4417b34b6..65f0c7e28c 100644
> --- a/include/hw/isa/isa.h
> +++ b/include/hw/isa/isa.h
> @@ -99,6 +99,7 @@ IsaDma *isa_get_dma(ISABus *bus, int nchan);
>  MemoryRegion *isa_address_space(ISADevice *dev);
>  MemoryRegion *isa_address_space_io(ISADevice *dev);
>  ISADevice *isa_new(const char *name);
> +bool isa_check_device_existence(const char *typename);
>  ISADevice *isa_try_new(const char *name);
>  bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp);
>  ISADevice *isa_create_simple(ISABus *bus, const char *name);
> --
> 2.35.1
>
diff mbox series

Patch

diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index 6c31398dda..39d1768797 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -222,6 +222,23 @@  void isa_build_aml(ISABus *bus, Aml *scope)
     }
 }
 
+bool isa_check_device_existence(const char *typename)
+{
+    assert(isabus != NULL);
+
+    BusChild *kid;
+    ISADevice *dev;
+
+    QTAILQ_FOREACH(kid, &isabus->parent_obj.children, sibling) {
+        dev = ISA_DEVICE(kid->child);
+        const char *object_type = object_get_typename(OBJECT(dev));
+        if (object_type && strcmp(object_type, typename) == 0) {
+            return true;
+        }
+    }
+    return false;
+}
+
 static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
 {
     ISADevice *d = ISA_DEVICE(dev);
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index d4417b34b6..65f0c7e28c 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -99,6 +99,7 @@  IsaDma *isa_get_dma(ISABus *bus, int nchan);
 MemoryRegion *isa_address_space(ISADevice *dev);
 MemoryRegion *isa_address_space_io(ISADevice *dev);
 ISADevice *isa_new(const char *name);
+bool isa_check_device_existence(const char *typename);
 ISADevice *isa_try_new(const char *name);
 bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp);
 ISADevice *isa_create_simple(ISABus *bus, const char *name);