@@ -76,7 +76,7 @@ int i2c_start_transfer(i2c_bus *bus, int address, int recv)
DeviceState *qdev;
i2c_slave *slave = NULL;
- LIST_FOREACH(qdev, &bus->qbus.children, sibling) {
+ TAILQ_FOREACH(qdev, &bus->qbus.children, sibling) {
slave = I2C_SLAVE_FROM_QDEV(qdev);
if (slave->address == address)
break;
@@ -101,7 +101,7 @@ DeviceState *qdev_create(BusState *bus, const char *name)
qdev_prop_set_defaults(dev, dev->info->props);
qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
qdev_prop_set_compat(dev);
- LIST_INSERT_HEAD(&bus->children, dev, sibling);
+ TAILQ_INSERT_TAIL(&bus->children, dev, sibling);
return dev;
}
@@ -214,7 +214,7 @@ void qdev_init(DeviceState *dev)
/* Unlink device from bus and free the structure. */
void qdev_free(DeviceState *dev)
{
- LIST_REMOVE(dev, sibling);
+ TAILQ_REMOVE(&dev->parent_bus->children, dev, sibling);
qemu_free(dev);
}
@@ -300,7 +300,7 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
{
BusState *bus;
- LIST_FOREACH(bus, &dev->child_bus, sibling) {
+ TAILQ_FOREACH(bus, &dev->child_bus, sibling) {
if (strcmp(name, bus->name) == 0) {
return bus;
}
@@ -344,8 +344,8 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
return bus;
}
- LIST_FOREACH(dev, &bus->children, sibling) {
- LIST_FOREACH(child, &dev->child_bus, sibling) {
+ TAILQ_FOREACH(dev, &bus->children, sibling) {
+ TAILQ_FOREACH(child, &dev->child_bus, sibling) {
ret = qbus_find_recursive(child, name, info);
if (ret) {
return ret;
@@ -363,7 +363,7 @@ static void qbus_list_bus(DeviceState *dev, char *dest, int len)
pos += snprintf(dest+pos, len-pos,"child busses at \"%s\":",
dev->id ? dev->id : dev->info->name);
- LIST_FOREACH(child, &dev->child_bus, sibling) {
+ TAILQ_FOREACH(child, &dev->child_bus, sibling) {
pos += snprintf(dest+pos, len-pos, "%s\"%s\"", sep, child->name);
sep = ", ";
}
@@ -377,7 +377,7 @@ static void qbus_list_dev(BusState *bus, char *dest, int len)
pos += snprintf(dest+pos, len-pos, "devices at \"%s\":",
bus->name);
- LIST_FOREACH(dev, &bus->children, sibling) {
+ TAILQ_FOREACH(dev, &bus->children, sibling) {
pos += snprintf(dest+pos, len-pos, "%s\"%s\"",
sep, dev->info->name);
if (dev->id)
@@ -390,7 +390,7 @@ static BusState *qbus_find_bus(DeviceState *dev, char *elem)
{
BusState *child;
- LIST_FOREACH(child, &dev->child_bus, sibling) {
+ TAILQ_FOREACH(child, &dev->child_bus, sibling) {
if (strcmp(child->name, elem) == 0) {
return child;
}
@@ -408,17 +408,17 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem)
* (2) driver name
* (3) driver alias, if present
*/
- LIST_FOREACH(dev, &bus->children, sibling) {
+ TAILQ_FOREACH(dev, &bus->children, sibling) {
if (dev->id && strcmp(dev->id, elem) == 0) {
return dev;
}
}
- LIST_FOREACH(dev, &bus->children, sibling) {
+ TAILQ_FOREACH(dev, &bus->children, sibling) {
if (strcmp(dev->info->name, elem) == 0) {
return dev;
}
}
- LIST_FOREACH(dev, &bus->children, sibling) {
+ TAILQ_FOREACH(dev, &bus->children, sibling) {
if (dev->info->alias && strcmp(dev->info->alias, elem) == 0) {
return dev;
}
@@ -476,7 +476,7 @@ static BusState *qbus_find(const char *path)
fprintf(stderr, "device has no child bus (%s)\n", path);
return NULL;
case 1:
- return LIST_FIRST(&dev->child_bus);
+ return TAILQ_FIRST(&dev->child_bus);
default:
qbus_list_bus(dev, msg, sizeof(msg));
fprintf(stderr, "device has multiple child busses (%s)\n%s\n",
@@ -530,9 +530,9 @@ BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)
bus->name = buf;
}
- LIST_INIT(&bus->children);
+ TAILQ_INIT(&bus->children);
if (parent) {
- LIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
+ TAILQ_INSERT_HEAD(&parent->child_bus, bus, sibling);
parent->num_child_bus++;
}
return bus;
@@ -573,7 +573,7 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
qdev_print_props(mon, dev, dev->parent_bus->info->props, "bus", indent);
if (dev->parent_bus->info->print_dev)
dev->parent_bus->info->print_dev(mon, dev, indent);
- LIST_FOREACH(child, &dev->child_bus, sibling) {
+ TAILQ_FOREACH(child, &dev->child_bus, sibling) {
qbus_print(mon, child, indent);
}
}
@@ -585,7 +585,7 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent)
qdev_printf("bus: %s\n", bus->name);
indent += 2;
qdev_printf("type %s\n", bus->info->name);
- LIST_FOREACH(dev, &bus->children, sibling) {
+ TAILQ_FOREACH(dev, &bus->children, sibling) {
qdev_print(mon, dev, indent);
}
}
@@ -29,10 +29,10 @@ struct DeviceState {
qemu_irq *gpio_out;
int num_gpio_in;
qemu_irq *gpio_in;
- LIST_HEAD(, BusState) child_bus;
+ TAILQ_HEAD(, BusState) child_bus;
int num_child_bus;
NICInfo *nd;
- LIST_ENTRY(DeviceState) sibling;
+ TAILQ_ENTRY(DeviceState) sibling;
};
typedef void (*bus_dev_printfn)(Monitor *mon, DeviceState *dev, int indent);
@@ -47,8 +47,8 @@ struct BusState {
DeviceState *parent;
BusInfo *info;
const char *name;
- LIST_HEAD(, DeviceState) children;
- LIST_ENTRY(BusState) sibling;
+ TAILQ_HEAD(, DeviceState) children;
+ TAILQ_ENTRY(BusState) sibling;
};
struct Property {
@@ -25,8 +25,8 @@ static void ssi_slave_init(DeviceState *dev, DeviceInfo *base_info)
SSIBus *bus;
bus = FROM_QBUS(SSIBus, qdev_get_parent_bus(dev));
- if (LIST_FIRST(&bus->qbus.children) != dev
- || LIST_NEXT(dev, sibling) != NULL) {
+ if (TAILQ_FIRST(&bus->qbus.children) != dev
+ || TAILQ_NEXT(dev, sibling) != NULL) {
hw_error("Too many devices on SSI bus");
}
@@ -61,7 +61,7 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val)
{
DeviceState *dev;
SSISlave *slave;
- dev = LIST_FIRST(&bus->qbus.children);
+ dev = TAILQ_FIRST(&bus->qbus.children);
if (!dev) {
return 0;
}
Tail queues allow to append elements to the tail if the list. That way we can maintain the ordering, i.e. devices/busses created first are also first in the list. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- hw/i2c.c | 2 +- hw/qdev.c | 32 ++++++++++++++++---------------- hw/qdev.h | 8 ++++---- hw/ssi.c | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-)