vserver 2.0 rc7
[linux-2.6.git] / drivers / usb / host / ohci-sa1111.c
index eb656a7..814d2be 100644 (file)
@@ -105,34 +105,8 @@ static void dump_hci_status(struct usb_hcd *hcd, const char *label)
 }
 #endif
 
-static irqreturn_t usb_hcd_sa1111_hcim_irq (int irq, void *__hcd, struct pt_regs * r)
-{
-       struct usb_hcd *hcd = __hcd;
-//     unsigned long status = sa1111_readl(hcd->regs + SA1111_USB_STATUS);
-
-       //dump_hci_status(hcd, "irq");
-
-#if 0
-       /* may work better this way -- need to investigate further */
-       if (status & USB_STATUS_NIRQHCIM) {
-               //dbg ("not normal HC interrupt; ignoring");
-               return;
-       }
-#endif
-
-       usb_hcd_irq(irq, hcd, r);
-
-       /*
-        * SA1111 seems to re-assert its interrupt immediately
-        * after processing an interrupt.  Always return IRQ_HANDLED.
-        */
-       return IRQ_HANDLED;
-}
-
 /*-------------------------------------------------------------------------*/
 
-void usb_hcd_sa1111_remove (struct usb_hcd *, struct sa1111_dev *);
-
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */
 
@@ -148,68 +122,35 @@ void usb_hcd_sa1111_remove (struct usb_hcd *, struct sa1111_dev *);
  * Store this function in the HCD's struct pci_driver as probe().
  */
 int usb_hcd_sa1111_probe (const struct hc_driver *driver,
-                         struct usb_hcd **hcd_out,
                          struct sa1111_dev *dev)
 {
+       struct usb_hcd *hcd;
        int retval;
-       struct usb_hcd *hcd = 0;
 
-       if (!request_mem_region(dev->res.start, 
-                               dev->res.end - dev->res.start + 1, hcd_name)) {
-               dbg("request_mem_region failed");
-               return -EBUSY;
-       }
-
-       sa1111_start_hc(dev);
+       hcd = usb_create_hcd (driver, &dev->dev, "sa1111");
+       if (!hcd)
+               return -ENOMEM;
+       hcd->rsrc_start = dev->res.start;
+       hcd->rsrc_len = dev->res.end - dev->res.start + 1;
 
-       hcd = usb_create_hcd (driver);
-       if (hcd == NULL){
-               dbg ("hcd_alloc failed");
-               retval = -ENOMEM;
+       if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
+               dbg("request_mem_region failed");
+               retval = -EBUSY;
                goto err1;
        }
-       ohci_hcd_init(hcd_to_ohci(hcd));
-
-       hcd->irq = dev->irq[1];
        hcd->regs = dev->mapbase;
-       hcd->self.controller = &dev->dev;
-
-       retval = hcd_buffer_create (hcd);
-       if (retval != 0) {
-               dbg ("pool alloc fail");
-               goto err2;
-       }
-
-       retval = request_irq (hcd->irq, usb_hcd_sa1111_hcim_irq, SA_INTERRUPT,
-                             hcd->driver->description, hcd);
-       if (retval != 0) {
-               dbg("request_irq failed");
-               retval = -EBUSY;
-               goto err3;
-       }
 
-       info ("%s (SA-1111) at 0x%p, irq %d\n",
-               hcd->driver->description, hcd->regs, hcd->irq);
-
-       hcd->self.bus_name = "sa1111";
-       usb_register_bus (&hcd->self);
+       sa1111_start_hc(dev);
+       ohci_hcd_init(hcd_to_ohci(hcd));
 
-       if ((retval = driver->start (hcd)) < 0) 
-       {
-               usb_hcd_sa1111_remove(hcd, dev);
+       retval = usb_add_hcd(hcd, dev->irq[1], SA_INTERRUPT);
+       if (retval == 0)
                return retval;
-       }
 
-       *hcd_out = hcd;
-       return 0;
-
- err3:
-       hcd_buffer_destroy (hcd);
- err2:
-       usb_put_hcd(hcd);
- err1:
        sa1111_stop_hc(dev);
-       release_mem_region(dev->res.start, dev->res.end - dev->res.start + 1);
+       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
+ err1:
+       usb_put_hcd(hcd);
        return retval;
 }
 
@@ -229,26 +170,10 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver,
  */
 void usb_hcd_sa1111_remove (struct usb_hcd *hcd, struct sa1111_dev *dev)
 {
-       info ("remove: %s, state %x", hcd->self.bus_name, hcd->state);
-
-       if (in_interrupt ())
-               BUG ();
-
-       hcd->state = USB_STATE_QUIESCING;
-
-       dbg ("%s: roothub graceful disconnect", hcd->self.bus_name);
-       usb_disconnect (&hcd->self.root_hub);
-
-       hcd->driver->stop (hcd);
-       hcd->state = USB_STATE_HALT;
-
-       free_irq (hcd->irq, hcd);
-       hcd_buffer_destroy (hcd);
-
-       usb_deregister_bus (&hcd->self);
-
+       usb_remove_hcd(hcd);
        sa1111_stop_hc(dev);
-       release_mem_region(dev->res.start, dev->res.end - dev->res.start + 1);
+       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
+       usb_put_hcd(hcd);
 }
 
 /*-------------------------------------------------------------------------*/
@@ -281,7 +206,7 @@ static const struct hc_driver ohci_sa1111_hc_driver = {
         * generic hardware linkage
         */
        .irq =                  ohci_irq,
-       .flags =                HCD_USB11,
+       .flags =                HCD_USB11 | HCD_MEMORY,
 
        /*
         * basic lifecycle operations
@@ -293,11 +218,6 @@ static const struct hc_driver ohci_sa1111_hc_driver = {
 #endif
        .stop =                 ohci_stop,
 
-       /*
-        * memory lifecycle (except per-request)
-        */
-       .hcd_alloc =            ohci_hcd_alloc,
-
        /*
         * managing i/o requests and associated device resources
         */
@@ -325,17 +245,12 @@ static const struct hc_driver ohci_sa1111_hc_driver = {
 
 static int ohci_hcd_sa1111_drv_probe(struct sa1111_dev *dev)
 {
-       struct usb_hcd *hcd = NULL;
        int ret;
 
        if (usb_disabled())
                return -ENODEV;
 
-       ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, &hcd, dev);
-
-       if (ret == 0)
-               sa1111_set_drvdata(dev, hcd);
-
+       ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, dev);
        return ret;
 }
 
@@ -344,9 +259,6 @@ static int ohci_hcd_sa1111_drv_remove(struct sa1111_dev *dev)
        struct usb_hcd *hcd = sa1111_get_drvdata(dev);
 
        usb_hcd_sa1111_remove(hcd, dev);
-
-       sa1111_set_drvdata(dev, NULL);
-
        return 0;
 }