serial: refactor device creation
authorBlue Swirl <blauwirbel@gmail.com>
Sat, 5 Feb 2011 19:37:40 +0000 (19:37 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Sun, 20 Feb 2011 09:32:50 +0000 (09:32 +0000)
Turn serial_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
hw/pc.h
hw/serial.c

diff --git a/hw/pc.h b/hw/pc.h
index 50d9943dc3fbb2c5b97ff2010c03df70bd63d741..09f63f044a6bd1883ce8c34f902445bc52a565e0 100644 (file)
--- 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 */
index 2c4af61a2b4f33ae0fafee9341d123ccafd941f9..879237f1ec85c6a3c89ad9bb33711e2b8b812b86 100644 (file)
@@ -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,