Patchwork [05/10] serial: refactor device creation

login
register
mail settings
Submitter Blue Swirl
Date Feb. 12, 2011, 10:41 p.m.
Message ID <AANLkTimgROjnD4G46xmDHkO2mmwb3Wg9Gg2jFwCjvrtf@mail.gmail.com>
Download mbox | patch
Permalink /patch/82947/
State New
Headers show

Comments

Blue Swirl - Feb. 12, 2011, 10:41 p.m.
Turn serial_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/pc.h     |   14 +++++++++++++-
 hw/serial.c |   12 ------------
 2 files changed, 13 insertions(+), 13 deletions(-)

Patch

diff --git a/hw/pc.h b/hw/pc.h
index 50d9943..09f63f0 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -17,7 +17,19 @@  SerialState *serial_mm_init (target_phys_addr_t
base, int it_shift,
                              qemu_irq irq, int baudbase,
                              CharDriverState *chr, int ioregister,
                              int be);
-SerialState *serial_isa_init(int index, CharDriverState *chr);
+static inline bool serial_isa_init(int index, CharDriverState *chr)
+{
+    ISADevice *dev;
+
+    dev = isa_create("isa-serial");
+    qdev_prop_set_uint32(&dev->qdev, "index", index);
+    qdev_prop_set_chr(&dev->qdev, "chardev", chr);
+    if (qdev_init(&dev->qdev) < 0) {
+        return false;
+    }
+    return true;
+}
+
 void serial_set_frequency(SerialState *s, uint32_t frequency);

 /* parallel.c */
diff --git a/hw/serial.c b/hw/serial.c
index 2c4af61..879237f 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -782,18 +782,6 @@  static int serial_isa_initfn(ISADevice *dev)
     return 0;
 }

-SerialState *serial_isa_init(int index, CharDriverState *chr)
-{
-    ISADevice *dev;
-
-    dev = isa_create("isa-serial");
-    qdev_prop_set_uint32(&dev->qdev, "index", index);
-    qdev_prop_set_chr(&dev->qdev, "chardev", chr);
-    if (qdev_init(&dev->qdev) < 0)
-        return NULL;
-    return &DO_UPCAST(ISASerialState, dev, dev)->state;
-}
-
 static const VMStateDescription vmstate_isa_serial = {
     .name = "serial",
     .version_id = 3,