Patchwork [16/22] qdev: nuke qdev_init_chardev()

login
register
mail settings
Submitter Anthony Liguori
Date Feb. 1, 2012, 7:50 p.m.
Message ID <1328125863-6203-17-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/139002/
State New
Headers show

Comments

Anthony Liguori - Feb. 1, 2012, 7:50 p.m.
I'm sure the intentions were good here, but there's no reason this should be in
qdev.  Move it to qemu-char where it belongs.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/etraxfs_ser.c     |    2 +-
 hw/lm32_juart.c      |    2 +-
 hw/lm32_uart.c       |    2 +-
 hw/milkymist-uart.c  |    2 +-
 hw/pl011.c           |    2 +-
 hw/qdev.c            |    9 ---------
 hw/qdev.h            |    2 --
 hw/xilinx_uartlite.c |    2 +-
 qemu-char.c          |   10 ++++++++++
 qemu-char.h          |    2 ++
 10 files changed, 18 insertions(+), 17 deletions(-)

Patch

diff --git a/hw/etraxfs_ser.c b/hw/etraxfs_ser.c
index b8acd43..567cb8c 100644
--- a/hw/etraxfs_ser.c
+++ b/hw/etraxfs_ser.c
@@ -216,7 +216,7 @@  static int etraxfs_ser_init(SysBusDevice *dev)
     memory_region_init_io(&s->mmio, &ser_ops, s, "etraxfs-serial", R_MAX * 4);
     sysbus_init_mmio(dev, &s->mmio);
 
-    s->chr = qdev_init_chardev(&dev->qdev);
+    s->chr = qemu_char_get_next_serial();
     if (s->chr)
         qemu_chr_add_handlers(s->chr,
                       serial_can_receive, serial_receive,
diff --git a/hw/lm32_juart.c b/hw/lm32_juart.c
index 023c644..38dd282 100644
--- a/hw/lm32_juart.c
+++ b/hw/lm32_juart.c
@@ -114,7 +114,7 @@  static int lm32_juart_init(SysBusDevice *dev)
 {
     LM32JuartState *s = FROM_SYSBUS(typeof(*s), dev);
 
-    s->chr = qdev_init_chardev(&dev->qdev);
+    s->chr = qemu_char_get_next_serial();
     if (s->chr) {
         qemu_chr_add_handlers(s->chr, juart_can_rx, juart_rx, juart_event, s);
     }
diff --git a/hw/lm32_uart.c b/hw/lm32_uart.c
index fc70490..630ccb7 100644
--- a/hw/lm32_uart.c
+++ b/hw/lm32_uart.c
@@ -252,7 +252,7 @@  static int lm32_uart_init(SysBusDevice *dev)
     memory_region_init_io(&s->iomem, &uart_ops, s, "uart", R_MAX * 4);
     sysbus_init_mmio(dev, &s->iomem);
 
-    s->chr = qdev_init_chardev(&dev->qdev);
+    s->chr = qemu_char_get_next_serial();
     if (s->chr) {
         qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
     }
diff --git a/hw/milkymist-uart.c b/hw/milkymist-uart.c
index 2999b79..f9a229c 100644
--- a/hw/milkymist-uart.c
+++ b/hw/milkymist-uart.c
@@ -199,7 +199,7 @@  static int milkymist_uart_init(SysBusDevice *dev)
             "milkymist-uart", R_MAX * 4);
     sysbus_init_mmio(dev, &s->regs_region);
 
-    s->chr = qdev_init_chardev(&dev->qdev);
+    s->chr = qemu_char_get_next_serial();
     if (s->chr) {
         qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
     }
diff --git a/hw/pl011.c b/hw/pl011.c
index 8db2248..752cbf9 100644
--- a/hw/pl011.c
+++ b/hw/pl011.c
@@ -264,7 +264,7 @@  static int pl011_init(SysBusDevice *dev, const unsigned char *id)
     sysbus_init_mmio(dev, &s->iomem);
     sysbus_init_irq(dev, &s->irq);
     s->id = id;
-    s->chr = qdev_init_chardev(&dev->qdev);
+    s->chr = qemu_char_get_next_serial();
 
     s->read_trigger = 1;
     s->ifl = 0x12;
diff --git a/hw/qdev.c b/hw/qdev.c
index e82165d..0692a21 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -336,15 +336,6 @@  bool qdev_machine_modified(void)
     return qdev_hot_added || qdev_hot_removed;
 }
 
-/* Get a character (serial) device interface.  */
-CharDriverState *qdev_init_chardev(DeviceState *dev)
-{
-    static int next_serial;
-
-    /* FIXME: This function needs to go away: use chardev properties!  */
-    return serial_hds[next_serial++];
-}
-
 BusState *qdev_get_parent_bus(DeviceState *dev)
 {
     return dev->parent_bus;
diff --git a/hw/qdev.h b/hw/qdev.h
index 9535e57..d1f0e19 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -234,8 +234,6 @@  BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
 void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
 void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
 
-CharDriverState *qdev_init_chardev(DeviceState *dev);
-
 BusState *qdev_get_parent_bus(DeviceState *dev);
 
 /*** BUS API. ***/
diff --git a/hw/xilinx_uartlite.c b/hw/xilinx_uartlite.c
index 1491bba..1c2b908 100644
--- a/hw/xilinx_uartlite.c
+++ b/hw/xilinx_uartlite.c
@@ -205,7 +205,7 @@  static int xilinx_uartlite_init(SysBusDevice *dev)
     memory_region_init_io(&s->mmio, &uart_ops, s, "xilinx-uartlite", R_MAX * 4);
     sysbus_init_mmio(dev, &s->mmio);
 
-    s->chr = qdev_init_chardev(&dev->qdev);
+    s->chr = qemu_char_get_next_serial();
     if (s->chr)
         qemu_chr_add_handlers(s->chr, uart_can_rx, uart_rx, uart_event, s);
     return 0;
diff --git a/qemu-char.c b/qemu-char.c
index 27abcb9..b1d80dd 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2903,3 +2903,13 @@  CharDriverState *qemu_chr_find(const char *name)
     }
     return NULL;
 }
+
+/* Get a character (serial) device interface.  */
+CharDriverState *qemu_char_get_next_serial(void)
+{
+    static int next_serial;
+
+    /* FIXME: This function needs to go away: use chardev properties!  */
+    return serial_hds[next_serial++];
+}
+
diff --git a/qemu-char.h b/qemu-char.h
index 8ca1e2d..486644b 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -248,4 +248,6 @@  void qemu_chr_close_mem(CharDriverState *chr);
 QString *qemu_chr_mem_to_qs(CharDriverState *chr);
 size_t qemu_chr_mem_osize(const CharDriverState *chr);
 
+CharDriverState *qemu_char_get_next_serial(void);
+
 #endif