From patchwork Fri Jan 6 00:26:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhao xiao qiang X-Patchwork-Id: 9499791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E0D4960236 for ; Fri, 6 Jan 2017 00:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1BFD2848A for ; Fri, 6 Jan 2017 00:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C665028499; Fri, 6 Jan 2017 00:31:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5AFC32848A for ; Fri, 6 Jan 2017 00:31:35 +0000 (UTC) Received: from localhost ([::1]:49414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPIRS-0001e9-4g for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Jan 2017 19:31:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPINU-0007Cx-Gr for qemu-devel@nongnu.org; Thu, 05 Jan 2017 19:27:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPINR-0000sL-Eh for qemu-devel@nongnu.org; Thu, 05 Jan 2017 19:27:28 -0500 Received: from m12-14.163.com ([220.181.12.14]:47934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPINQ-0000qC-Q4; Thu, 05 Jan 2017 19:27:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=R2XtO7dF4vfgvWnBRA XXuB3wxUq32Z2HhCB0LurB0/w=; b=WGhoqlIMccFg7B4Rf7Pm4PpkGZDosAu+Yb crDZk3KaAFE1ePQ0DWnyPjRs8UD5ONQXQREPaiLlLUGm8KNifGfX0sZerqNnAtef J3c5eCj9J1V53huz+mE4+BW9xNeHWnvdMxIByj91nz2RNhIFEvphRYs+IdTmT4yb 369F8Tt1A= Received: from localhost.localdomain (unknown [223.104.3.255]) by smtp10 (Coremail) with SMTP id DsCowABHJps65G5Ymg8zGQ--.36662S3; Fri, 06 Jan 2017 08:26:44 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Fri, 6 Jan 2017 08:26:25 +0800 Message-Id: <20170106002628.10343-2-zxq_yx_007@163.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170106002628.10343-1-zxq_yx_007@163.com> References: <20170106002628.10343-1-zxq_yx_007@163.com> X-CM-TRANSID: DsCowABHJps65G5Ymg8zGQ--.36662S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7ArWkZFW8ur4ktr4fJw4xZwb_yoW8uFyrpF yDuF1rur4YyF4DJr43XF1kCr1kCwn7Kr1xtrZrA3sakFn0gFWjvr9Fya93Xrs8trW8Z3W3 X3ykJFyDJF1DAw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jkZ2-UUUUU= X-Originating-IP: [223.104.3.255] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/xtbBEARXxlUL-5+w+gAAsx X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH v2 1/4] hw/gpio: QOM'ify mpc8xxx.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-ppc@nongnu.org, agraf@suse.de, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP * Drop the old SysBus init function and use instance_init * Change mpc8xxx_gpio_reset to a DeviceClass::reset function Signed-off-by: xiaoqiang zhao --- hw/gpio/mpc8xxx.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hw/gpio/mpc8xxx.c b/hw/gpio/mpc8xxx.c index d149719469..e12edb4933 100644 --- a/hw/gpio/mpc8xxx.c +++ b/hw/gpio/mpc8xxx.c @@ -143,8 +143,10 @@ static void mpc8xxx_gpio_write(void *opaque, hwaddr offset, mpc8xxx_gpio_update(s); } -static void mpc8xxx_gpio_reset(MPC8XXXGPIOState *s) +static void mpc8xxx_gpio_reset(DeviceState *dev) { + MPC8XXXGPIOState *s = MPC8XXX_GPIO(dev); + s->dir = 0; s->odr = 0; s->dat = 0; @@ -180,33 +182,33 @@ static const MemoryRegionOps mpc8xxx_gpio_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static int mpc8xxx_gpio_initfn(SysBusDevice *sbd) +static void mpc8xxx_gpio_initfn(Object *obj) { - DeviceState *dev = DEVICE(sbd); - MPC8XXXGPIOState *s = MPC8XXX_GPIO(dev); + DeviceState *dev = DEVICE(obj); + MPC8XXXGPIOState *s = MPC8XXX_GPIO(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - memory_region_init_io(&s->iomem, OBJECT(s), &mpc8xxx_gpio_ops, s, "mpc8xxx_gpio", 0x1000); + memory_region_init_io(&s->iomem, obj, &mpc8xxx_gpio_ops, + s, "mpc8xxx_gpio", 0x1000); sysbus_init_mmio(sbd, &s->iomem); sysbus_init_irq(sbd, &s->irq); qdev_init_gpio_in(dev, mpc8xxx_gpio_set_irq, 32); qdev_init_gpio_out(dev, s->out, 32); - mpc8xxx_gpio_reset(s); - return 0; } static void mpc8xxx_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = mpc8xxx_gpio_initfn; dc->vmsd = &vmstate_mpc8xxx_gpio; + dc->reset = mpc8xxx_gpio_reset; } static const TypeInfo mpc8xxx_gpio_info = { .name = TYPE_MPC8XXX_GPIO, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(MPC8XXXGPIOState), + .instance_init = mpc8xxx_gpio_initfn, .class_init = mpc8xxx_gpio_class_init, };