From: Markus Armbruster <armbru@redhat.com>
To: Zhou Yuan <zhouyuan.fnst@cn.fujitsu.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] hw/i2c/core.c: add the id property of i2c_slaver when created in the QEMUMachine's initialization
Date: Fri, 15 Nov 2013 10:28:40 +0100 [thread overview]
Message-ID: <87k3gaggjb.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <201311151701366579617@cn.fujitsu.com> (Zhou Yuan's message of "Fri, 15 Nov 2013 17:01:38 +0800")
"Zhou Yuan" <zhouyuan.fnst@cn.fujitsu.com> writes:
> From: zhouy <zhouyuan.fnst@cn.fujitsu.com>
> Date: Fri, 15 Nov 2013 15:50:52 -0500
> Subject: [PATCH] add the id property of i2c_slaver when created in the
> QEMUMachine's initialization
>
> Signed-off-by: zhouy <zhouyuan.fnst@cn.fujitsu.com>
> ---
> qemu-master/hw/i2c/core.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-master/hw/i2c/core.c b/qemu-master/hw/i2c/core.c
> index c97e7f7..ea3e59d 100644
> --- a/qemu-master/hw/i2c/core.c
> +++ b/qemu-master/hw/i2c/core.c
> @@ -213,10 +213,16 @@ static int i2c_slave_qdev_init(DeviceState *dev)
> DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr)
> {
> DeviceState *dev;
> -
> + static unsigned int seq_num;
> + char *id = g_malloc0(20);
> + snprintf(id, 20, "%s-%d", name, seq_num);
> dev = qdev_create(&bus->qbus, name);
> qdev_prop_set_uint8(dev, "address", addr);
> + dev->id = id;
> + object_property_add_child(container_get(qdev_get_machine(), "/peripheral"),
> + dev->id, OBJECT(dev), NULL);
> qdev_init_nofail(dev);
> + seq_num++;
> return dev;
> }
Why is this needed?
In general, property "id" / DeviceState member id is strictly for the
user, and should never be set automatically. Exceptions exist in
convenience options, mostly for historical reasons.
prev parent reply other threads:[~2013-11-15 9:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 9:01 [Qemu-devel] [PATCH] hw/i2c/core.c: add the id property of i2c_slaver when created in the QEMUMachine's initialization Zhou Yuan
2013-11-15 9:28 ` Markus Armbruster [this message]
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=87k3gaggjb.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhouyuan.fnst@cn.fujitsu.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.