mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
usb: rework attach/detach workflow
Add separate detach callback to USBPortOps, split uhci/ohci/musb/usbhub attach functions into two. Move common code to the usb_attach() function, only the hardware-specific bits remain in the attach/detach callbacks. Keep track of the port it is attached to for each usb device. [ v3: fix tyops in usb-musb.c ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
0d86d2bebb
commit
618c169b57
6 changed files with 124 additions and 135 deletions
20
hw/usb.c
20
hw/usb.c
|
@ -28,7 +28,25 @@
|
|||
|
||||
void usb_attach(USBPort *port, USBDevice *dev)
|
||||
{
|
||||
port->ops->attach(port, dev);
|
||||
if (dev != NULL) {
|
||||
/* attach */
|
||||
if (port->dev) {
|
||||
usb_attach(port, NULL);
|
||||
}
|
||||
dev->port = port;
|
||||
port->dev = dev;
|
||||
port->ops->attach(port);
|
||||
usb_send_msg(dev, USB_MSG_ATTACH);
|
||||
} else {
|
||||
/* detach */
|
||||
dev = port->dev;
|
||||
port->ops->detach(port);
|
||||
if (dev) {
|
||||
usb_send_msg(dev, USB_MSG_DETACH);
|
||||
dev->port = NULL;
|
||||
port->dev = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue