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 <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2010-12-03 17:59:36 +01:00
parent 843d4e0c63
commit b6f77fbe23
2 changed files with 11 additions and 1 deletions

View File

@ -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;
if (s->info->handle_reset) {
s->info->handle_reset(s);
}
return 0;
}

View File

@ -193,6 +193,11 @@ struct USBDeviceInfo {
*/
void (*handle_destroy)(USBDevice *dev);
/*
* Attach the device
*/
void (*handle_attach)(USBDevice *dev);
/*
* Reset the device
*/