[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 05/12] x86-iommu: use DeviceClass properties
From: |
Peter Xu |
Subject: |
[Qemu-devel] [PATCH v3 05/12] x86-iommu: use DeviceClass properties |
Date: |
Wed, 10 May 2017 16:01:48 +0800 |
No reason to keep tens of lines if we can do it actually far shorter.
Signed-off-by: Peter Xu <address@hidden>
---
hw/i386/x86-iommu.c | 47 +++++++----------------------------------------
1 file changed, 7 insertions(+), 40 deletions(-)
diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
index 23dcd3f..02b8825 100644
--- a/hw/i386/x86-iommu.c
+++ b/hw/i386/x86-iommu.c
@@ -88,55 +88,22 @@ static void x86_iommu_realize(DeviceState *dev, Error
**errp)
x86_iommu_set_default(X86_IOMMU_DEVICE(dev));
}
+static Property x86_iommu_properties[] = {
+ DEFINE_PROP_BOOL("intremap", X86IOMMUState, intr_supported, false),
+ DEFINE_PROP_BOOL("device-iotlb", X86IOMMUState, dt_supported, false),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void x86_iommu_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = x86_iommu_realize;
-}
-
-static bool x86_iommu_intremap_prop_get(Object *o, Error **errp)
-{
- X86IOMMUState *s = X86_IOMMU_DEVICE(o);
- return s->intr_supported;
-}
-
-static void x86_iommu_intremap_prop_set(Object *o, bool value, Error **errp)
-{
- X86IOMMUState *s = X86_IOMMU_DEVICE(o);
- s->intr_supported = value;
-}
-
-static bool x86_iommu_device_iotlb_prop_get(Object *o, Error **errp)
-{
- X86IOMMUState *s = X86_IOMMU_DEVICE(o);
- return s->dt_supported;
-}
-
-static void x86_iommu_device_iotlb_prop_set(Object *o, bool value, Error
**errp)
-{
- X86IOMMUState *s = X86_IOMMU_DEVICE(o);
- s->dt_supported = value;
-}
-
-static void x86_iommu_instance_init(Object *o)
-{
- X86IOMMUState *s = X86_IOMMU_DEVICE(o);
-
- /* By default, do not support IR */
- s->intr_supported = false;
- object_property_add_bool(o, "intremap", x86_iommu_intremap_prop_get,
- x86_iommu_intremap_prop_set, NULL);
- s->dt_supported = false;
- object_property_add_bool(o, "device-iotlb",
- x86_iommu_device_iotlb_prop_get,
- x86_iommu_device_iotlb_prop_set,
- NULL);
+ dc->props = x86_iommu_properties;
}
static const TypeInfo x86_iommu_info = {
.name = TYPE_X86_IOMMU_DEVICE,
.parent = TYPE_SYS_BUS_DEVICE,
- .instance_init = x86_iommu_instance_init,
.instance_size = sizeof(X86IOMMUState),
.class_init = x86_iommu_class_init,
.class_size = sizeof(X86IOMMUClass),
--
2.7.4
[Qemu-devel] [PATCH v3 05/12] x86-iommu: use DeviceClass properties,
Peter Xu <=
[Qemu-devel] [PATCH v3 07/12] intel_iommu: provide vtd_ce_get_type(), Peter Xu, 2017/05/10
[Qemu-devel] [PATCH v3 06/12] intel_iommu: renaming context entry helpers, Peter Xu, 2017/05/10
[Qemu-devel] [PATCH v3 08/12] intel_iommu: use IOMMU_ACCESS_FLAG(), Peter Xu, 2017/05/10
[Qemu-devel] [PATCH v3 09/12] intel_iommu: allow dev-iotlb context entry conditionally, Peter Xu, 2017/05/10
[Qemu-devel] [PATCH v3 10/12] intel_iommu: support passthrough (PT), Peter Xu, 2017/05/10
[Qemu-devel] [PATCH v3 11/12] intel_iommu: turn off pt before 2.9, Peter Xu, 2017/05/10