qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH target-arm v4 01/12] qom: Make uintXX added properti


From: Peter Crosthwaite
Subject: [Qemu-devel] [PATCH target-arm v4 01/12] qom: Make uintXX added properties writable
Date: Tue, 10 Dec 2013 18:53:31 -0800

Currently the uintXX property adders make a read only property. This
is not useful for devices that want to create board (or container)
configurable dynamic device properties. Fix by trivially adding property
setters to object_property_add_uintXX.

Signed-off-by: Peter Crosthwaite <address@hidden>
---
changed since v3:
Dropped "/object" in subject (AF review)
changed since v2:
msg typo: "trivially"

 qom/object.c | 44 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index fc19cf6..07b454b 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1353,6 +1353,15 @@ static void property_get_uint8_ptr(Object *obj, Visitor 
*v,
     visit_type_uint8(v, &value, name, errp);
 }
 
+static void property_set_uint8_ptr(Object *obj, Visitor *v,
+                                   void *opaque, const char *name,
+                                   Error **errp)
+{
+    uint8_t value;
+    visit_type_uint8(v, &value, name, errp);
+    *(uint8_t *)opaque = value;
+}
+
 static void property_get_uint16_ptr(Object *obj, Visitor *v,
                                    void *opaque, const char *name,
                                    Error **errp)
@@ -1361,6 +1370,15 @@ static void property_get_uint16_ptr(Object *obj, Visitor 
*v,
     visit_type_uint16(v, &value, name, errp);
 }
 
+static void property_set_uint16_ptr(Object *obj, Visitor *v,
+                                    void *opaque, const char *name,
+                                    Error **errp)
+{
+    uint16_t value;
+    visit_type_uint16(v, &value, name, errp);
+    *(uint16_t *)opaque = value;
+}
+
 static void property_get_uint32_ptr(Object *obj, Visitor *v,
                                    void *opaque, const char *name,
                                    Error **errp)
@@ -1369,6 +1387,15 @@ static void property_get_uint32_ptr(Object *obj, Visitor 
*v,
     visit_type_uint32(v, &value, name, errp);
 }
 
+static void property_set_uint32_ptr(Object *obj, Visitor *v,
+                                    void *opaque, const char *name,
+                                    Error **errp)
+{
+    uint32_t value;
+    visit_type_uint32(v, &value, name, errp);
+    *(uint32_t *)opaque = value;
+}
+
 static void property_get_uint64_ptr(Object *obj, Visitor *v,
                                    void *opaque, const char *name,
                                    Error **errp)
@@ -1377,32 +1404,41 @@ static void property_get_uint64_ptr(Object *obj, 
Visitor *v,
     visit_type_uint64(v, &value, name, errp);
 }
 
+static void property_set_uint64_ptr(Object *obj, Visitor *v,
+                                    void *opaque, const char *name,
+                                    Error **errp)
+{
+    uint64_t value;
+    visit_type_uint64(v, &value, name, errp);
+    *(uint64_t *)opaque = value;
+}
+
 void object_property_add_uint8_ptr(Object *obj, const char *name,
                                    const uint8_t *v, Error **errp)
 {
     object_property_add(obj, name, "uint8", property_get_uint8_ptr,
-                        NULL, NULL, (void *)v, errp);
+                        property_set_uint8_ptr, NULL, (void *)v, errp);
 }
 
 void object_property_add_uint16_ptr(Object *obj, const char *name,
                                     const uint16_t *v, Error **errp)
 {
     object_property_add(obj, name, "uint16", property_get_uint16_ptr,
-                        NULL, NULL, (void *)v, errp);
+                        property_set_uint16_ptr, NULL, (void *)v, errp);
 }
 
 void object_property_add_uint32_ptr(Object *obj, const char *name,
                                     const uint32_t *v, Error **errp)
 {
     object_property_add(obj, name, "uint32", property_get_uint32_ptr,
-                        NULL, NULL, (void *)v, errp);
+                        property_set_uint32_ptr, NULL, (void *)v, errp);
 }
 
 void object_property_add_uint64_ptr(Object *obj, const char *name,
                                     const uint64_t *v, Error **errp)
 {
     object_property_add(obj, name, "uint64", property_get_uint64_ptr,
-                        NULL, NULL, (void *)v, errp);
+                        property_set_uint64_ptr, NULL, (void *)v, errp);
 }
 
 static void object_instance_init(Object *obj)
-- 
1.8.5.1




reply via email to

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