Fix typo
[qemu/mdroth.git] / hw / ssi.c
blobb0bcf97151506cde0901856f2d458816c81da5f7
1 /*
2 * QEMU Synchronous Serial Interface support
4 * Copyright (c) 2009 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licenced under the GNU GPL v2.
8 */
10 #include "ssi.h"
12 struct SSIBus {
13 BusState qbus;
16 static void ssi_slave_init(DeviceState *dev, DeviceInfo *base_info)
18 SSISlaveInfo *info = container_of(base_info, SSISlaveInfo, qdev);
19 SSISlave *s = SSI_SLAVE_FROM_QDEV(dev);
20 SSIBus *bus;
22 bus = FROM_QBUS(SSIBus, qdev_get_parent_bus(dev));
23 if (LIST_FIRST(&bus->qbus.children) != dev
24 || LIST_NEXT(dev, sibling) != NULL) {
25 hw_error("Too many devices on SSI bus");
28 s->info = info;
29 info->init(s);
32 void ssi_register_slave(SSISlaveInfo *info)
34 assert(info->qdev.size >= sizeof(SSISlave));
35 info->qdev.init = ssi_slave_init;
36 info->qdev.bus_type = BUS_TYPE_SSI;
37 qdev_register(&info->qdev);
40 DeviceState *ssi_create_slave(SSIBus *bus, const char *name)
42 DeviceState *dev;
43 dev = qdev_create(&bus->qbus, name);
44 qdev_init(dev);
45 return dev;
48 SSIBus *ssi_create_bus(DeviceState *parent, const char *name)
50 BusState *bus;
51 bus = qbus_create(BUS_TYPE_SSI, sizeof(SSIBus), parent, name);
52 return FROM_QBUS(SSIBus, bus);
55 uint32_t ssi_transfer(SSIBus *bus, uint32_t val)
57 DeviceState *dev;
58 SSISlave *slave;
59 dev = LIST_FIRST(&bus->qbus.children);
60 if (!dev) {
61 return 0;
63 slave = SSI_SLAVE_FROM_QDEV(dev);
64 return slave->info->transfer(slave, val);