]> git.proxmox.com Git - mirror_qemu.git/blobdiff - hw/audio/wm8750.c
target/arm: Move GTimer definitions to new 'gtimer.h' header
[mirror_qemu.git] / hw / audio / wm8750.c
index 601ed04aff49b6bb1454eff48f03be1935b2faea..ec2c4e13743dc7930801a90cf3a1fe5e75c92792 100644 (file)
@@ -13,6 +13,7 @@
 #include "qemu/module.h"
 #include "hw/audio/wm8750.h"
 #include "audio/audio.h"
+#include "qom/object.h"
 
 #define IN_PORT_N      3
 #define OUT_PORT_N     3
@@ -26,9 +27,9 @@ typedef struct {
     int dac_hz;
 } WMRate;
 
-#define WM8750(obj) OBJECT_CHECK(WM8750State, (obj), TYPE_WM8750)
+OBJECT_DECLARE_SIMPLE_TYPE(WM8750State, WM8750)
 
-typedef struct WM8750State {
+struct WM8750State {
     I2CSlave parent_obj;
 
     uint8_t i2c_data[2];
@@ -54,7 +55,7 @@ typedef struct WM8750State {
     const WMRate *rate;
     uint8_t rate_vmstate;
     int adc_hz, dac_hz, ext_adc_hz, ext_dac_hz, master;
-} WM8750State;
+};
 
 /* pow(10.0, -i / 20.0) * 255, i = 0..42 */
 static const uint8_t wm8750_vol_db_table[] = {
@@ -591,7 +592,7 @@ static const VMStateDescription vmstate_wm8750 = {
     .minimum_version_id = 0,
     .pre_save = wm8750_pre_save,
     .post_load = wm8750_post_load,
-    .fields = (VMStateField[]) {
+    .fields = (const VMStateField[]) {
         VMSTATE_UINT8_ARRAY(i2c_data, WM8750State, 2),
         VMSTATE_INT32(i2c_len, WM8750State),
         VMSTATE_INT32(enable, WM8750State),
@@ -623,7 +624,10 @@ static void wm8750_realize(DeviceState *dev, Error **errp)
 {
     WM8750State *s = WM8750(dev);
 
-    AUD_register_card(CODEC, &s->card);
+    if (!AUD_register_card(CODEC, &s->card, errp)) {
+        return;
+    }
+
     wm8750_reset(I2C_SLAVE(s));
 }
 
@@ -717,7 +721,7 @@ static void wm8750_class_init(ObjectClass *klass, void *data)
     sc->recv = wm8750_rx;
     sc->send = wm8750_tx;
     dc->vmsd = &vmstate_wm8750;
-    dc->props = wm8750_properties;
+    device_class_set_props(dc, wm8750_properties);
 }
 
 static const TypeInfo wm8750_info = {