From patchwork Fri Feb 27 01:48:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 444113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 471CE14011D for ; Fri, 27 Feb 2015 12:49:31 +1100 (AEDT) Received: from localhost ([::1]:33431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRA3V-0002iR-0T for incoming@patchwork.ozlabs.org; Thu, 26 Feb 2015 20:49:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRA3D-00024f-0m for qemu-devel@nongnu.org; Thu, 26 Feb 2015 20:49:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRA39-0008RG-Pa for qemu-devel@nongnu.org; Thu, 26 Feb 2015 20:49:10 -0500 Received: from mail-by2on0060.outbound.protection.outlook.com ([207.46.100.60]:18327 helo=na01-by2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRA39-0008R2-EP for qemu-devel@nongnu.org; Thu, 26 Feb 2015 20:49:07 -0500 Received: from BN1BFFO11FD051.protection.gbl (10.58.144.33) by BN1BFFO11HUB023.protection.gbl (10.58.144.170) with Microsoft SMTP Server (TLS) id 15.1.99.6; Fri, 27 Feb 2015 01:49:04 +0000 Received: from xsj-tvapsmtpgw01 (149.199.60.96) by BN1BFFO11FD051.mail.protection.outlook.com (10.58.145.6) with Microsoft SMTP Server (TLS) id 15.1.99.6 via Frontend Transport; Fri, 27 Feb 2015 01:49:03 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:36816 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1YR9zE-00007Y-3y; Thu, 26 Feb 2015 17:45:04 -0800 Received: from [127.0.0.1] (port=34392 helo=xsj-tvapsmtp02) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1YRA34-0005iH-6v; Thu, 26 Feb 2015 17:49:02 -0800 Received: from [172.16.162.22] (port=49868 helo=xbreng02.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1YRA33-0005iD-J9; Thu, 26 Feb 2015 17:49:01 -0800 From: Alistair Francis To: Date: Fri, 27 Feb 2015 11:48:58 +1000 Message-ID: <787a3b7f44a5be8b6976a808ca8e76cf84dc830e.1424999648.git.alistair.francis@xilinx.com> X-Mailer: git-send-email 2.1.1 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-7.5.0.1018-21358.005 X-TM-AS-Result: No--9.003-7.0-31-10 X-imss-scan-details: No--9.003-7.0-31-10 X-TMASE-MatchedRID: Hmx+Q2IPwQFzhK4AgIBmbpY9D0/NRxoqwx0jRRxcQfO4F2GkfaY1S3nv qbLkjGO6D855hkFOPoJFZcIUqUXCsxLmJd2F/yFu4pdq9sdj8LVo3Yq5PCwLAp0Koq3EzpuHZeB 4wkR7kKZ6ycEc/K4gzaAyD+9UWnWYZKHDol+YWzkVglQa/gMvfJv8tNLRPUrWEvoxTu3fj1u+Un f56ZSSHOLzNWBegCW2wgn7iDBesS0gBwKKRHe+r6KXizUsE6u60Ja3Crar1WS1vq2dn8N2E+TVe HQTkfSYX3pkxtcmvN0= X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of xilinx.com does not designate 149.199.60.96 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.96; helo=xsj-tvapsmtpgw01; Authentication-Results: spf=fail (sender IP is 149.199.60.96) smtp.mailfrom=alistair.francis@xilinx.com; nongnu.org; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:149.199.60.96; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(339900001)(189002)(199003)(47776003)(62966003)(77156002)(85426001)(50986999)(105606002)(46102003)(36756003)(16796002)(64026002)(110136001)(229853001)(71366001)(2351001)(19580395003)(50466002)(19580405001)(6806004)(77096005)(106466001)(87936001)(118296001)(48376002)(86362001)(50226001)(33646002)(92566002)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1BFFO11HUB023; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1BFFO11HUB023; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006); SRVR:BN1BFFO11HUB023; BCL:0; PCL:0; RULEID:; SRVR:BN1BFFO11HUB023; X-Forefront-PRVS: 05009853EF X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2015 01:49:03.5043 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.96] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1BFFO11HUB023 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 207.46.100.60 Cc: peter.crosthwaite@xilinx.com, afaerber@suse.de, alistair.francis@xilinx.com Subject: [Qemu-devel] [PATCH v3 1/1] char: cadence_uart: Convert to realize() 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 Use the DeviceClass realize() and init() instead of the deprecated SysBusDevice init(). Signed-off-by: Alistair Francis Reviewed-by: Peter Crosthwaite --- V3: - Move the timer_new_ns() function to realize - Remove the QEMUTimerCB cast V2: - Simplfy commit message - Fix function typo hw/char/cadence_uart.c | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 7044b35..a713a08 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -476,18 +476,12 @@ static void cadence_uart_reset(DeviceState *dev) uart_update_status(s); } -static int cadence_uart_init(SysBusDevice *dev) +static void cadence_uart_realize(DeviceState *dev, Error **errp) { UartState *s = CADENCE_UART(dev); - memory_region_init_io(&s->iomem, OBJECT(s), &uart_ops, s, "uart", 0x1000); - sysbus_init_mmio(dev, &s->iomem); - sysbus_init_irq(dev, &s->irq); - s->fifo_trigger_handle = timer_new_ns(QEMU_CLOCK_VIRTUAL, - (QEMUTimerCB *)fifo_trigger_update, s); - - s->char_tx_time = (get_ticks_per_sec() / 9600) * 10; + fifo_trigger_update, s); s->chr = qemu_char_get_next_serial(); @@ -495,8 +489,17 @@ static int cadence_uart_init(SysBusDevice *dev) qemu_chr_add_handlers(s->chr, uart_can_receive, uart_receive, uart_event, s); } +} - return 0; +static void cadence_uart_init(Object *obj) +{ + UartState *s = CADENCE_UART(obj); + + memory_region_init_io(&s->iomem, obj, &uart_ops, s, "uart", 0x1000); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); + + s->char_tx_time = (get_ticks_per_sec() / 9600) * 10; } static int cadence_uart_post_load(void *opaque, int version_id) @@ -528,9 +531,8 @@ static const VMStateDescription vmstate_cadence_uart = { static void cadence_uart_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); - sdc->init = cadence_uart_init; + dc->realize = cadence_uart_realize; dc->vmsd = &vmstate_cadence_uart; dc->reset = cadence_uart_reset; } @@ -539,6 +541,7 @@ static const TypeInfo cadence_uart_info = { .name = TYPE_CADENCE_UART, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(UartState), + .instance_init = cadence_uart_init, .class_init = cadence_uart_class_init, };