Received: from eggs.gnu.org ([2001:4830:134:3::10]:48117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byfhv-0001G0-KT for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:54:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byfhr-0000uf-Vn for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:54:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byfhr-0000uZ-Nu for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:54:27 -0400 Date: Mon, 24 Oct 2016 15:54:24 +0200 From: Igor Mammedov Message-ID: <20161024155424.2713b9dd@nial.brq.redhat.com> In-Reply-To: <1476985679-4456-3-git-send-email-ehabkost@redhat.com> References: <1476985679-4456-1-git-send-email-ehabkost@redhat.com> <1476985679-4456-3-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/6] qdev: Extract property-default code to qdev_property_set_to_default() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: qemu-devel@nongnu.org, Markus Armbruster , Andreas =?UTF-8?B?RsOkcmJlcg==?= On Thu, 20 Oct 2016 15:47:55 -0200 Eduardo Habkost wrote: > The code that registers qdev properties will be split from the > code that initializes default values on instance_init, so move it > to a separate function. > > Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov > --- > hw/core/qdev.c | 41 +++++++++++++++++++++++++++++------------ > 1 file changed, 29 insertions(+), 12 deletions(-) > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index 36ca5e7..85952e8 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -775,6 +775,34 @@ static void qdev_property_add_legacy(DeviceState *dev, Property *prop, > } > > /** > + * qdev_property_set_to_default: > + * @dev: Device where the property will be reset > + * @prop: The qdev property definition > + * @errp: location to store error information > + * > + * Reset the value of property @prop in @dev to its default value. > + * On error, store error in @errp. > + */ > +static void qdev_property_set_to_default(DeviceState *dev, Property *prop, > + Error **errp) > +{ > + Object *obj = OBJECT(dev); > + > + if (prop->qtype == QTYPE_NONE) { > + return; > + } > + > + if (prop->qtype == QTYPE_QBOOL) { > + object_property_set_bool(obj, prop->defval, prop->name, errp); > + } else if (prop->info->enum_table) { > + object_property_set_str(obj, prop->info->enum_table[prop->defval], > + prop->name, errp); > + } else if (prop->qtype == QTYPE_QINT) { > + object_property_set_int(obj, prop->defval, prop->name, errp); > + } > +} > + > +/** > * qdev_property_add_static: > * @dev: Device to add the property to. > * @prop: The qdev property definition. > @@ -813,18 +841,7 @@ void qdev_property_add_static(DeviceState *dev, Property *prop, > prop->info->description, > &error_abort); > > - if (prop->qtype == QTYPE_NONE) { > - return; > - } > - > - if (prop->qtype == QTYPE_QBOOL) { > - object_property_set_bool(obj, prop->defval, prop->name, &error_abort); > - } else if (prop->info->enum_table) { > - object_property_set_str(obj, prop->info->enum_table[prop->defval], > - prop->name, &error_abort); > - } else if (prop->qtype == QTYPE_QINT) { > - object_property_set_int(obj, prop->defval, prop->name, &error_abort); > - } > + qdev_property_set_to_default(dev, prop, &error_abort); > } > > /* @qdev_alias_all_properties - Add alias properties to the source object for