aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-bt.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-08-31 14:23:59 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-09-09 14:55:17 -0500
commit806b60248218bd5f74a8b070f5a99a864e8e51c6 (patch)
treeef5ebf0b2f0aebb33cfbb6a3c7b58de8092a079c /hw/usb-bt.c
parent755700885432a8692c53549dd177d7d52d5cdd17 (diff)
qdev/usb: add usb bus support to qdev, convert drivers.
* Add USBBus. * Add USBDeviceInfo, move device callbacks here. * Add usb-qdev helper functions. * Switch drivers to qdev. TODO: * make the rest of qemu aware of usb busses and kill the FIXMEs added by this patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/usb-bt.c')
-rw-r--r--hw/usb-bt.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/hw/usb-bt.c b/hw/usb-bt.c
index 72245f64b5..4c60d424fd 100644
--- a/hw/usb-bt.c
+++ b/hw/usb-bt.c
@@ -617,22 +617,23 @@ static void usb_bt_handle_destroy(USBDevice *dev)
qemu_free(s);
}
+static int usb_bt_initfn(USBDevice *dev)
+{
+ struct USBBtState *s = DO_UPCAST(struct USBBtState, dev, dev);
+ s->dev.speed = USB_SPEED_HIGH;
+ return 0;
+}
+
USBDevice *usb_bt_init(HCIInfo *hci)
{
+ USBDevice *dev;
struct USBBtState *s;
if (!hci)
return NULL;
- s = qemu_mallocz(sizeof(struct USBBtState));
+ dev = usb_create_simple(NULL /* FIXME */, "QEMU BT dongle");
+ s = DO_UPCAST(struct USBBtState, dev, dev);
s->dev.opaque = s;
- s->dev.speed = USB_SPEED_HIGH;
- s->dev.handle_packet = usb_generic_handle_packet;
- pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU BT dongle");
-
- s->dev.handle_reset = usb_bt_handle_reset;
- s->dev.handle_control = usb_bt_handle_control;
- s->dev.handle_data = usb_bt_handle_data;
- s->dev.handle_destroy = usb_bt_handle_destroy;
s->hci = hci;
s->hci->opaque = s;
@@ -641,5 +642,22 @@ USBDevice *usb_bt_init(HCIInfo *hci)
usb_bt_handle_reset(&s->dev);
- return &s->dev;
+ return dev;
+}
+
+static struct USBDeviceInfo bt_info = {
+ .qdev.name = "QEMU BT dongle",
+ .qdev.size = sizeof(struct USBBtState),
+ .init = usb_bt_initfn,
+ .handle_packet = usb_generic_handle_packet,
+ .handle_reset = usb_bt_handle_reset,
+ .handle_control = usb_bt_handle_control,
+ .handle_data = usb_bt_handle_data,
+ .handle_destroy = usb_bt_handle_destroy,
+};
+
+static void usb_bt_register_devices(void)
+{
+ usb_qdev_register(&bt_info);
}
+device_init(usb_bt_register_devices)