usb: add usb_wakeup() + wakeup callback to port ops
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 1 Dec 2010 10:32:45 +0000 (11:32 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 11 Jan 2011 16:01:02 +0000 (17:01 +0100)
Add wakeup callback to port ops for remote wakeup handling.
Also add a usb_wakeup() function for devices which want
trigger a remote wakeup.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb.c
hw/usb.h

index 2eda86a58c75467b9cb44d03bf674d02e5b4a150..ba720b48e0d333b828fe99475aced3cf1dcae597 100644 (file)
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -49,6 +49,13 @@ void usb_attach(USBPort *port, USBDevice *dev)
     }
 }
 
+void usb_wakeup(USBDevice *dev)
+{
+    if (dev->remote_wakeup && dev->port && dev->port->ops->wakeup) {
+        dev->port->ops->wakeup(dev);
+    }
+}
+
 /**********************/
 
 /* generic USB device helpers (you are not forced to use them when
index 3744d19be341c69dd9079b9a2cb2e413b6e8deda..250ec71a97aba0d3cd7a951a3e3a4c8140fb6c3c 100644 (file)
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -220,6 +220,7 @@ struct USBDeviceInfo {
 typedef struct USBPortOps {
     void (*attach)(USBPort *port);
     void (*detach)(USBPort *port);
+    void (*wakeup)(USBDevice *dev);
 } USBPortOps;
 
 /* USB port on which a device can be connected */
@@ -275,6 +276,7 @@ static inline void usb_cancel_packet(USBPacket * p)
 }
 
 void usb_attach(USBPort *port, USBDevice *dev);
+void usb_wakeup(USBDevice *dev);
 int usb_generic_handle_packet(USBDevice *s, USBPacket *p);
 int set_usb_string(uint8_t *buf, const char *str);
 void usb_send_msg(USBDevice *dev, int msg);