From patchwork Thu Aug 13 10:44:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 52366 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id D942722EC6 for ; Thu, 13 Aug 2015 10:52:45 +0000 (UTC) Received: by wicul11 with SMTP id ul11sf15815195wic.1 for ; Thu, 13 Aug 2015 03:52:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=f9CMOd5fpPcQSTZxKjUo4ws8QjYfsGb5Ypd23Bxb/tw=; b=Uv4Lk0SJ399ugiypjSNvk7M2SoVbwisEStvSIHjhQo0QY6Z6vRbB3oc8lPV9axNndf HAJP8KE+Znv7VnuegzELuP8ReCauVnjBQuI8zPsDS9pEskX6GJTyw6/ohw+kzcCWN/3T Um0bHvSdiCgP2VVVWutGXgHhidB0SxTJ2PUzOVNCOHqdV/tzvUz8Z42nJd5cBKOsqX6g cueEgFZW0+wlYvJlq4rH6xd6MNRDyJHJotEVQ9vvk4n3xBRjEZf+yiZ59ObSCSJ8vp4W e1yBZ+qlgJaDhulqVgtIrJ0eAMR0CWPhwwuCJ5pc4zamYc9qXN7+Z4n0DvBRaLiBMetD FSpA== X-Gm-Message-State: ALoCoQkFjZb1ONjNYw3/9580J9s8pRvbZ5gx7XjHsHs40sua7L6xLyN5u0F8urAWoEOwdoZ6JaJn X-Received: by 10.152.27.10 with SMTP id p10mr6034716lag.6.1439463165142; Thu, 13 Aug 2015 03:52:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.131 with SMTP id wq3ls130195lac.106.gmail; Thu, 13 Aug 2015 03:52:44 -0700 (PDT) X-Received: by 10.152.6.231 with SMTP id e7mr10392461laa.78.1439463164846; Thu, 13 Aug 2015 03:52:44 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id cq12si1801941lad.97.2015.08.13.03.52.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2015 03:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lagz9 with SMTP id z9so23875632lag.3 for ; Thu, 13 Aug 2015 03:52:44 -0700 (PDT) X-Received: by 10.112.176.228 with SMTP id cl4mr35977391lbc.106.1439463164698; Thu, 13 Aug 2015 03:52:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp860688lba; Thu, 13 Aug 2015 03:52:42 -0700 (PDT) X-Received: by 10.107.6.65 with SMTP id 62mr33320210iog.93.1439463162401; Thu, 13 Aug 2015 03:52:42 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id kc5si1200056igb.30.2015.08.13.03.52.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Aug 2015 03:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:41694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPq7l-0001Y2-76 for patch@linaro.org; Thu, 13 Aug 2015 06:52:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPq0P-0005TP-7Z for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:45:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPq0M-0005QE-LH for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:45:04 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPq0M-0005DT-CT for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:45:02 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZPq07-00070y-Rf for qemu-devel@nongnu.org; Thu, 13 Aug 2015 11:44:47 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Aug 2015 11:44:29 +0100 Message-Id: <1439462687-26903-10-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1439462687-26903-1-git-send-email-peter.maydell@linaro.org> References: <1439462687-26903-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 09/27] i.MX: Move serial initialization to init/realize of DeviceClass. 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Jean-Christophe Dubois Move constructor to DeviceClass methods * imx_serial_init * imx_serial_realize imx32_serial_properties is renamed to imx_serial_properties. Signed-off-by: Jean-Christophe Dubois Reviewed-by: Peter Crosthwaite Message-id: 6854bd75e2b5af312e04e760587e249dbaff807f.1437080501.git.jcd@tribudubois.net Signed-off-by: Peter Maydell --- hw/char/imx_serial.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c index 1dcb325..f0ed255 100644 --- a/hw/char/imx_serial.c +++ b/hw/char/imx_serial.c @@ -306,16 +306,10 @@ static const struct MemoryRegionOps imx_serial_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int imx_serial_init(SysBusDevice *dev) +static void imx_serial_realize(DeviceState *dev, Error **errp) { IMXSerialState *s = IMX_SERIAL(dev); - - memory_region_init_io(&s->iomem, OBJECT(s), &imx_serial_ops, s, - "imx-serial", 0x1000); - sysbus_init_mmio(dev, &s->iomem); - sysbus_init_irq(dev, &s->irq); - if (s->chr) { qemu_chr_add_handlers(s->chr, imx_can_receive, imx_receive, imx_event, s); @@ -323,8 +317,17 @@ static int imx_serial_init(SysBusDevice *dev) DPRINTF("No char dev for uart at 0x%lx\n", (unsigned long)s->iomem.ram_addr); } +} + +static void imx_serial_init(Object *obj) +{ + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + IMXSerialState *s = IMX_SERIAL(obj); - return 0; + memory_region_init_io(&s->iomem, obj, &imx_serial_ops, s, + TYPE_IMX_SERIAL, 0x1000); + sysbus_init_mmio(sbd, &s->iomem); + sysbus_init_irq(sbd, &s->irq); } void imx_serial_create(int uart, const hwaddr addr, qemu_irq irq) @@ -361,7 +364,7 @@ void imx_serial_create(int uart, const hwaddr addr, qemu_irq irq) } -static Property imx32_serial_properties[] = { +static Property imx_serial_properties[] = { DEFINE_PROP_CHR("chardev", IMXSerialState, chr), DEFINE_PROP_END_OF_LIST(), }; @@ -369,21 +372,21 @@ static Property imx32_serial_properties[] = { static void imx_serial_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = imx_serial_init; + dc->realize = imx_serial_realize; dc->vmsd = &vmstate_imx_serial; dc->reset = imx_serial_reset_at_boot; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); dc->desc = "i.MX series UART"; - dc->props = imx32_serial_properties; + dc->props = imx_serial_properties; } static const TypeInfo imx_serial_info = { - .name = TYPE_IMX_SERIAL, - .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(IMXSerialState), - .class_init = imx_serial_class_init, + .name = TYPE_IMX_SERIAL, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(IMXSerialState), + .instance_init = imx_serial_init, + .class_init = imx_serial_class_init, }; static void imx_serial_register_types(void)