wm8750: QOM'ify
Replace usages of FROM_I2C_SLAVE() and direct parent field accesses with QOM cast macro. Rename parent field. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
a5f96db7e8
commit
bc229b0f90
@ -23,8 +23,12 @@ typedef struct {
|
|||||||
int dac_hz;
|
int dac_hz;
|
||||||
} WMRate;
|
} WMRate;
|
||||||
|
|
||||||
typedef struct {
|
#define TYPE_WM8750 "wm8750"
|
||||||
I2CSlave i2c;
|
#define WM8750(obj) OBJECT_CHECK(WM8750State, (obj), TYPE_WM8750)
|
||||||
|
|
||||||
|
typedef struct WM8750State {
|
||||||
|
I2CSlave parent_obj;
|
||||||
|
|
||||||
uint8_t i2c_data[2];
|
uint8_t i2c_data[2];
|
||||||
int i2c_len;
|
int i2c_len;
|
||||||
QEMUSoundCard card;
|
QEMUSoundCard card;
|
||||||
@ -256,7 +260,8 @@ static void wm8750_clk_update(WM8750State *s, int ext)
|
|||||||
|
|
||||||
static void wm8750_reset(I2CSlave *i2c)
|
static void wm8750_reset(I2CSlave *i2c)
|
||||||
{
|
{
|
||||||
WM8750State *s = (WM8750State *) i2c;
|
WM8750State *s = WM8750(i2c);
|
||||||
|
|
||||||
s->rate = &wm_rate_table[0];
|
s->rate = &wm_rate_table[0];
|
||||||
s->enable = 0;
|
s->enable = 0;
|
||||||
wm8750_clk_update(s, 1);
|
wm8750_clk_update(s, 1);
|
||||||
@ -299,7 +304,7 @@ static void wm8750_reset(I2CSlave *i2c)
|
|||||||
|
|
||||||
static void wm8750_event(I2CSlave *i2c, enum i2c_event event)
|
static void wm8750_event(I2CSlave *i2c, enum i2c_event event)
|
||||||
{
|
{
|
||||||
WM8750State *s = (WM8750State *) i2c;
|
WM8750State *s = WM8750(i2c);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case I2C_START_SEND:
|
case I2C_START_SEND:
|
||||||
@ -356,7 +361,7 @@ static void wm8750_event(I2CSlave *i2c, enum i2c_event event)
|
|||||||
|
|
||||||
static int wm8750_tx(I2CSlave *i2c, uint8_t data)
|
static int wm8750_tx(I2CSlave *i2c, uint8_t data)
|
||||||
{
|
{
|
||||||
WM8750State *s = (WM8750State *) i2c;
|
WM8750State *s = WM8750(i2c);
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
|
|
||||||
@ -542,7 +547,7 @@ static int wm8750_tx(I2CSlave *i2c, uint8_t data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM8750_RESET: /* Reset */
|
case WM8750_RESET: /* Reset */
|
||||||
wm8750_reset(&s->i2c);
|
wm8750_reset(I2C_SLAVE(s));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -604,17 +609,17 @@ static const VMStateDescription vmstate_wm8750 = {
|
|||||||
VMSTATE_UINT8(format, WM8750State),
|
VMSTATE_UINT8(format, WM8750State),
|
||||||
VMSTATE_UINT8(power, WM8750State),
|
VMSTATE_UINT8(power, WM8750State),
|
||||||
VMSTATE_UINT8(rate_vmstate, WM8750State),
|
VMSTATE_UINT8(rate_vmstate, WM8750State),
|
||||||
VMSTATE_I2C_SLAVE(i2c, WM8750State),
|
VMSTATE_I2C_SLAVE(parent_obj, WM8750State),
|
||||||
VMSTATE_END_OF_LIST()
|
VMSTATE_END_OF_LIST()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int wm8750_init(I2CSlave *i2c)
|
static int wm8750_init(I2CSlave *i2c)
|
||||||
{
|
{
|
||||||
WM8750State *s = FROM_I2C_SLAVE(WM8750State, i2c);
|
WM8750State *s = WM8750(i2c);
|
||||||
|
|
||||||
AUD_register_card(CODEC, &s->card);
|
AUD_register_card(CODEC, &s->card);
|
||||||
wm8750_reset(&s->i2c);
|
wm8750_reset(I2C_SLAVE(s));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -622,8 +627,9 @@ static int wm8750_init(I2CSlave *i2c)
|
|||||||
#if 0
|
#if 0
|
||||||
static void wm8750_fini(I2CSlave *i2c)
|
static void wm8750_fini(I2CSlave *i2c)
|
||||||
{
|
{
|
||||||
WM8750State *s = (WM8750State *) i2c;
|
WM8750State *s = WM8750(i2c);
|
||||||
wm8750_reset(&s->i2c);
|
|
||||||
|
wm8750_reset(I2C_SLAVE(s));
|
||||||
AUD_remove_card(&s->card);
|
AUD_remove_card(&s->card);
|
||||||
g_free(s);
|
g_free(s);
|
||||||
}
|
}
|
||||||
@ -632,7 +638,8 @@ static void wm8750_fini(I2CSlave *i2c)
|
|||||||
void wm8750_data_req_set(DeviceState *dev,
|
void wm8750_data_req_set(DeviceState *dev,
|
||||||
void (*data_req)(void *, int, int), void *opaque)
|
void (*data_req)(void *, int, int), void *opaque)
|
||||||
{
|
{
|
||||||
WM8750State *s = FROM_I2C_SLAVE(WM8750State, I2C_SLAVE(dev));
|
WM8750State *s = WM8750(dev);
|
||||||
|
|
||||||
s->data_req = data_req;
|
s->data_req = data_req;
|
||||||
s->opaque = opaque;
|
s->opaque = opaque;
|
||||||
}
|
}
|
||||||
@ -702,7 +709,7 @@ static void wm8750_class_init(ObjectClass *klass, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo wm8750_info = {
|
static const TypeInfo wm8750_info = {
|
||||||
.name = "wm8750",
|
.name = TYPE_WM8750,
|
||||||
.parent = TYPE_I2C_SLAVE,
|
.parent = TYPE_I2C_SLAVE,
|
||||||
.instance_size = sizeof(WM8750State),
|
.instance_size = sizeof(WM8750State),
|
||||||
.class_init = wm8750_class_init,
|
.class_init = wm8750_class_init,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user