Lines Matching refs:dev
26 do { printf("smbus(%02x): " fmt , dev->i2c.address, ## __VA_ARGS__); } while (0)
28 do { g_autofree char *qom_path = object_get_canonical_path(OBJECT(dev)); \
34 do { g_autofree char *qom_path = object_get_canonical_path(OBJECT(dev)); \
47 static void smbus_do_quick_cmd(SMBusDevice *dev, int recv) in smbus_do_quick_cmd() argument
49 SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev); in smbus_do_quick_cmd()
53 sc->quick_cmd(dev, recv); in smbus_do_quick_cmd()
57 static void smbus_do_write(SMBusDevice *dev) in smbus_do_write() argument
59 SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev); in smbus_do_write()
61 DPRINTF("Command %d len %d\n", dev->data_buf[0], dev->data_len); in smbus_do_write()
63 sc->write_data(dev, dev->data_buf, dev->data_len); in smbus_do_write()
69 SMBusDevice *dev = SMBUS_DEVICE(s); in smbus_i2c_event() local
73 switch (dev->mode) { in smbus_i2c_event()
76 dev->mode = SMBUS_WRITE_DATA; in smbus_i2c_event()
80 BADF("Unexpected send start condition in state %d\n", dev->mode); in smbus_i2c_event()
81 dev->mode = SMBUS_CONFUSED; in smbus_i2c_event()
87 switch (dev->mode) { in smbus_i2c_event()
90 dev->mode = SMBUS_READ_DATA; in smbus_i2c_event()
94 if (dev->data_len == 0) { in smbus_i2c_event()
96 dev->mode = SMBUS_CONFUSED; in smbus_i2c_event()
98 smbus_do_write(dev); in smbus_i2c_event()
100 dev->mode = SMBUS_READ_DATA; in smbus_i2c_event()
105 BADF("Unexpected recv start condition in state %d\n", dev->mode); in smbus_i2c_event()
106 dev->mode = SMBUS_CONFUSED; in smbus_i2c_event()
112 if (dev->data_len == 0) { in smbus_i2c_event()
113 if (dev->mode == SMBUS_WRITE_DATA || dev->mode == SMBUS_READ_DATA) { in smbus_i2c_event()
114 smbus_do_quick_cmd(dev, dev->mode == SMBUS_READ_DATA); in smbus_i2c_event()
117 switch (dev->mode) { in smbus_i2c_event()
119 smbus_do_write(dev); in smbus_i2c_event()
131 dev->mode = SMBUS_IDLE; in smbus_i2c_event()
132 dev->data_len = 0; in smbus_i2c_event()
136 switch (dev->mode) { in smbus_i2c_event()
142 dev->mode = SMBUS_DONE; in smbus_i2c_event()
146 BADF("Unexpected NACK in state %d\n", dev->mode); in smbus_i2c_event()
147 dev->mode = SMBUS_CONFUSED; in smbus_i2c_event()
161 SMBusDevice *dev = SMBUS_DEVICE(s); in smbus_i2c_recv() local
162 SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev); in smbus_i2c_recv()
165 switch (dev->mode) { in smbus_i2c_recv()
168 ret = sc->receive_byte(dev); in smbus_i2c_recv()
174 BADF("Unexpected read in state %d\n", dev->mode); in smbus_i2c_recv()
175 dev->mode = SMBUS_CONFUSED; in smbus_i2c_recv()
184 SMBusDevice *dev = SMBUS_DEVICE(s); in smbus_i2c_send() local
186 switch (dev->mode) { in smbus_i2c_send()
189 if (dev->data_len >= sizeof(dev->data_buf)) { in smbus_i2c_send()
192 dev->data_buf[dev->data_len++] = data; in smbus_i2c_send()
197 BADF("Unexpected write in state %d\n", dev->mode); in smbus_i2c_send()
213 bool smbus_vmstate_needed(SMBusDevice *dev) in smbus_vmstate_needed() argument
215 return dev->mode != SMBUS_IDLE; in smbus_vmstate_needed()