qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 03/13] qdev: add property type for 32bit signed integers.
Date: Thu, 10 Sep 2009 11:43:25 +0200	[thread overview]
Message-ID: <1252575815-7824-4-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1252575815-7824-1-git-send-email-kraxel@redhat.com>


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev-properties.c |   28 ++++++++++++++++++++++++++++
 hw/qdev.h            |    5 +++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 12ff46b..28b2716 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -64,6 +64,29 @@ PropertyInfo qdev_prop_uint32 = {
     .print = print_uint32,
 };
 
+static int parse_int32(DeviceState *dev, Property *prop, const char *str)
+{
+    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
+
+    if (sscanf(str, "%" PRId32, ptr) != 1)
+        return -1;
+    return 0;
+}
+
+static int print_int32(DeviceState *dev, Property *prop, char *dest, size_t len)
+{
+    int32_t *ptr = qdev_get_prop_ptr(dev, prop);
+    return snprintf(dest, len, "%" PRId32, *ptr);
+}
+
+PropertyInfo qdev_prop_int32 = {
+    .name  = "int32",
+    .type  = PROP_TYPE_INT32,
+    .size  = sizeof(int32_t),
+    .parse = parse_int32,
+    .print = print_int32,
+};
+
 /* --- 32bit hex value --- */
 
 static int parse_hex32(DeviceState *dev, Property *prop, const char *str)
@@ -367,6 +390,11 @@ void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value)
     qdev_prop_set(dev, name, &value, PROP_TYPE_UINT32);
 }
 
+void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value)
+{
+    qdev_prop_set(dev, name, &value, PROP_TYPE_INT32);
+}
+
 void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value)
 {
     qdev_prop_set(dev, name, &value, PROP_TYPE_UINT64);
diff --git a/hw/qdev.h b/hw/qdev.h
index 6d0d7f4..c2609b4 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -62,6 +62,7 @@ enum PropertyType {
     PROP_TYPE_UNSPEC = 0,
     PROP_TYPE_UINT16,
     PROP_TYPE_UINT32,
+    PROP_TYPE_INT32,
     PROP_TYPE_UINT64,
     PROP_TYPE_TADDR,
     PROP_TYPE_MACADDR,
@@ -156,6 +157,7 @@ void do_info_qdm(Monitor *mon);
 
 extern PropertyInfo qdev_prop_uint16;
 extern PropertyInfo qdev_prop_uint32;
+extern PropertyInfo qdev_prop_int32;
 extern PropertyInfo qdev_prop_uint64;
 extern PropertyInfo qdev_prop_hex32;
 extern PropertyInfo qdev_prop_hex64;
@@ -183,6 +185,8 @@ extern PropertyInfo qdev_prop_pci_devfn;
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
 #define DEFINE_PROP_UINT32(_n, _s, _f, _d)                      \
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
+#define DEFINE_PROP_INT32(_n, _s, _f, _d)                      \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
 #define DEFINE_PROP_UINT64(_n, _s, _f, _d)                      \
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
 #define DEFINE_PROP_HEX32(_n, _s, _f, _d)                       \
@@ -210,6 +214,7 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
 void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type);
 void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
 void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
+void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
 void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
 void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
 void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value);
-- 
1.6.2.5

  parent reply	other threads:[~2009-09-10  9:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-10  9:43 [Qemu-devel] [PATCH v2 00/13] qdev isa patches Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 01/13] isapc: Fix irq routing Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 02/13] isapc: pick a more sane default cpu for such old hardware Gerd Hoffmann
2009-09-10  9:43 ` Gerd Hoffmann [this message]
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 04/13] qdev: drop iobase properties from isa bus Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 05/13] qdev: simplify isa irq assignments Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 06/13] qdev: tag isabus-bridge as no-user Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 07/13] qdev: add isa_create() function Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 08/13] qdev/isa: convert soundblaster Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 09/13] qdev/isa: convert cs4231a sound card Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 10/13] qdev/isa: convert gravis ultrasound Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 11/13] qdev/isa: convert ne2000 Gerd Hoffmann
2009-09-10 15:53   ` Markus Armbruster
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 12/13] qdev/isa: finish pckbd conversion Gerd Hoffmann
2009-09-10  9:43 ` [Qemu-devel] [PATCH v2 13/13] qdev/isa: convert real time clock 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=1252575815-7824-4-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.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).