aboutsummaryrefslogtreecommitdiff
path: root/hw/usb.c
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2011-01-21 17:56:50 +0100
committerAurelien Jarno <aurelien@aurel32.net>2011-01-21 17:56:50 +0100
commitb947c12c0bb217fe09968e652873e0d22b269d68 (patch)
tree1fbb289269c4d28d310391a5bdd4fe667feda1ca /hw/usb.c
parent543c4c94cf235d11315157bab25a24f7d9a48711 (diff)
parentace1318b8ea95efa332fb3e8e159924d4f928753 (diff)
downloadqemu-b947c12c0bb217fe09968e652873e0d22b269d68.zip
qemu-b947c12c0bb217fe09968e652873e0d22b269d68.tar.gz
qemu-b947c12c0bb217fe09968e652873e0d22b269d68.tar.bz2
Merge branch 'usb.4' of git://anongit.freedesktop.org/spice/qemu
* 'usb.4' of git://anongit.freedesktop.org/spice/qemu: (32 commits) usb: zap pdev from usbport usb: rewrite fw path, fix numbering usb: add port property. usb: keep track of physical port address. usb storage: handle long responses usb storage: fix status reporting usb storage: high speed support usb: add device qualifier support usb: add usb_desc_attach usb: add attach callback usb: add speed mask to ports usb: hid: change serial number to "42". usb: hid: remote wakeup support. usb: hub: remote wakeup support. usb: uhci: remote wakeup support. usb: add usb_wakeup() + wakeup callback to port ops usb: rework attach/detach workflow usb: create USBPortOps, move attach there. usb: move remote wakeup handling to common code usb: move USB_REQ_{GET,SET}_CONFIGURATION handling to common code ...
Diffstat (limited to 'hw/usb.c')
-rw-r--r--hw/usb.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/hw/usb.c b/hw/usb.c
index a326bcf..82a6217 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -28,7 +28,32 @@
void usb_attach(USBPort *port, USBDevice *dev)
{
- port->attach(port, dev);
+ if (dev != NULL) {
+ /* attach */
+ if (port->dev) {
+ usb_attach(port, NULL);
+ }
+ dev->port = port;
+ port->dev = dev;
+ port->ops->attach(port);
+ usb_send_msg(dev, USB_MSG_ATTACH);
+ } else {
+ /* detach */
+ dev = port->dev;
+ port->ops->detach(port);
+ if (dev) {
+ usb_send_msg(dev, USB_MSG_DETACH);
+ dev->port = NULL;
+ port->dev = NULL;
+ }
+ }
+}
+
+void usb_wakeup(USBDevice *dev)
+{
+ if (dev->remote_wakeup && dev->port && dev->port->ops->wakeup) {
+ dev->port->ops->wakeup(dev);
+ }
}
/**********************/
@@ -169,6 +194,9 @@ int usb_generic_handle_packet(USBDevice *s, USBPacket *p)
switch(p->pid) {
case USB_MSG_ATTACH:
s->state = USB_STATE_ATTACHED;
+ if (s->info->handle_attach) {
+ s->info->handle_attach(s);
+ }
return 0;
case USB_MSG_DETACH:
@@ -179,7 +207,9 @@ int usb_generic_handle_packet(USBDevice *s, USBPacket *p)
s->remote_wakeup = 0;
s->addr = 0;
s->state = USB_STATE_DEFAULT;
- s->info->handle_reset(s);
+ if (s->info->handle_reset) {
+ s->info->handle_reset(s);
+ }
return 0;
}