aboutsummaryrefslogtreecommitdiff
path: root/hw/audio
diff options
context:
space:
mode:
authorxiaoqiang zhao <zxq_yx_007@163.com>2016-05-13 11:46:59 +0800
committerGerd Hoffmann <kraxel@redhat.com>2016-06-03 11:13:38 +0200
commitbda8d9b8b13c0c54aeab268b9023ccc246a3ee67 (patch)
tree816206dd0a7f13e5130a715567bd37ba109e015c /hw/audio
parente19202af791218068808914a172eaa2717f6c0ea (diff)
hw/audio: QOM'ify intel-hda
* use DeviceClass::realize instead of DeviceClass::init Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com> Message-id: 1463111220-30335-4-git-send-email-zxq_yx_007@163.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/audio')
-rw-r--r--hw/audio/intel-hda.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 5b1e760175..93d7669fb5 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;