From: Gerd Hoffmann Date: Fri, 3 Dec 2010 16:59:36 +0000 (+0100) Subject: usb: add attach callback X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b6f77fbe230ad3e9ec5c9115a1535137d5e5d04b;p=qemu.git usb: add attach callback 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 --- diff --git a/hw/usb.c b/hw/usb.c index ba720b48e0..82a6217a0b 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 407a11465a..892ff724ff 100644 --- 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 */