This patch enables to call platform specific power callback function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto...@renesas.com>
---
 drivers/usb/host/ohci-platform.c |   29 ++++++++++++++++++++++++++---
 include/linux/usb/ohci_pdriver.h |    2 ++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 670c705..03da469 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -83,10 +83,11 @@ static int __devinit ohci_platform_probe(struct 
platform_device *dev)
 {
        struct usb_hcd *hcd;
        struct resource *res_mem;
+       struct usb_ohci_pdata *pdata = dev->dev.platform_data;
        int irq;
        int err = -ENOMEM;
 
-       BUG_ON(!dev->dev.platform_data);
+       BUG_ON(!pdata);
 
        if (usb_disabled())
                return -ENODEV;
@@ -103,10 +104,15 @@ static int __devinit ohci_platform_probe(struct 
platform_device *dev)
                return -ENXIO;
        }
 
+       if (pdata->power) /* power enable */
+               pdata->power(&dev->dev, 0, 1);
+
        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);
@@ -134,12 +140,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) /* power disable */
+               pdata->power(&dev->dev, 0, 0);
+
        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);
@@ -147,6 +158,9 @@ static int __devexit ohci_platform_remove(struct 
platform_device *dev)
        usb_put_hcd(hcd);
        platform_set_drvdata(dev, NULL);
 
+       if (pdata->power) /* power disable */
+               pdata->power(&dev->dev, 0, 0);
+
        return 0;
 }
 
@@ -154,12 +168,21 @@ 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;
+
+       if (pdata->power) /* power disable */
+               pdata->power(dev, 1, 0);
+
        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;
+
+       if (pdata->power) /* power enable */
+               pdata->power(dev, 1, 1);
 
        ohci_finish_controller_resume(hcd);
        return 0;
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h
index 2808f2a..6cf973a 100644
--- a/include/linux/usb/ohci_pdriver.h
+++ b/include/linux/usb/ohci_pdriver.h
@@ -33,6 +33,8 @@ struct usb_ohci_pdata {
        unsigned        big_endian_desc:1;
        unsigned        big_endian_mmio:1;
        unsigned        no_big_frame_no:1;
+
+       void (*power)(struct device *dev, int in_pm, int enable);
 };
 
 #endif /* __USB_CORE_OHCI_PDRIVER_H */
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to