summaryrefslogtreecommitdiff
path: root/payloads
diff options
context:
space:
mode:
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/drivers/usb/ohci_rh.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/payloads/libpayload/drivers/usb/ohci_rh.c b/payloads/libpayload/drivers/usb/ohci_rh.c
index 9de2b981f8..aa44f338ec 100644
--- a/payloads/libpayload/drivers/usb/ohci_rh.c
+++ b/payloads/libpayload/drivers/usb/ohci_rh.c
@@ -128,15 +128,14 @@ ohci_rh_scanport (usbdev_t *dev, int port)
static int
ohci_rh_report_port_changes (usbdev_t *dev)
{
- int i;
+ ohci_t *const ohcic = OHCI_INST (dev->controller);
- if (!(OHCI_INST (dev->controller)->opreg->HcInterruptStatus & RootHubStatusChange)) return -1;
- OHCI_INST (dev->controller)->opreg->HcInterruptStatus = RootHubStatusChange;
- usb_debug("port change\n");
+ int i;
for (i = 0; i < RH_INST(dev)->numports; i++) {
// maybe detach+attach happened between two scans?
- if (OHCI_INST (dev->controller)->opreg->HcRhPortStatus[i] & ConnectStatusChange) {
+ if (ohcic->opreg->HcRhPortStatus[i] & ConnectStatusChange) {
+ ohcic->opreg->HcRhPortStatus[i] = ConnectStatusChange;
usb_debug("attachment change on port %d\n", i);
return i;
}
@@ -158,7 +157,17 @@ ohci_rh_destroy (usbdev_t *dev)
static void
ohci_rh_poll (usbdev_t *dev)
{
+ ohci_t *const ohcic = OHCI_INST (dev->controller);
+
int port;
+
+ /* Check if anything changed. */
+ if (!(ohcic->opreg->HcInterruptStatus & RootHubStatusChange))
+ return;
+ ohcic->opreg->HcInterruptStatus = RootHubStatusChange;
+ usb_debug("root hub status change\n");
+
+ /* Scan ports with changed connection status. */
while ((port = ohci_rh_report_port_changes (dev)) != -1)
ohci_rh_scanport (dev, port);
}