From patchwork Tue Jun 7 10:35:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhao xiao qiang X-Patchwork-Id: 9160287 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 3BA3D60467 for ; Tue, 7 Jun 2016 10:52:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2879E27248 for ; Tue, 7 Jun 2016 10:52:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CB8728179; Tue, 7 Jun 2016 10:52:31 +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 ACB2D27248 for ; Tue, 7 Jun 2016 10:52:30 +0000 (UTC) Received: from localhost ([::1]:48472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAEcX-0001iR-DA for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Jun 2016 06:52:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAENG-0005GI-Ir for qemu-devel@nongnu.org; Tue, 07 Jun 2016 06:36:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAENB-0002VT-5n for qemu-devel@nongnu.org; Tue, 07 Jun 2016 06:36:41 -0400 Received: from m12-18.163.com ([220.181.12.18]:51398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAENA-0002Ux-K8; Tue, 07 Jun 2016 06:36:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=Okd+lsxPYpE0MapdvC oikaxYdrJzq0SZ7zgm/s9Ibkw=; b=AOBkev0AwvkG89XRLVEMJh7gZV1j6r4i+s ts0AS79E6pLlWmm8G8tNkrimvrdjmnuCiKGlpXx+DANwoUtEAWdV59Z60sgLCWwR N9nDfQMaf70/oIdzEMdNcdsof6KNyPWqJd5v8kWtuF4MaKIwqk4W1ALNBf80pnA+ SpTpifUnI= Received: from localhost.localdomain (unknown [118.187.28.42]) by smtp14 (Coremail) with SMTP id EsCowECZ5UeKo1ZXnD8LAA--.4292S6; Tue, 07 Jun 2016 18:36:11 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Tue, 7 Jun 2016 18:35:44 +0800 Message-Id: <1465295747-11651-5-git-send-email-zxq_yx_007@163.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1465295747-11651-1-git-send-email-zxq_yx_007@163.com> References: <1465295747-11651-1-git-send-email-zxq_yx_007@163.com> X-CM-TRANSID: EsCowECZ5UeKo1ZXnD8LAA--.4292S6 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw4UuFykWr4fCFyUCF4UArb_yoW5XF1Dpa yfXF1F9r4UtFsxGrZ3Jr17Wr1rAwnak3WxXrW7G3WfK3W8urZ8tF1kJ34avFyDWrZ2k3Wr XrWDJw17ArnrZw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jD5rcUUUUU= X-Originating-IP: [118.187.28.42] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/xtbB0hyBxlUL-PlFKQAAs+ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 220.181.12.18 Subject: [Qemu-devel] [PATCH 14/17] hw/dma: QOM'ify pxa2xx_dma.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: i.mitsyanko@gmail.com, peter.maydell@linaro.org, qemu-arm@nongnu.org, zhaoshenglong@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP split the old SysBus init function into an instance_init and a Device realize function Signed-off-by: xiaoqiang zhao --- hw/dma/pxa2xx_dma.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/hw/dma/pxa2xx_dma.c b/hw/dma/pxa2xx_dma.c index 2306abc..634a432 100644 --- a/hw/dma/pxa2xx_dma.c +++ b/hw/dma/pxa2xx_dma.c @@ -12,6 +12,7 @@ #include "hw/hw.h" #include "hw/arm/pxa.h" #include "hw/sysbus.h" +#include "qapi/error.h" #define PXA255_DMA_NUM_CHANNELS 16 #define PXA27X_DMA_NUM_CHANNELS 32 @@ -450,31 +451,36 @@ static void pxa2xx_dma_request(void *opaque, int req_num, int on) } } -static int pxa2xx_dma_init(SysBusDevice *sbd) +static void pxa2xx_dma_init(Object *obj) +{ + DeviceState *dev = DEVICE(obj); + PXA2xxDMAState *s = PXA2XX_DMA(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + + memset(s->req, 0, sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS); + + qdev_init_gpio_in(dev, pxa2xx_dma_request, PXA2XX_DMA_NUM_REQUESTS); + + memory_region_init_io(&s->iomem, obj, &pxa2xx_dma_ops, s, + "pxa2xx.dma", 0x00010000); + sysbus_init_mmio(sbd, &s->iomem); + sysbus_init_irq(sbd, &s->irq); +} + +static void pxa2xx_dma_realize(DeviceState *dev, Error **errp) { - DeviceState *dev = DEVICE(sbd); PXA2xxDMAState *s = PXA2XX_DMA(dev); int i; if (s->channels <= 0) { - return -1; + error_setg(errp, "channels value invalid"); + return; } s->chan = g_new0(PXA2xxDMAChannel, s->channels); for (i = 0; i < s->channels; i ++) s->chan[i].state = DCSR_STOPINTR; - - memset(s->req, 0, sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS); - - qdev_init_gpio_in(dev, pxa2xx_dma_request, PXA2XX_DMA_NUM_REQUESTS); - - memory_region_init_io(&s->iomem, OBJECT(s), &pxa2xx_dma_ops, s, - "pxa2xx.dma", 0x00010000); - sysbus_init_mmio(sbd, &s->iomem); - sysbus_init_irq(sbd, &s->irq); - - return 0; } DeviceState *pxa27x_dma_init(hwaddr base, qemu_irq irq) @@ -553,18 +559,18 @@ static Property pxa2xx_dma_properties[] = { static void pxa2xx_dma_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = pxa2xx_dma_init; dc->desc = "PXA2xx DMA controller"; dc->vmsd = &vmstate_pxa2xx_dma; dc->props = pxa2xx_dma_properties; + dc->realize = pxa2xx_dma_realize; } static const TypeInfo pxa2xx_dma_info = { .name = TYPE_PXA2XX_DMA, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(PXA2xxDMAState), + .instance_init = pxa2xx_dma_init, .class_init = pxa2xx_dma_class_init, };