From patchwork Wed Feb 1 19:50:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 139002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 860F51007D1 for ; Thu, 2 Feb 2012 08:00:01 +1100 (EST) Received: from localhost ([::1]:58983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsgEQ-0002W7-A4 for incoming@patchwork.ozlabs.org; Wed, 01 Feb 2012 14:52:38 -0500 Received: from eggs.gnu.org ([140.186.70.92]:37728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsgE7-0001yh-Ec for qemu-devel@nongnu.org; Wed, 01 Feb 2012 14:52:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RsgE2-0006Cx-Fp for qemu-devel@nongnu.org; Wed, 01 Feb 2012 14:52:19 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:52947 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsgE2-0006CR-9V for qemu-devel@nongnu.org; Wed, 01 Feb 2012 14:52:14 -0500 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id q11Jq6T3006408; Wed, 1 Feb 2012 13:52:07 -0600 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id q11Jq5XL006407; Wed, 1 Feb 2012 13:52:05 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 1 Feb 2012 13:50:57 -0600 Message-Id: <1328125863-6203-17-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1328125863-6203-1-git-send-email-aliguori@us.ibm.com> References: <1328125863-6203-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Paolo Bonzini , Anthony Liguori , Andreas Faerber , Peter Maydell Subject: [Qemu-devel] [PATCH 16/22] qdev: nuke qdev_init_chardev() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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(-) 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