Patchwork [v2,17/24] qdev: remove qdev_prop_exists

login
register
mail settings
Submitter Paolo Bonzini
Date April 11, 2012, 9:30 p.m.
Message ID <1334179842-6061-17-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/151907/
State New
Headers show

Comments

Paolo Bonzini - April 11, 2012, 9:30 p.m.
Can be replaced everywhere with object_property_find.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/qdev-properties.c  |    5 -----
 hw/qdev.c             |    2 +-
 hw/qdev.h             |    1 -
 hw/scsi-bus.c         |    2 +-
 include/qemu/object.h |    9 +++++++++
 qom/object.c          |    2 +-
 6 files changed, 12 insertions(+), 9 deletions(-)
Andreas Färber - April 12, 2012, 4:54 p.m.
Am 11.04.2012 23:30, schrieb Paolo Bonzini:
> Can be replaced everywhere with object_property_find.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

/-F

Patch

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index ace81cf..ffd601a 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -882,11 +882,6 @@  static Property *qdev_prop_find(DeviceState *dev, const char *name)
     return NULL;
 }
 
-int qdev_prop_exists(DeviceState *dev, const char *name)
-{
-    return qdev_prop_find(dev, name) ? true : false;
-}
-
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
                                     Property *prop, const char *value)
 {
diff --git a/hw/qdev.c b/hw/qdev.c
index f371248..819bff0 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -295,7 +295,7 @@  void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
     if (nd->netdev)
         qdev_prop_set_netdev(dev, "netdev", nd->netdev);
     if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
-        qdev_prop_exists(dev, "vectors")) {
+        object_property_find(OBJECT(dev), "vectors")) {
         qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
     }
     nd->instantiated = 1;
diff --git a/hw/qdev.h b/hw/qdev.h
index dfff93a..a159b94 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -287,7 +287,6 @@  extern PropertyInfo qdev_prop_pci_devfn;
 
 /* Set properties between creation and init.  */
 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
-int qdev_prop_exists(DeviceState *dev, const char *name);
 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
 void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);
 void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value);
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 10f9c63..2777566 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -206,7 +206,7 @@  SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
     if (bootindex >= 0) {
         qdev_prop_set_int32(dev, "bootindex", bootindex);
     }
-    if (qdev_prop_exists(dev, "removable")) {
+    if (object_property_find(OBJECT(dev), "removable")) {
         qdev_prop_set_bit(dev, "removable", removable);
     }
     if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) {
diff --git a/include/qemu/object.h b/include/qemu/object.h
index 22f646d..80f2bf3 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -637,6 +637,15 @@  void object_property_add(Object *obj, const char *name, const char *type,
 
 void object_property_del(Object *obj, const char *name, struct Error **errp);
 
+/**
+ * object_property_find:
+ * @obj: the object
+ * @name: the name of the property
+ *
+ * Look up a property for an object and return its #ObjectProperty if found.
+ */
+ObjectProperty *object_property_find(Object *obj, const char *name);
+
 void object_unparent(Object *obj);
 
 /**
diff --git a/qom/object.c b/qom/object.c
index ff36946..488047c 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -656,7 +656,7 @@  void object_property_add(Object *obj, const char *name, const char *type,
     QTAILQ_INSERT_TAIL(&obj->properties, prop, node);
 }
 
-static ObjectProperty *object_property_find(Object *obj, const char *name)
+ObjectProperty *object_property_find(Object *obj, const char *name)
 {
     ObjectProperty *prop;