qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Igor Mammedov <imammedo@redhat.com>
Subject: [PULL 11/15] qdev: Make qdev_class_add_property() more flexible
Date: Wed, 23 Dec 2020 16:27:31 -0500	[thread overview]
Message-ID: <20201223212735.512062-12-ehabkost@redhat.com> (raw)
In-Reply-To: <20201223212735.512062-1-ehabkost@redhat.com>

Support Property.set_default and PropertyInfo.description even if
PropertyInfo.create is set.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20201211220529.2290218-26-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/qdev-properties.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3bb05e7d0d..2946cdf56d 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -863,24 +863,22 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name,
                                     Property *prop)
 {
     ObjectClass *oc = OBJECT_CLASS(klass);
+    ObjectProperty *op;
 
     if (prop->info->create) {
-        prop->info->create(oc, name, prop);
+        op = prop->info->create(oc, name, prop);
     } else {
-        ObjectProperty *op;
-
         op = object_class_property_add(oc,
                                        name, prop->info->name,
                                        field_prop_getter(prop->info),
                                        field_prop_setter(prop->info),
                                        prop->info->release,
                                        prop);
-        if (prop->set_default) {
-            prop->info->set_default_value(op, prop);
-        }
     }
-    object_class_property_set_description(oc, name,
-                                          prop->info->description);
+    if (prop->set_default) {
+        prop->info->set_default_value(op, prop);
+    }
+    object_class_property_set_description(oc, name, prop->info->description);
 }
 
 /**
-- 
2.28.0



  parent reply	other threads:[~2020-12-23 21:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 21:27 [PULL 00/15] Machine queue, 2020-12-23 Eduardo Habkost
2020-12-23 21:27 ` [PULL 01/15] qdev: Move softmmu properties to qdev-properties-system.h Eduardo Habkost
2020-12-23 21:27 ` [PULL 02/15] qdev: Reuse DEFINE_PROP in all DEFINE_PROP_* macros Eduardo Habkost
2020-12-23 21:27 ` [PULL 03/15] sparc: Use DEFINE_PROP for nwindows property Eduardo Habkost
2020-12-23 21:27 ` [PULL 04/15] qdev: Get just property name at error_set_from_qdev_prop_error() Eduardo Habkost
2020-12-23 21:27 ` [PULL 05/15] qdev: Avoid using prop->name unnecessarily Eduardo Habkost
2020-12-23 21:27 ` [PULL 06/15] qdev: Add name parameter to qdev_class_add_property() Eduardo Habkost
2020-12-23 21:27 ` [PULL 07/15] qdev: Add name argument to PropertyInfo.create method Eduardo Habkost
2020-12-23 21:27 ` [PULL 08/15] qdev: Wrap getters and setters in separate helpers Eduardo Habkost
2020-12-23 21:27 ` [PULL 09/15] qdev: Move dev->realized check to qdev_property_set() Eduardo Habkost
2020-12-23 21:27 ` [PULL 10/15] qdev: Make PropertyInfo.create return ObjectProperty* Eduardo Habkost
2020-12-23 21:27 ` Eduardo Habkost [this message]
2020-12-23 21:27 ` [PULL 12/15] qdev: Move qdev_prop_tpm declaration to tpm_prop.h Eduardo Habkost
2020-12-23 21:27 ` [PULL 13/15] qdev: Rename qdev_get_prop_ptr() to object_field_prop_ptr() Eduardo Habkost
2020-12-23 21:27 ` [PULL 14/15] qdev: Avoid unnecessary DeviceState* variable at set_prop_arraylen() Eduardo Habkost
2020-12-23 21:27 ` [PULL 15/15] bugfix: hostmem: Free host_nodes list right after visited Eduardo Habkost
2021-01-02 13:12 ` [PULL 00/15] Machine queue, 2020-12-23 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201223212735.512062-12-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).