Revision 8d0eb050 hw/i2c.c
b/hw/i2c.c | ||
---|---|---|
26 | 26 |
} |
27 | 27 |
}; |
28 | 28 |
|
29 |
static void i2c_bus_save(QEMUFile *f, void *opaque)
|
|
29 |
static void i2c_bus_pre_save(void *opaque)
|
|
30 | 30 |
{ |
31 |
i2c_bus *bus = (i2c_bus *)opaque; |
|
32 |
bus->saved_address = bus->current_dev ? bus->current_dev->address : -1; |
|
31 |
i2c_bus *bus = opaque; |
|
33 | 32 |
|
34 |
qemu_put_8s(f, &bus->saved_address);
|
|
33 |
bus->saved_address = bus->current_dev ? bus->current_dev->address : -1;
|
|
35 | 34 |
} |
36 | 35 |
|
37 |
static int i2c_bus_load(QEMUFile *f, void *opaque, int version_id)
|
|
36 |
static int i2c_bus_post_load(void *opaque, int version_id)
|
|
38 | 37 |
{ |
39 |
i2c_bus *bus = (i2c_bus *)opaque; |
|
40 |
|
|
41 |
if (version_id != 1) |
|
42 |
return -EINVAL; |
|
38 |
i2c_bus *bus = opaque; |
|
43 | 39 |
|
44 | 40 |
/* The bus is loaded before attached devices, so load and save the |
45 | 41 |
current device id. Devices will check themselves as loaded. */ |
46 |
qemu_get_8s(f, &bus->saved_address); |
|
47 | 42 |
bus->current_dev = NULL; |
48 |
|
|
49 | 43 |
return 0; |
50 | 44 |
} |
51 | 45 |
|
46 |
static const VMStateDescription vmstate_i2c_bus = { |
|
47 |
.name = "i2c_bus", |
|
48 |
.version_id = 1, |
|
49 |
.minimum_version_id = 1, |
|
50 |
.minimum_version_id_old = 1, |
|
51 |
.pre_save = i2c_bus_pre_save, |
|
52 |
.post_load = i2c_bus_post_load, |
|
53 |
.fields = (VMStateField []) { |
|
54 |
VMSTATE_UINT8(saved_address, i2c_bus), |
|
55 |
VMSTATE_END_OF_LIST() |
|
56 |
} |
|
57 |
}; |
|
58 |
|
|
52 | 59 |
/* Create a new I2C bus. */ |
53 | 60 |
i2c_bus *i2c_init_bus(DeviceState *parent, const char *name) |
54 | 61 |
{ |
55 | 62 |
i2c_bus *bus; |
56 | 63 |
|
57 | 64 |
bus = FROM_QBUS(i2c_bus, qbus_create(&i2c_bus_info, parent, name)); |
58 |
register_savevm("i2c_bus", -1, 1, i2c_bus_save, i2c_bus_load, bus);
|
|
65 |
vmstate_register(-1, &vmstate_i2c_bus, bus);
|
|
59 | 66 |
return bus; |
60 | 67 |
} |
61 | 68 |
|
Also available in: Unified diff