From patchwork Fri May 13 03:46:59 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: 9087841 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2C4C69F372 for ; Fri, 13 May 2016 04:05:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 850EA201C7 for ; Fri, 13 May 2016 04:05:46 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id D5E3E20148 for ; Fri, 13 May 2016 04:05:45 +0000 (UTC) Received: from localhost ([::1]:60857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b14MC-00040b-Mg for patchwork-qemu-devel@patchwork.kernel.org; Fri, 13 May 2016 00:05:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b14Lu-0003sL-VS for qemu-devel@nongnu.org; Fri, 13 May 2016 00:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b14Lq-0008Sa-Ka for qemu-devel@nongnu.org; Fri, 13 May 2016 00:05:25 -0400 Received: from mproxygzc4.163.com ([218.107.63.212]:34000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b14Lp-0008S6-Aq for qemu-devel@nongnu.org; Fri, 13 May 2016 00:05:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=a9+Upsuyq4APqh1r7A lpueiSBQHI6t/FhVbs7ycqKXo=; b=fGBsg9qyRQfAShnsWxw6CXB3IwPW7eyT4u smeE2vzRu7jQJCJYwDR9Wo/1Qhp8S/mOPc0Zp3fefwZp6Dfc3atkMq/r6fPjBjSY TW/k81JQeJJxHosZsFTh2DUmQ5NU3arU1NQzxgP+TOOR5L0HvD9Jmmb2i4Sy4DKv ym4/dDudA= Received: from localhost.localdomain (unknown [118.187.28.42]) by smtp13 (Coremail) with SMTP id EcCowAD33QZZTjVXOV26CA--.49488S5; Fri, 13 May 2016 11:47:52 +0800 (CST) From: xiaoqiang zhao To: qemu-devel@nongnu.org Date: Fri, 13 May 2016 11:46:59 +0800 Message-Id: <1463111220-30335-4-git-send-email-zxq_yx_007@163.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1463111220-30335-1-git-send-email-zxq_yx_007@163.com> References: <1463111220-30335-1-git-send-email-zxq_yx_007@163.com> X-CM-TRANSID: EcCowAD33QZZTjVXOV26CA--.49488S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cr1rJr48ur4kZr48XryDGFg_yoW8ArWDpF 93uF9xCrW3GanFyrs7ZF45K3WUArn5J3Wrtryxtr1xCrW2kr15Jr1vqrW8ZFyxGrZYya4F qrWDZayDJ3W7Zr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j9sqXUUUUU= X-Originating-IP: [118.187.28.42] X-CM-SenderInfo: 520ts5t0bqili6rwjhhfrp/1tbiTAdoxlSIPEaalAAAsN X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 218.107.63.212 Subject: [Qemu-devel] [PATCH v3 3/4] hw/audio: QOM'ify intel-hda 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: pbonzini@redhat.com, michael@walle.cc, kraxel@redhat.com, afaerber@suse.de Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * use DeviceClass::realize instead of DeviceClass::init Signed-off-by: xiaoqiang zhao --- hw/audio/intel-hda.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 5b1e760..93d7669 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -26,6 +26,7 @@ #include "intel-hda.h" #include "intel-hda-defs.h" #include "sysemu/dma.h" +#include "qapi/error.h" /* --------------------------------------------------------------------- */ /* hda bus */ @@ -50,7 +51,7 @@ void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size, bus->xfer = xfer; } -static int hda_codec_dev_init(DeviceState *qdev) +static void hda_codec_dev_realize(DeviceState *qdev, Error **errp) { HDACodecBus *bus = HDA_BUS(qdev->parent_bus); HDACodecDevice *dev = HDA_CODEC_DEVICE(qdev); @@ -60,10 +61,13 @@ static int hda_codec_dev_init(DeviceState *qdev) dev->cad = bus->next_cad; } if (dev->cad >= 15) { - return -1; + error_setg(errp, "HDA audio codec address is full"); + return; } bus->next_cad = dev->cad + 1; - return cdc->init(dev); + if (cdc->init(dev) != 0) { + error_setg(errp, "HDA audio init failed"); + } } static int hda_codec_dev_exit(DeviceState *qdev) @@ -1298,7 +1302,7 @@ static const TypeInfo intel_hda_info_ich9 = { static void hda_codec_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); - k->init = hda_codec_dev_init; + k->realize = hda_codec_dev_realize; k->exit = hda_codec_dev_exit; set_bit(DEVICE_CATEGORY_SOUND, k->categories); k->bus_type = TYPE_HDA_BUS;