[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 24/28] qdev-props: convert global_props to GPtrAr
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v7 24/28] qdev-props: convert global_props to GPtrArray |
Date: |
Fri, 21 Dec 2018 13:04:06 +0400 |
A step towards being able to call a common function,
object_apply_global_props().
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
---
hw/core/qdev-properties.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 43c30a57f4..3467e0485c 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1173,22 +1173,32 @@ void qdev_prop_set_ptr(DeviceState *dev, const char
*name, void *value)
*ptr = value;
}
-static GList *global_props;
+static GPtrArray *global_props(void)
+{
+ static GPtrArray *gp;
+
+ if (!gp) {
+ gp = g_ptr_array_new();
+ }
+
+ return gp;
+}
void qdev_prop_register_global(GlobalProperty *prop)
{
- global_props = g_list_append(global_props, prop);
+ g_ptr_array_add(global_props(), prop);
}
int qdev_prop_check_globals(void)
{
- GList *l;
- int ret = 0;
+ int i, ret = 0;
- for (l = global_props; l; l = l->next) {
- GlobalProperty *prop = l->data;
+ for (i = 0; i < global_props()->len; i++) {
+ GlobalProperty *prop;
ObjectClass *oc;
DeviceClass *dc;
+
+ prop = g_ptr_array_index(global_props(), i);
if (prop->used) {
continue;
}
@@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
void qdev_prop_set_globals(DeviceState *dev)
{
- GList *l;
+ int i;
- for (l = global_props; l; l = l->next) {
- GlobalProperty *prop = l->data;
+ for (i = 0; i < global_props()->len; i++) {
+ GlobalProperty *prop;
Error *err = NULL;
+ prop = g_ptr_array_index(global_props(), i);
if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
continue;
}
--
2.20.1.2.gb21ebb671b
- [Qemu-devel] [PATCH v7 17/28] compat: replace PC_COMPAT_2_3 & HW_COMPAT_2_3 macros, (continued)
- [Qemu-devel] [PATCH v7 17/28] compat: replace PC_COMPAT_2_3 & HW_COMPAT_2_3 macros, Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 19/28] compat: replace PC_COMPAT_2_1 & HW_COMPAT_2_1 macros, Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 20/28] include: remove compat.h, Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 21/28] compat: remove remaining PC_COMPAT macros, Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 23/28] qdev: all globals are now user-provided, Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 24/28] qdev-props: convert global_props to GPtrArray,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v7 22/28] qdev: make a separate helper function to apply compat properties, Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 25/28] qdev-props: remove errp from GlobalProperty, Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 26/28] qdev-props: call object_apply_global_props(), Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 27/28] arm: replace instance_post_init(), Marc-André Lureau, 2018/12/21
- [Qemu-devel] [PATCH v7 28/28] hostmem: use object id for memory region name with >= 4.0, Marc-André Lureau, 2018/12/21