提交 b2317837 编写于 作者: G Gerd Hoffmann 提交者: Anthony Liguori

switch usb bus to inplace allocation.

Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 ca9c39fa
......@@ -14,16 +14,13 @@ static struct BusInfo usb_bus_info = {
static int next_usb_bus = 0;
static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
USBBus *usb_bus_new(DeviceState *host)
void usb_bus_new(USBBus *bus, DeviceState *host)
{
USBBus *bus;
bus = FROM_QBUS(USBBus, qbus_create(&usb_bus_info, host, NULL));
qbus_create_inplace(&bus->qbus, &usb_bus_info, host, NULL);
bus->busnr = next_usb_bus++;
QTAILQ_INIT(&bus->free);
QTAILQ_INIT(&bus->used);
QTAILQ_INSERT_TAIL(&busses, bus, next);
return bus;
}
USBBus *usb_bus_find(int busnr)
......
......@@ -281,7 +281,7 @@ typedef struct {
struct MUSBState {
qemu_irq *irqs;
USBBus *bus;
USBBus bus;
USBPort port;
int idx;
......@@ -331,8 +331,8 @@ struct MUSBState {
s->ep[i].epnum = i;
}
s->bus = usb_bus_new(NULL /* FIXME */);
usb_register_port(s->bus, &s->port, s, 0, musb_attach);
usb_bus_new(&s->bus, NULL /* FIXME */);
usb_register_port(&s->bus, &s->port, s, 0, musb_attach);
return s;
}
......
......@@ -65,7 +65,7 @@ enum ohci_type {
};
typedef struct {
USBBus *bus;
USBBus bus;
qemu_irq irq;
enum ohci_type type;
int mem;
......@@ -1690,10 +1690,10 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
ohci->irq = irq;
ohci->type = type;
ohci->bus = usb_bus_new(dev);
usb_bus_new(&ohci->bus, dev);
ohci->num_ports = num_ports;
for (i = 0; i < num_ports; i++) {
usb_register_port(ohci->bus, &ohci->rhport[i].port, ohci, i, ohci_attach);
usb_register_port(&ohci->bus, &ohci->rhport[i].port, ohci, i, ohci_attach);
}
ohci->async_td = 0;
......
......@@ -122,7 +122,7 @@ typedef struct UHCIPort {
typedef struct UHCIState {
PCIDevice dev;
USBBus *bus;
USBBus bus;
uint16_t cmd; /* cmd register */
uint16_t status;
uint16_t intr; /* interrupt enable register */
......@@ -1083,9 +1083,9 @@ static int usb_uhci_common_initfn(UHCIState *s)
pci_conf[0x3d] = 4; // interrupt pin 3
pci_conf[0x60] = 0x10; // release number
s->bus = usb_bus_new(&s->dev.qdev);
usb_bus_new(&s->bus, &s->dev.qdev);
for(i = 0; i < NB_PORTS; i++) {
usb_register_port(s->bus, &s->ports[i].port, s, i, uhci_attach);
usb_register_port(&s->bus, &s->ports[i].port, s, i, uhci_attach);
}
s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
......
......@@ -303,7 +303,7 @@ struct USBBus {
QTAILQ_ENTRY(USBBus) next;
};
USBBus *usb_bus_new(DeviceState *host);
void usb_bus_new(USBBus *bus, DeviceState *host);
USBBus *usb_bus_find(int busnr);
void usb_qdev_register(USBDeviceInfo *info);
void usb_qdev_register_many(USBDeviceInfo *info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册