usb/ohci: Move cancelling async packet to ohci_stop_endpoints()

This is always done before calling this function so remove duplicated
code and do it within the function at one place.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-Id: <ce766722506bfd7145cccbec750692ff57072280.1643117600.git.balaton@eik.bme.hu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
BALATON Zoltan 2022-01-25 14:33:20 +01:00 committed by Gerd Hoffmann
parent 6e821e5084
commit ae310557f4

View File

@ -369,6 +369,10 @@ void ohci_stop_endpoints(OHCIState *ohci)
USBDevice *dev; USBDevice *dev;
int i, j; int i, j;
if (ohci->async_td) {
usb_cancel_packet(&ohci->usb_packet);
ohci->async_td = 0;
}
for (i = 0; i < ohci->num_ports; i++) { for (i = 0; i < ohci->num_ports; i++) {
dev = ohci->rhport[i].port.dev; dev = ohci->rhport[i].port.dev;
if (dev && dev->attached) { if (dev && dev->attached) {
@ -398,10 +402,6 @@ static void ohci_roothub_reset(OHCIState *ohci)
usb_port_reset(&port->port); usb_port_reset(&port->port);
} }
} }
if (ohci->async_td) {
usb_cancel_packet(&ohci->usb_packet);
ohci->async_td = 0;
}
ohci_stop_endpoints(ohci); ohci_stop_endpoints(ohci);
} }
@ -1277,10 +1277,6 @@ static void ohci_frame_boundary(void *opaque)
/* Cancel all pending packets if either of the lists has been disabled. */ /* Cancel all pending packets if either of the lists has been disabled. */
if (ohci->old_ctl & (~ohci->ctl) & (OHCI_CTL_BLE | OHCI_CTL_CLE)) { if (ohci->old_ctl & (~ohci->ctl) & (OHCI_CTL_BLE | OHCI_CTL_CLE)) {
if (ohci->async_td) {
usb_cancel_packet(&ohci->usb_packet);
ohci->async_td = 0;
}
ohci_stop_endpoints(ohci); ohci_stop_endpoints(ohci);
} }
ohci->old_ctl = ohci->ctl; ohci->old_ctl = ohci->ctl;