Be sure to add "void" to all function prototypes that take no args.
[seabios.git] / src / usb-ohci.c
index 9e07c8953cceb48aae9263724105a4ed3998c33e..6ad1dbc142ea6d7232b18e1b40c0e52d666dc0dd 100644 (file)
@@ -121,12 +121,14 @@ shutdown:
     return 0;
 }
 
-int
-ohci_init(struct usb_s *cntl)
+void
+ohci_init(void *data)
 {
     if (! CONFIG_USB_OHCI)
-        return 0;
+        return;
+    struct usb_s *cntl = data;
 
+    // XXX - don't call pci_config_XXX from a thread
     cntl->type = USB_TYPE_OHCI;
     u32 baseaddr = pci_config_readl(cntl->bdf, PCI_BASE_ADDRESS_0);
     cntl->ohci.regs = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK);
@@ -150,7 +152,7 @@ ohci_init(struct usb_s *cntl)
     struct ohci_ed *control_ed = malloc_high(sizeof(*control_ed));
     if (!hcca || !control_ed) {
         dprintf(1, "No ram for ohci init\n");
-        return 0;
+        return;
     }
     memset(hcca, 0, sizeof(*hcca));
     memset(control_ed, 0, sizeof(*control_ed));
@@ -164,13 +166,12 @@ ohci_init(struct usb_s *cntl)
     int count = check_ohci_ports(cntl);
     if (! count)
         goto err;
-    return count;
+    return;
 
 err:
     stop_ohci(cntl);
     free(hcca);
     free(control_ed);
-    return 0;
 }
 
 static int
@@ -185,7 +186,7 @@ wait_ed(struct ohci_ed *ed)
             dprintf(1, "Timeout on wait_ed %p\n", ed);
             return -1;
         }
-        cpu_relax();
+        yield();
     }
 }
 
@@ -229,7 +230,8 @@ ohci_control(u32 endp, int dir, const void *cmd, int cmdsize
 
     int ret = wait_ed(ed);
     ed->hwINFO = ED_SKIP;
-    usleep(1); // XXX - in case controller still accessing tds
+    if (ret)
+        usleep(1); // XXX - in case controller still accessing tds
     free(tds);
     return ret;
 }