ChangeSet 1.2020.1.129, 2005/03/08 00:41:46-08:00, [EMAIL PROTECTED]

[PATCH] USBcore: implement usb_add_hcd and usb_remove_hcd

This patch contains the changes to the ohci-ppc-soc driver.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/host/ohci-ppc-soc.c |  123 +++++++++-------------------------------
 1 files changed, 29 insertions(+), 94 deletions(-)


diff -Nru a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
--- a/drivers/usb/host/ohci-ppc-soc.c   2005-03-08 16:42:11 -08:00
+++ b/drivers/usb/host/ohci-ppc-soc.c   2005-03-08 16:42:11 -08:00
@@ -16,8 +16,6 @@
 
 #include <asm/usb.h>
 
-static void usb_hcd_ppc_soc_remove(struct usb_hcd *, struct platform_device *);
-
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */
 
@@ -32,11 +30,10 @@
  * Store this function in the HCD's struct pci_driver as probe().
  */
 static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver,
-                         struct usb_hcd **hcd_out,
                          struct platform_device *pdev)
 {
        int retval;
-       struct usb_hcd *hcd = 0;
+       struct usb_hcd *hcd;
        struct ohci_hcd *ohci;
        struct resource *res;
        int irq;
@@ -56,82 +53,46 @@
                pr_debug(__FILE__ ": no reg addr\n");
                return -ENODEV;
        }
-       if (!request_mem_region(res->start, res->end - res->start + 1,
-                                       hcd_name)) {
-               pr_debug(__FILE__ ": request_mem_region failed\n");
-               return -EBUSY;
-       }
 
-       if (pd->start && (retval = pd->start(pdev)))
-               goto err0;
+       hcd = usb_create_hcd(driver, &pdev->dev, "PPC-SOC USB");
+       if (!hcd)
+               return -ENOMEM;
+       hcd->rsrc_start = res->start;
+       hcd->rsrc_len = res->end - res->start + 1;
 
-       hcd = usb_create_hcd(driver);
-       if (!hcd){
-               pr_debug(__FILE__ ": hcd_alloc failed\n");
-               retval = -ENOMEM;
+       if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
+               pr_debug(__FILE__ ": request_mem_region failed\n");
+               retval = -EBUSY;
                goto err1;
        }
 
-       ohci = hcd_to_ohci(hcd);
-
-       ohci->flags |= OHCI_BIG_ENDIAN;
-
-       ohci_hcd_init(ohci);
-
-       hcd->irq = irq;
-       hcd->regs = (struct ohci_regs *) ioremap(res->start,
-                                               res->end - res->start + 1);
+       hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
        if (!hcd->regs) {
                pr_debug(__FILE__ ": ioremap failed\n");
                retval = -ENOMEM;
                goto err2;
        }
 
-       hcd->self.controller = &pdev->dev;
-
-       retval = hcd_buffer_create(hcd);
-       if (retval) {
-               pr_debug(__FILE__ ": pool alloc fail\n");
+       if (pd->start && (retval = pd->start(pdev)))
                goto err3;
-       }
-
-       retval = request_irq(hcd->irq, usb_hcd_irq, SA_INTERRUPT,
-                               hcd_name, hcd);
-       if (retval) {
-               pr_debug(__FILE__ ": request_irq failed, returned %d\n",
-                                                               retval);
-               retval = -EBUSY;
-               goto err4;
-       }
 
-       info("%s (PPC-SOC) at 0x%p, irq %d\n",
-             hcd_name, hcd->regs, hcd->irq);
-
-       hcd->self.bus_name = "PPC-SOC USB";
-
-       usb_register_bus(&hcd->self);
+       ohci = hcd_to_ohci(hcd);
+       ohci->flags |= OHCI_BIG_ENDIAN;
+       ohci_hcd_init(ohci);
 
-       if ((retval = driver->start(hcd)) < 0) {
-               usb_hcd_ppc_soc_remove(hcd, pdev);
+       retval = usb_add_hcd(hcd, irq, SA_INTERRUPT);
+       if (retval == 0)
                return retval;
-       }
 
-       *hcd_out = hcd;
-       return 0;
-
- err4:
-       hcd_buffer_destroy(hcd);
+       pr_debug("Removing PPC-SOC USB Controller\n");
+       if (pd && pd->stop)
+               pd->stop(pdev);
  err3:
        iounmap(hcd->regs);
  err2:
-       dev_set_drvdata(&pdev->dev, NULL);
-       usb_put_hcd(hcd);
+       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  err1:
-       pr_debug("Removing PPC-SOC USB Controller\n");
-       if (pd && pd->stop)
-               pd->stop(pdev);
- err0:
-       release_mem_region(res->start, res->end - res->start + 1);
+       usb_put_hcd(hcd);
        return retval;
 }
 
@@ -149,39 +110,20 @@
  * context, normally "rmmod", "apmd", or something similar.
  *
  */
-static void usb_hcd_ppc_soc_remove(struct usb_hcd *hcd, struct platform_device 
*pdev)
+static void usb_hcd_ppc_soc_remove(struct usb_hcd *hcd,
+               struct platform_device *pdev)
 {
-       struct resource *res;
        struct usb_hcd_platform_data *pd = pdev->dev.platform_data;
 
-       pr_debug(__FILE__ ": remove: %s, state %x\n", hcd->self.bus_name,
-                                                               hcd->state);
-       if (in_interrupt())
-               BUG();
-
-       hcd->state = USB_STATE_QUIESCING;
-
-       pr_debug("%s: roothub graceful disconnect\n", 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);
-
-       iounmap(hcd->regs);
-       kfree(hcd);
+       usb_remove_hcd(hcd);
 
        pr_debug("stopping PPC-SOC USB Controller\n");
-
        if (pd && pd->stop)
                pd->stop(pdev);
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       release_mem_region(res->start, res->end - res->start + 1);
+       iounmap(hcd->regs);
+       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
+       usb_hcd_put(hcd);
 }
 
 static int __devinit
@@ -210,7 +152,7 @@
         * generic hardware linkage
         */
        .irq =                  ohci_irq,
-       .flags =                HCD_USB11,
+       .flags =                HCD_USB11 | HCD_MEMORY,
 
        /*
         * basic lifecycle operations
@@ -245,17 +187,12 @@
 static int ohci_hcd_ppc_soc_drv_probe(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
-       struct usb_hcd *hcd = NULL;
        int ret;
 
        if (usb_disabled())
                return -ENODEV;
 
-       ret = usb_hcd_ppc_soc_probe(&ohci_ppc_soc_hc_driver, &hcd, pdev);
-
-       if (ret == 0)
-               dev_set_drvdata(dev, hcd);
-
+       ret = usb_hcd_ppc_soc_probe(&ohci_ppc_soc_hc_driver, pdev);
        return ret;
 }
 
@@ -265,8 +202,6 @@
        struct usb_hcd *hcd = dev_get_drvdata(dev);
 
        usb_hcd_ppc_soc_remove(hcd, pdev);
-
-       dev_set_drvdata(dev, NULL);
        return 0;
 }
 



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to