drivers/usb/host/ohci-platform.c: fix error return code
[deliverable/linux.git] / drivers / usb / host / ohci-platform.c
index 4c886f938f6cbed4d4b6a606211f63918dc5ffc7..e24ec9f79164afc9e6563a147cb76d4c0f3c96c3 100644 (file)
@@ -107,10 +107,18 @@ static int __devinit ohci_platform_probe(struct platform_device *dev)
                return -ENXIO;
        }
 
+       if (pdata->power_on) {
+               err = pdata->power_on(dev);
+               if (err < 0)
+                       return err;
+       }
+
        hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev,
                        dev_name(&dev->dev));
-       if (!hcd)
-               return -ENOMEM;
+       if (!hcd) {
+               err = -ENOMEM;
+               goto err_power;
+       }
 
        hcd->rsrc_start = res_mem->start;
        hcd->rsrc_len = resource_size(res_mem);
@@ -122,8 +130,10 @@ static int __devinit ohci_platform_probe(struct platform_device *dev)
        }
 
        hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
-       if (!hcd->regs)
+       if (!hcd->regs) {
+               err = -ENOMEM;
                goto err_release_region;
+       }
        err = usb_add_hcd(hcd, irq, IRQF_SHARED);
        if (err)
                goto err_iounmap;
@@ -138,12 +148,17 @@ err_release_region:
        release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
 err_put_hcd:
        usb_put_hcd(hcd);
+err_power:
+       if (pdata->power_off)
+               pdata->power_off(dev);
+
        return err;
 }
 
 static int __devexit ohci_platform_remove(struct platform_device *dev)
 {
        struct usb_hcd *hcd = platform_get_drvdata(dev);
+       struct usb_ohci_pdata *pdata = dev->dev.platform_data;
 
        usb_remove_hcd(hcd);
        iounmap(hcd->regs);
@@ -151,6 +166,9 @@ static int __devexit ohci_platform_remove(struct platform_device *dev)
        usb_put_hcd(hcd);
        platform_set_drvdata(dev, NULL);
 
+       if (pdata->power_off)
+               pdata->power_off(dev);
+
        return 0;
 }
 
@@ -158,12 +176,28 @@ static int __devexit ohci_platform_remove(struct platform_device *dev)
 
 static int ohci_platform_suspend(struct device *dev)
 {
+       struct usb_ohci_pdata *pdata = dev->platform_data;
+       struct platform_device *pdev =
+               container_of(dev, struct platform_device, dev);
+
+       if (pdata->power_suspend)
+               pdata->power_suspend(pdev);
+
        return 0;
 }
 
 static int ohci_platform_resume(struct device *dev)
 {
        struct usb_hcd *hcd = dev_get_drvdata(dev);
+       struct usb_ohci_pdata *pdata = dev->platform_data;
+       struct platform_device *pdev =
+               container_of(dev, struct platform_device, dev);
+
+       if (pdata->power_on) {
+               int err = pdata->power_on(pdev);
+               if (err < 0)
+                       return err;
+       }
 
        ohci_finish_controller_resume(hcd);
        return 0;
This page took 0.024989 seconds and 5 git commands to generate.