]> Git Repo - qemu.git/commitdiff
usb: add attach callback
authorGerd Hoffmann <[email protected]>
Fri, 3 Dec 2010 16:59:36 +0000 (17:59 +0100)
committerGerd Hoffmann <[email protected]>
Tue, 11 Jan 2011 16:15:24 +0000 (17:15 +0100)
Add handle_attach() callback to USBDeviceInfo which is called by the
generic package handler when the device is attached to the usb bus
(i.e. plugged into a port).

Signed-off-by: Gerd Hoffmann <[email protected]>
hw/usb.c
hw/usb.h

index ba720b48e0d333b828fe99475aced3cf1dcae597..82a6217a0b5f94b3d7f83ccc5c43c9608eb8bd1e 100644 (file)
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -194,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:
@@ -204,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;
     }
 
index 407a11465ace5fd1e8e2e95a34f2b25654f6fe9e..892ff724ff97698ead8aeeef948ec7d97f08db38 100644 (file)
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -193,6 +193,11 @@ struct USBDeviceInfo {
      */
     void (*handle_destroy)(USBDevice *dev);
 
+    /*
+     * Attach the device
+     */
+    void (*handle_attach)(USBDevice *dev);
+
     /*
      * Reset the device
      */
This page took 0.025655 seconds and 4 git commands to generate.