提交 638ac2d8 编写于 作者: G Gerd Hoffmann

usb-hub: add usb_hub_port_update()

Helper function to update port status bits which depends on the
connected device.  We need the same logic for device attach and
port reset, so factor it out.
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190524070310.4952-5-kraxel@redhat.com
上级 868a4203
......@@ -188,18 +188,28 @@ static bool usb_hub_port_clear(USBHubPort *port, uint16_t status)
return usb_hub_port_change(port, status);
}
static void usb_hub_attach(USBPort *port1)
static bool usb_hub_port_update(USBHubPort *port)
{
USBHubState *s = port1->opaque;
USBHubPort *port = &s->ports[port1->index];
bool notify = false;
trace_usb_hub_attach(s->dev.addr, port1->index + 1);
usb_hub_port_set(port, PORT_STAT_CONNECTION);
if (port->port.dev && port->port.dev->attached) {
notify = usb_hub_port_set(port, PORT_STAT_CONNECTION);
if (port->port.dev->speed == USB_SPEED_LOW) {
usb_hub_port_set(port, PORT_STAT_LOW_SPEED);
} else {
usb_hub_port_clear(port, PORT_STAT_LOW_SPEED);
}
}
return notify;
}
static void usb_hub_attach(USBPort *port1)
{
USBHubState *s = port1->opaque;
USBHubPort *port = &s->ports[port1->index];
trace_usb_hub_attach(s->dev.addr, port1->index + 1);
usb_hub_port_update(port);
usb_wakeup(s->intr, 0);
}
......@@ -287,12 +297,7 @@ static void usb_hub_handle_reset(USBDevice *dev)
port->wPortStatus = 0;
port->wPortChange = 0;
usb_hub_port_set(port, PORT_STAT_POWER);
if (port->port.dev && port->port.dev->attached) {
usb_hub_port_set(port, PORT_STAT_CONNECTION);
if (port->port.dev->speed == USB_SPEED_LOW) {
usb_hub_port_set(port, PORT_STAT_LOW_SPEED);
}
}
usb_hub_port_update(port);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册