aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/usb.c7
-rw-r--r--hw/usb.h5
2 files changed, 11 insertions, 1 deletions
diff --git a/hw/usb.c b/hw/usb.c
index ba720b4..82a6217 100644
--- 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;
}
diff --git a/hw/usb.h b/hw/usb.h
index 407a114..892ff72 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -194,6 +194,11 @@ struct USBDeviceInfo {
void (*handle_destroy)(USBDevice *dev);
/*
+ * Attach the device
+ */
+ void (*handle_attach)(USBDevice *dev);
+
+ /*
* Reset the device
*/
void (*handle_reset)(USBDevice *dev);