From: Rong Wang <rong.w...@csr.com>

Chipidea puts ci information to drvdata, but this overwrites the drvdata
placed by EHCI core. EHCI core thinks drvdata is ehci_hcd. We can find this
from codes like ehci-sysfs.c:
static ssize_t show_companion(struct device *dev,
                              struct device_attribute *attr,
                              char *buf)
{
        struct ehci_hcd         *ehci;

        ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
        ...
}

So overwritting drvdata from chipidea driver actually breaks a part of
functionalities of EHCI core.

Since the platform_data would not be accessed after the device is added
to system after the probe process, so it's safe to move to platform_data
here. This fix is not elegant but currently it is the quickest fix.

Signed-off-by: Rong Wang <rong.w...@csr.com>
Signed-off-by: Barry Song <baohua.s...@csr.com>
---
 drivers/usb/chipidea/core.c    |  4 ++--
 drivers/usb/chipidea/host.c    |  1 -
 drivers/usb/chipidea/otg_fsm.c | 14 +++++++-------
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 3ad48e1..94e8d15 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -811,7 +811,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
                }
        }
 
-       platform_set_drvdata(pdev, ci);
+       dev->platform_data = ci;
        ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED,
                        ci->platdata->name, ci);
        if (ret)
@@ -844,7 +844,7 @@ deinit_phy:
 
 static int ci_hdrc_remove(struct platform_device *pdev)
 {
-       struct ci_hdrc *ci = platform_get_drvdata(pdev);
+       struct ci_hdrc *ci = dev_get_platdata(&pdev->dev);
 
        if (ci->supports_runtime_pm) {
                pm_runtime_get_sync(&pdev->dev);
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 7161439..57d0a8b 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -102,7 +102,6 @@ static int host_start(struct ci_hdrc *ci)
        if (!hcd)
                return -ENOMEM;
 
-       dev_set_drvdata(ci->dev, ci);
        hcd->rsrc_start = ci->hw_bank.phys;
        hcd->rsrc_len = ci->hw_bank.size;
        hcd->regs = ci->hw_bank.abs;
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 19d655a..3dc146d 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -36,7 +36,7 @@ get_a_bus_req(struct device *dev, struct device_attribute 
*attr, char *buf)
 {
        char            *next;
        unsigned        size, t;
-       struct ci_hdrc  *ci = dev_get_drvdata(dev);
+       struct ci_hdrc  *ci = dev_get_platdata(dev);
 
        next = buf;
        size = PAGE_SIZE;
@@ -51,7 +51,7 @@ static ssize_t
 set_a_bus_req(struct device *dev, struct device_attribute *attr,
                                        const char *buf, size_t count)
 {
-       struct ci_hdrc *ci = dev_get_drvdata(dev);
+       struct ci_hdrc  *ci = dev_get_platdata(dev);
 
        if (count > 2)
                return -1;
@@ -80,7 +80,7 @@ get_a_bus_drop(struct device *dev, struct device_attribute 
*attr, char *buf)
 {
        char            *next;
        unsigned        size, t;
-       struct ci_hdrc  *ci = dev_get_drvdata(dev);
+       struct ci_hdrc  *ci = dev_get_platdata(dev);
 
        next = buf;
        size = PAGE_SIZE;
@@ -95,7 +95,7 @@ static ssize_t
 set_a_bus_drop(struct device *dev, struct device_attribute *attr,
                                        const char *buf, size_t count)
 {
-       struct ci_hdrc  *ci = dev_get_drvdata(dev);
+       struct ci_hdrc  *ci = dev_get_platdata(dev);
 
        if (count > 2)
                return -1;
@@ -121,7 +121,7 @@ get_b_bus_req(struct device *dev, struct device_attribute 
*attr, char *buf)
 {
        char            *next;
        unsigned        size, t;
-       struct ci_hdrc  *ci = dev_get_drvdata(dev);
+       struct ci_hdrc  *ci = dev_get_platdata(dev);
 
        next = buf;
        size = PAGE_SIZE;
@@ -136,7 +136,7 @@ static ssize_t
 set_b_bus_req(struct device *dev, struct device_attribute *attr,
                                        const char *buf, size_t count)
 {
-       struct ci_hdrc  *ci = dev_get_drvdata(dev);
+       struct ci_hdrc  *ci = dev_get_platdata(dev);
 
        if (count > 2)
                return -1;
@@ -158,7 +158,7 @@ static ssize_t
 set_a_clr_err(struct device *dev, struct device_attribute *attr,
                                        const char *buf, size_t count)
 {
-       struct ci_hdrc  *ci = dev_get_drvdata(dev);
+       struct ci_hdrc  *ci = dev_get_platdata(dev);
 
        if (count > 2)
                return -1;
-- 
1.9.1

--
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