From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: paul@codesourcery.com, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] qdev/prop: helper macros.
Date: Mon, 13 Jul 2009 15:33:51 +0200 [thread overview]
Message-ID: <1247492031-16104-3-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1247492031-16104-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pci.c | 5 +++++
hw/qdev-addr.h | 3 +++
hw/qdev.h | 20 ++++++++++++++++++++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 4e92c4c..1a1cbc6 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -56,6 +56,7 @@ static struct BusInfo pci_bus_info = {
.print_dev = pcibus_dev_print,
.add_dev = pci_create,
.props = (Property[]) {
+#if 0
{
.name = "devfn",
.info = &qdev_prop_uint32,
@@ -63,6 +64,10 @@ static struct BusInfo pci_bus_info = {
.defval = (uint32_t[]) { -1 },
},
{/* end of list */}
+#else
+ DEF_PROP_UINT32("devfn", PCIDevice, devfn, -1),
+ DEF_PROP_END_OF_LIST()
+#endif
}
};
diff --git a/hw/qdev-addr.h b/hw/qdev-addr.h
index f02bd7a..7160989 100644
--- a/hw/qdev-addr.h
+++ b/hw/qdev-addr.h
@@ -1,2 +1,5 @@
+#define DEF_PROP_TADDR(_n, _s, _f, _d) \
+ DEF_PROP(_n, _s, _f, _d, target_phys_addr_t, qdev_prop_taddr)
+
extern PropertyInfo qdev_prop_taddr;
void qdev_prop_set_taddr(DeviceState *dev, const char *name, target_phys_addr_t value);
diff --git a/hw/qdev.h b/hw/qdev.h
index 584617e..1edefcc 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -144,6 +144,26 @@ extern PropertyInfo qdev_prop_hex32;
extern PropertyInfo qdev_prop_ptr;
extern PropertyInfo qdev_prop_mac;
+#define DEF_PROP(_name, _state, _field, _defval, _type, _prop) { \
+ .name = (_name), \
+ .info = &(_prop), \
+ .offset = offsetof(_state, _field), \
+ .defval = (_type[]) { (_defval) }, \
+ }
+
+#define DEF_PROP_UINT16(_n, _s, _f, _d) \
+ DEF_PROP(_n, _s, _f, _d, uint16_t, qdev_prop_uint16)
+#define DEF_PROP_UINT32(_n, _s, _f, _d) \
+ DEF_PROP(_n, _s, _f, _d, uint32_t, qdev_prop_uint32)
+#define DEF_PROP_HEX32(_n, _s, _f, _d) \
+ DEF_PROP(_n, _s, _f, _d, uint32_t, qdev_prop_hex32)
+#define DEF_PROP_PTR(_n, _s, _f, _d) \
+ DEF_PROP(_n, _s, _f, _d, void*, qdev_prop_ptr)
+#define DEF_PROP_MAC(_n, _s, _f, _d) \
+ DEF_PROP(_n, _s, _f, _d, void*, qdev_prop_mac)
+#define DEF_PROP_END_OF_LIST() \
+ {}
+
/* Set properties between creation and init. */
void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
--
1.6.2.5
next prev parent reply other threads:[~2009-07-13 13:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-13 13:33 [Qemu-devel] [RfC PATCH 0/2] qdev/prop: type checking Gerd Hoffmann
2009-07-13 13:33 ` [Qemu-devel] [PATCH 1/2] qdev/prop: add property type Gerd Hoffmann
2009-07-13 13:33 ` Gerd Hoffmann [this message]
2009-07-13 15:36 ` [Qemu-devel] [RfC PATCH 0/2] qdev/prop: type checking Paul Brook
2009-07-13 19:19 ` Gerd Hoffmann
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=1247492031-16104-3-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=paul@codesourcery.com \
--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).