diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2011-09-01 13:56:37 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2011-09-07 09:58:26 +0200 |
commit | 891fb2cd4592b6fe76106a69e0ca40efbf82726a (patch) | |
tree | 9f7c75abb2c3de0e1f856cdd4179518f1603b04b /hw/usb-hub.c | |
parent | 7755260f015dcbb8fa47bcc6f1e2ca317b2205aa (diff) |
usb: claim port at device initialization time.
This patch makes qemu assign a port when creating the device, not when
attaching it. For most usb devices this isn't a noticable difference
because they are in attached state all the time.
The change affects usb-host devices which live in detached state while
the real device is unplugged from the host. They have a fixed port
assigned all the time now instead of getting grabbing one on attach and
releasing it at detach, i.e. they stop floating around at the usb bus.
The change also allows to simplify usb-hub. It doesn't need the
handle_attach() callback any more to configure the downstream ports.
This can be done at device initialitation time now. The changed
initialization order (first grab upstream port, then register downstream
ports) also fixes some icky corner cases. For example it is not possible
any more to plug the hub into one of its own downstream ports.
The usb host adapters must care too. USBPort->dev being non-NULL
doesn't imply any more the device is in attached state. The host
adapters must additionally check the USBPort->dev->attached flag.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb-hub.c')
-rw-r--r-- | hw/usb-hub.c | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/hw/usb-hub.c b/hw/usb-hub.c index c49c547d0c..286e3ad85d 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -213,16 +213,6 @@ static void usb_hub_complete(USBPort *port, USBPacket *packet) usb_packet_complete(&s->dev, packet); } -static void usb_hub_handle_attach(USBDevice *dev) -{ - USBHubState *s = DO_UPCAST(USBHubState, dev, dev); - int i; - - for (i = 0; i < NUM_PORTS; i++) { - usb_port_location(&s->ports[i].port, dev->port, i+1); - } -} - static void usb_hub_handle_reset(USBDevice *dev) { /* XXX: do it */ @@ -499,6 +489,7 @@ static int usb_hub_initfn(USBDevice *dev) usb_register_port(usb_bus_from_device(dev), &port->port, s, i, &usb_hub_port_ops, USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); + usb_port_location(&port->port, dev->port, i+1); port->wPortStatus = PORT_STAT_POWER; port->wPortChange = 0; } @@ -537,7 +528,6 @@ static struct USBDeviceInfo hub_info = { .usb_desc = &desc_hub, .init = usb_hub_initfn, .handle_packet = usb_hub_handle_packet, - .handle_attach = usb_hub_handle_attach, .handle_reset = usb_hub_handle_reset, .handle_control = usb_hub_handle_control, .handle_data = usb_hub_handle_data, |