Skip to contentSkip to conversation

serial: refactor device creation

PATCH In review Blue Swirl 1 participant 1 message Feb 12, 2011

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

PATCH 5/10 serial: refactor device creation

Turn serial_init into an inline function.

---
 hw/pc.h     |   14 +++++++++++++-
 hw/serial.c |   12 ------------
 2 files changed, 13 insertions(+), 13 deletions(-)
hw/pc.h +0 -0
index 50d9943..09f63f0 100644
@@ -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 */

hw/serial.c +0 -12
index 2c4af61..879237f 100644
@@ -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,
Signature · 1 line
1.6.2.4

From 900fe1267fe152dd28302e7769315cfa8e1b3ec5 Mon Sep 17 00:00:00 2001
Message-Id: <900fe1267fe152dd28302e7769315cfa8e1b3ec5.1297550228.git.blauwirbel@gmail.com>
In-Reply-To: <533f58d512d6a4c4e004e9efdfb807b1ba84a5de.1297550228.git.blauwirbel@gmail.com>
References: <533f58d512d6a4c4e004e9efdfb807b1ba84a5de.1297550228.git.blauwirbel@gmail.com>
From: Blue Swirl <[email protected]>
Date: Sat, 5 Feb 2011 19:37:40 +0000
Subject: [PATCH 05/10] serial: refactor device creation

Turn serial_init into an inline function.

---
 hw/pc.h     |   14 +++++++++++++-
 hw/serial.c |   12 ------------
 2 files changed, 13 insertions(+), 13 deletions(-)
hw/pc.h +13 -1
index 50d9943..09f63f0 100644
@@ -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 */
hw/serial.c +0 -12
index 2c4af61..879237f 100644
@@ -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,
Signature · 1 line
1.7.2.3