2014-10-28 16:35:46

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH v7 0/7] usb: add support for the generic PHY framework

The series can be found at:
git://git.free-electrons.com:users/antoine-tenart/linux.git usb-phy

Changes since v6:
- rebased on top of v3.18-rc2

Changes since v5:
- rebased on the latest version of Sergei's series[1]
- fixed one modifiaction made in the wrong patch

Changes since v4:
- reworked the PHY handling in ci_hdrc_probe()
- fixed a rebase error

Changes since v3:
- moved phy_exit() after phy_power_on()
- fixed the PHY handling in ci_hdrc_probe()
- some little fixes

Changes since v2:
- rebased the series on top of v3.17-rc1
- switched to devm_phy_get() to handle non DT cases
- moved usb_otg into the ci_hdrc structure

Changes since v1:
- rebased the series on top of [2] (generic PHY support for HCD)
- split s/phy/usb_phy/ renaming and generic PHY support in separate
patches

[1] https://www.mail-archive.com/linux-usb%40vger.kernel.org/msg48068.html

Antoine Tenart (7):
usb: move the OTG state from the USB PHY to the OTG structure
usb: rename phy to usb_phy in OTG
usb: add support to the generic PHY framework in OTG
usb: allow to supply the PHY in the drivers when using HCD
usb: rename transceiver and phy to usb_phy in ChipIdea
usb: chipidea: move usb_otg into struct ci_hdrc
usb: chipidea: add support to the generic PHY framework in ChipIdea

drivers/phy/phy-omap-usb2.c | 14 ++----
drivers/usb/chipidea/ci.h | 8 +++-
drivers/usb/chipidea/ci_hdrc_imx.c | 2 +-
drivers/usb/chipidea/ci_hdrc_msm.c | 8 ++--
drivers/usb/chipidea/core.c | 89 ++++++++++++++++++++++++++--------
drivers/usb/chipidea/debug.c | 2 +-
drivers/usb/chipidea/host.c | 10 ++--
drivers/usb/chipidea/otg_fsm.c | 30 +++++-------
drivers/usb/chipidea/udc.c | 4 +-
drivers/usb/common/usb-otg-fsm.c | 8 ++--
drivers/usb/core/hcd.c | 7 +--
drivers/usb/host/ohci-omap.c | 2 +-
drivers/usb/musb/am35x.c | 28 +++++------
drivers/usb/musb/blackfin.c | 18 +++----
drivers/usb/musb/da8xx.c | 28 +++++------
drivers/usb/musb/davinci.c | 18 +++----
drivers/usb/musb/musb_core.c | 94 ++++++++++++++++++------------------
drivers/usb/musb/musb_dsps.c | 26 +++++-----
drivers/usb/musb/musb_gadget.c | 36 +++++++-------
drivers/usb/musb/musb_host.c | 8 ++--
drivers/usb/musb/musb_virthub.c | 22 ++++-----
drivers/usb/musb/omap2430.c | 30 ++++++------
drivers/usb/musb/tusb6010.c | 40 ++++++++--------
drivers/usb/musb/ux500.c | 10 ++--
drivers/usb/phy/phy-ab8500-usb.c | 16 +++----
drivers/usb/phy/phy-fsl-usb.c | 23 ++++-----
drivers/usb/phy/phy-generic.c | 6 +--
drivers/usb/phy/phy-gpio-vbus-usb.c | 14 +++---
drivers/usb/phy/phy-isp1301-omap.c | 10 ++--
drivers/usb/phy/phy-msm-usb.c | 95 +++++++++++++++++++------------------
drivers/usb/phy/phy-mv-usb.c | 50 +++++++++----------
drivers/usb/phy/phy-tahvo.c | 8 ++--
drivers/usb/phy/phy-ulpi.c | 6 +--
include/linux/usb/chipidea.h | 4 +-
include/linux/usb/otg.h | 7 ++-
include/linux/usb/phy.h | 1 -
36 files changed, 420 insertions(+), 362 deletions(-)

--
1.9.1


2014-10-28 16:35:58

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH v7 2/7] usb: rename phy to usb_phy in OTG

This patch prepares the introduction of the generic PHY support in the
USB OTG common functions. The USB PHY member of the OTG structure is
renamed to 'usb_phy' and modifications are done in all drivers accessing
it. Renaming this pointer will allow to keep the compatibility for USB
PHY drivers.

Signed-off-by: Antoine Tenart <[email protected]>
---
drivers/phy/phy-omap-usb2.c | 6 ++--
drivers/usb/chipidea/otg_fsm.c | 2 +-
drivers/usb/phy/phy-ab8500-usb.c | 6 ++--
drivers/usb/phy/phy-fsl-usb.c | 13 ++++----
drivers/usb/phy/phy-generic.c | 2 +-
drivers/usb/phy/phy-gpio-vbus-usb.c | 4 +--
drivers/usb/phy/phy-isp1301-omap.c | 10 +++---
drivers/usb/phy/phy-msm-usb.c | 61 +++++++++++++++++++------------------
drivers/usb/phy/phy-mv-usb.c | 4 +--
drivers/usb/phy/phy-tahvo.c | 8 +++--
drivers/usb/phy/phy-ulpi.c | 6 ++--
include/linux/usb/otg.h | 2 +-
12 files changed, 65 insertions(+), 59 deletions(-)

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 9f4093590f4c..32c3e86b4935 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -60,7 +60,7 @@ EXPORT_SYMBOL_GPL(omap_usb2_set_comparator);

static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
{
- struct omap_usb *phy = phy_to_omapusb(otg->phy);
+ struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);

if (!phy->comparator)
return -ENODEV;
@@ -70,7 +70,7 @@ static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)

static int omap_usb_start_srp(struct usb_otg *otg)
{
- struct omap_usb *phy = phy_to_omapusb(otg->phy);
+ struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);

if (!phy->comparator)
return -ENODEV;
@@ -251,7 +251,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
otg->set_vbus = omap_usb_set_vbus;
if (phy_data->flags & OMAP_USB2_HAS_START_SRP)
otg->start_srp = omap_usb_start_srp;
- otg->phy = &phy->phy;
+ otg->usb_phy = &phy->phy;

platform_set_drvdata(pdev, phy);

diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 8cb2508a6b71..d8490e758a74 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -788,7 +788,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
return -ENOMEM;
}

- otg->phy = ci->transceiver;
+ otg->usb_phy = ci->transceiver;
otg->gadget = &ci->gadget;
ci->fsm.otg = otg;
ci->transceiver->otg = ci->fsm.otg;
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 2d5250143ce1..3a802fa7dae2 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -1056,7 +1056,7 @@ static int ab8500_usb_set_peripheral(struct usb_otg *otg,
if (!otg)
return -ENODEV;

- ab = phy_to_ab(otg->phy);
+ ab = phy_to_ab(otg->usb_phy);

ab->phy.otg->gadget = gadget;

@@ -1080,7 +1080,7 @@ static int ab8500_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
if (!otg)
return -ENODEV;

- ab = phy_to_ab(otg->phy);
+ ab = phy_to_ab(otg->usb_phy);

ab->phy.otg->host = host;

@@ -1382,7 +1382,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
ab->phy.set_power = ab8500_usb_set_power;
ab->phy.otg->state = OTG_STATE_UNDEFINED;

- otg->phy = &ab->phy;
+ otg->usb_phy = &ab->phy;
otg->set_host = ab8500_usb_set_host;
otg->set_peripheral = ab8500_usb_set_peripheral;

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 15d7a81eece5..b7f36b212422 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -499,7 +499,8 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
{
struct usb_otg *otg = fsm->otg;
struct device *dev;
- struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
+ struct fsl_otg *otg_dev =
+ container_of(otg->usb_phy, struct fsl_otg, phy);
u32 retval = 0;

if (!otg->host)
@@ -594,7 +595,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
if (!otg)
return -ENODEV;

- otg_dev = container_of(otg->phy, struct fsl_otg, phy);
+ otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy);
if (otg_dev != fsl_otg_dev)
return -ENODEV;

@@ -644,7 +645,7 @@ static int fsl_otg_set_peripheral(struct usb_otg *otg,
if (!otg)
return -ENODEV;

- otg_dev = container_of(otg->phy, struct fsl_otg, phy);
+ otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy);
VDBG("otg_dev 0x%x\n", (int)otg_dev);
VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev);
if (otg_dev != fsl_otg_dev)
@@ -717,7 +718,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
if (!otg || otg.state != OTG_STATE_B_IDLE)
return -ENODEV;

- otg_dev = container_of(otg->phy, struct fsl_otg, phy);
+ otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy);
if (otg_dev != fsl_otg_dev)
return -ENODEV;

@@ -735,7 +736,7 @@ static int fsl_otg_start_hnp(struct usb_otg *otg)
if (!otg)
return -ENODEV;

- otg_dev = container_of(otg->phy, struct fsl_otg, phy);
+ otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy);
if (otg_dev != fsl_otg_dev)
return -ENODEV;

@@ -857,7 +858,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
fsl_otg_tc->phy.dev = &pdev->dev;
fsl_otg_tc->phy.set_power = fsl_otg_set_power;

- fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy;
+ fsl_otg_tc->phy.otg->usb_phy = &fsl_otg_tc->phy;
fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host;
fsl_otg_tc->phy.otg->set_peripheral = fsl_otg_set_peripheral;
fsl_otg_tc->phy.otg->start_hnp = fsl_otg_start_hnp;
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 280a3458ff6b..0c01bd12cabc 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -228,7 +228,7 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
nop->phy.type = type;

nop->phy.otg->state = OTG_STATE_UNDEFINED;
- nop->phy.otg->phy = &nop->phy;
+ nop->phy.otg->usb_phy = &nop->phy;
nop->phy.otg->set_host = nop_set_host;
nop->phy.otg->set_peripheral = nop_set_peripheral;

diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index 7a6be3e5dc23..9fcf19ba1416 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -180,7 +180,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
struct platform_device *pdev;
int gpio;

- gpio_vbus = container_of(otg->phy, struct gpio_vbus_data, phy);
+ gpio_vbus = container_of(otg->usb_phy, struct gpio_vbus_data, phy);
pdev = to_platform_device(gpio_vbus->dev);
pdata = dev_get_platdata(gpio_vbus->dev);
gpio = pdata->gpio_pullup;
@@ -271,7 +271,7 @@ static int gpio_vbus_probe(struct platform_device *pdev)
gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;

gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
- gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
+ gpio_vbus->phy.otg->usb_phy = &gpio_vbus->phy;
gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;

err = devm_gpio_request(&pdev->dev, gpio, "vbus_detect");
diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c
index 8eea56d3ded6..dc2f41eb8b75 100644
--- a/drivers/usb/phy/phy-isp1301-omap.c
+++ b/drivers/usb/phy/phy-isp1301-omap.c
@@ -1275,7 +1275,7 @@ static int isp1301_otg_enable(struct isp1301 *isp)
static int
isp1301_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
+ struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy);

if (isp != the_transceiver)
return -ENODEV;
@@ -1331,7 +1331,7 @@ isp1301_set_host(struct usb_otg *otg, struct usb_bus *host)
static int
isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
{
- struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
+ struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy);

if (isp != the_transceiver)
return -ENODEV;
@@ -1411,7 +1411,7 @@ isp1301_set_power(struct usb_phy *dev, unsigned mA)
static int
isp1301_start_srp(struct usb_otg *otg)
{
- struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
+ struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy);
u32 otg_ctrl;

if (isp != the_transceiver || isp->phy.state != OTG_STATE_B_IDLE)
@@ -1438,7 +1438,7 @@ static int
isp1301_start_hnp(struct usb_otg *otg)
{
#ifdef CONFIG_USB_OTG
- struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
+ struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy);
u32 l;

if (isp != the_transceiver)
@@ -1583,7 +1583,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
isp->phy.label = DRIVER_NAME;
isp->phy.set_power = isp1301_set_power,

- isp->phy.otg->phy = &isp->phy;
+ isp->phy.otg->usb_phy = &isp->phy;
isp->phy.otg->set_host = isp1301_set_host,
isp->phy.otg->set_peripheral = isp1301_set_peripheral,
isp->phy.otg->start_srp = isp1301_start_srp,
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8c22aeef0246..0d35b17c97fb 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -708,7 +708,7 @@ static void msm_otg_start_host(struct usb_phy *phy, int on)

static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy);
+ struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy);
struct usb_hcd *hcd;

/*
@@ -716,14 +716,14 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
* only peripheral configuration.
*/
if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) {
- dev_info(otg->phy->dev, "Host mode is not supported\n");
+ dev_info(otg->usb_phy->dev, "Host mode is not supported\n");
return -ENODEV;
}

if (!host) {
if (otg->state == OTG_STATE_A_HOST) {
- pm_runtime_get_sync(otg->phy->dev);
- msm_otg_start_host(otg->phy, 0);
+ pm_runtime_get_sync(otg->usb_phy->dev);
+ msm_otg_start_host(otg->usb_phy, 0);
otg->host = NULL;
otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
@@ -738,14 +738,14 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
hcd->power_budget = motg->pdata->power_budget;

otg->host = host;
- dev_dbg(otg->phy->dev, "host driver registered w/ tranceiver\n");
+ dev_dbg(otg->usb_phy->dev, "host driver registered w/ tranceiver\n");

/*
* Kick the state machine work, if peripheral is not supported
* or peripheral is already registered with us.
*/
if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
- pm_runtime_get_sync(otg->phy->dev);
+ pm_runtime_get_sync(otg->usb_phy->dev);
schedule_work(&motg->sm_work);
}

@@ -782,21 +782,21 @@ static void msm_otg_start_peripheral(struct usb_phy *phy, int on)
static int msm_otg_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
{
- struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy);
+ struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy);

/*
* Fail peripheral registration if this board can support
* only host configuration.
*/
if (motg->pdata->mode == USB_DR_MODE_HOST) {
- dev_info(otg->phy->dev, "Peripheral mode is not supported\n");
+ dev_info(otg->usb_phy->dev, "Peripheral mode is not supported\n");
return -ENODEV;
}

if (!gadget) {
if (otg->state == OTG_STATE_B_PERIPHERAL) {
- pm_runtime_get_sync(otg->phy->dev);
- msm_otg_start_peripheral(otg->phy, 0);
+ pm_runtime_get_sync(otg->usb_phy->dev);
+ msm_otg_start_peripheral(otg->usb_phy, 0);
otg->gadget = NULL;
otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
@@ -807,14 +807,15 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
return 0;
}
otg->gadget = gadget;
- dev_dbg(otg->phy->dev, "peripheral driver registered w/ tranceiver\n");
+ dev_dbg(otg->usb_phy->dev,
+ "peripheral driver registered w/ tranceiver\n");

/*
* Kick the state machine work, if host is not supported
* or host is already registered with us.
*/
if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
- pm_runtime_get_sync(otg->phy->dev);
+ pm_runtime_get_sync(otg->usb_phy->dev);
schedule_work(&motg->sm_work);
}

@@ -1172,17 +1173,17 @@ static void msm_otg_sm_work(struct work_struct *w)

switch (otg->state) {
case OTG_STATE_UNDEFINED:
- dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
- msm_otg_reset(otg->phy);
+ dev_dbg(otg->usb_phy->dev, "OTG_STATE_UNDEFINED state\n");
+ msm_otg_reset(otg->usb_phy);
msm_otg_init_sm(motg);
otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
- dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
+ dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_IDLE state\n");
if (!test_bit(ID, &motg->inputs) && otg->host) {
/* disable BSV bit */
writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
- msm_otg_start_host(otg->phy, 1);
+ msm_otg_start_host(otg->usb_phy, 1);
otg->state = OTG_STATE_A_HOST;
} else if (test_bit(B_SESS_VLD, &motg->inputs)) {
switch (motg->chg_state) {
@@ -1198,13 +1199,15 @@ static void msm_otg_sm_work(struct work_struct *w)
case USB_CDP_CHARGER:
msm_otg_notify_charger(motg,
IDEV_CHG_MAX);
- msm_otg_start_peripheral(otg->phy, 1);
+ msm_otg_start_peripheral(otg->usb_phy,
+ 1);
otg->state
= OTG_STATE_B_PERIPHERAL;
break;
case USB_SDP_CHARGER:
msm_otg_notify_charger(motg, IUNIT);
- msm_otg_start_peripheral(otg->phy, 1);
+ msm_otg_start_peripheral(otg->usb_phy,
+ 1);
otg->state
= OTG_STATE_B_PERIPHERAL;
break;
@@ -1222,8 +1225,8 @@ static void msm_otg_sm_work(struct work_struct *w)
* is incremented in charger detection work.
*/
if (cancel_delayed_work_sync(&motg->chg_work)) {
- pm_runtime_put_sync(otg->phy->dev);
- msm_otg_reset(otg->phy);
+ pm_runtime_put_sync(otg->usb_phy->dev);
+ msm_otg_reset(otg->usb_phy);
}
msm_otg_notify_charger(motg, 0);
motg->chg_state = USB_CHG_STATE_UNDEFINED;
@@ -1231,27 +1234,27 @@ static void msm_otg_sm_work(struct work_struct *w)
}

if (otg->state == OTG_STATE_B_IDLE)
- pm_runtime_put_sync(otg->phy->dev);
+ pm_runtime_put_sync(otg->usb_phy->dev);
break;
case OTG_STATE_B_PERIPHERAL:
- dev_dbg(otg->phy->dev, "OTG_STATE_B_PERIPHERAL state\n");
+ dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_PERIPHERAL state\n");
if (!test_bit(B_SESS_VLD, &motg->inputs) ||
!test_bit(ID, &motg->inputs)) {
msm_otg_notify_charger(motg, 0);
- msm_otg_start_peripheral(otg->phy, 0);
+ msm_otg_start_peripheral(otg->usb_phy, 0);
motg->chg_state = USB_CHG_STATE_UNDEFINED;
motg->chg_type = USB_INVALID_CHARGER;
otg->state = OTG_STATE_B_IDLE;
- msm_otg_reset(otg->phy);
+ msm_otg_reset(otg->usb_phy);
schedule_work(w);
}
break;
case OTG_STATE_A_HOST:
- dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
+ dev_dbg(otg->usb_phy->dev, "OTG_STATE_A_HOST state\n");
if (test_bit(ID, &motg->inputs)) {
- msm_otg_start_host(otg->phy, 0);
+ msm_otg_start_host(otg->usb_phy, 0);
otg->state = OTG_STATE_B_IDLE;
- msm_otg_reset(otg->phy);
+ msm_otg_reset(otg->usb_phy);
schedule_work(w);
}
break;
@@ -1388,7 +1391,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
goto out;
}

- pm_runtime_get_sync(otg->phy->dev);
+ pm_runtime_get_sync(otg->usb_phy->dev);
schedule_work(&motg->sm_work);
out:
return status;
@@ -1674,7 +1677,7 @@ static int msm_otg_probe(struct platform_device *pdev)

phy->io_ops = &msm_otg_io_ops;

- phy->otg->phy = &motg->phy;
+ phy->otg->usb_phy = &motg->phy;
phy->otg->set_host = msm_otg_set_host;
phy->otg->set_peripheral = msm_otg_set_peripheral;

diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index d6b3c473f068..d948275d55e5 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -56,7 +56,7 @@ static char *state_string[] = {

static int mv_otg_set_vbus(struct usb_otg *otg, bool on)
{
- struct mv_otg *mvotg = container_of(otg->phy, struct mv_otg, phy);
+ struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, phy);
if (mvotg->pdata->set_vbus == NULL)
return -ENODEV;

@@ -718,8 +718,8 @@ static int mv_otg_probe(struct platform_device *pdev)
mvotg->phy.otg = otg;
mvotg->phy.label = driver_name;

- otg->phy = &mvotg->phy;
otg->state = OTG_STATE_UNDEFINED;
+ otg->usb_phy = &mvotg->phy;
otg->set_host = mv_otg_set_host;
otg->set_peripheral = mv_otg_set_peripheral;
otg->set_vbus = mv_otg_set_vbus;
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index cc61ee44b911..402e6af29c65 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -196,7 +196,8 @@ static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend)

static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct tahvo_usb *tu = container_of(otg->phy, struct tahvo_usb, phy);
+ struct tahvo_usb *tu = container_of(otg->usb_phy, struct tahvo_usb,
+ phy);

dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, host);

@@ -225,7 +226,8 @@ static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
static int tahvo_usb_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
{
- struct tahvo_usb *tu = container_of(otg->phy, struct tahvo_usb, phy);
+ struct tahvo_usb *tu = container_of(otg->usb_phy, struct tahvo_usb,
+ phy);

dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, gadget);

@@ -383,7 +385,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
tu->phy.label = DRIVER_NAME;
tu->phy.set_suspend = tahvo_usb_set_suspend;

- tu->phy.otg->phy = &tu->phy;
+ tu->phy.otg->usb_phy = &tu->phy;
tu->phy.otg->set_host = tahvo_usb_set_host;
tu->phy.otg->set_peripheral = tahvo_usb_set_peripheral;

diff --git a/drivers/usb/phy/phy-ulpi.c b/drivers/usb/phy/phy-ulpi.c
index 4e3877c329f2..f48a7a21e3c2 100644
--- a/drivers/usb/phy/phy-ulpi.c
+++ b/drivers/usb/phy/phy-ulpi.c
@@ -211,7 +211,7 @@ static int ulpi_init(struct usb_phy *phy)

static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct usb_phy *phy = otg->phy;
+ struct usb_phy *phy = otg->usb_phy;
unsigned int flags = usb_phy_io_read(phy, ULPI_IFC_CTRL);

if (!host) {
@@ -237,7 +237,7 @@ static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host)

static int ulpi_set_vbus(struct usb_otg *otg, bool on)
{
- struct usb_phy *phy = otg->phy;
+ struct usb_phy *phy = otg->usb_phy;
unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL);

flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
@@ -276,7 +276,7 @@ otg_ulpi_create(struct usb_phy_io_ops *ops,
phy->otg = otg;
phy->init = ulpi_init;

- otg->phy = phy;
+ otg->usb_phy = phy;
otg->set_host = ulpi_set_host;
otg->set_vbus = ulpi_set_vbus;

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 33d3480c9cda..978fbbb0e266 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -14,7 +14,7 @@
struct usb_otg {
u8 default_a;

- struct usb_phy *phy;
+ struct usb_phy *usb_phy;
struct usb_bus *host;
struct usb_gadget *gadget;

--
1.9.1

2014-10-28 16:35:57

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.

Signed-off-by: Antoine Tenart <[email protected]>
Acked-by: Peter Chen <[email protected]>
---
drivers/phy/phy-omap-usb2.c | 8 +---
drivers/usb/chipidea/debug.c | 2 +-
drivers/usb/chipidea/otg_fsm.c | 12 ++---
drivers/usb/common/usb-otg-fsm.c | 8 ++--
drivers/usb/host/ohci-omap.c | 2 +-
drivers/usb/musb/am35x.c | 28 +++++------
drivers/usb/musb/blackfin.c | 18 +++----
drivers/usb/musb/da8xx.c | 28 +++++------
drivers/usb/musb/davinci.c | 18 +++----
drivers/usb/musb/musb_core.c | 94 ++++++++++++++++++-------------------
drivers/usb/musb/musb_dsps.c | 26 +++++-----
drivers/usb/musb/musb_gadget.c | 36 +++++++-------
drivers/usb/musb/musb_host.c | 8 ++--
drivers/usb/musb/musb_virthub.c | 22 ++++-----
drivers/usb/musb/omap2430.c | 30 ++++++------
drivers/usb/musb/tusb6010.c | 40 ++++++++--------
drivers/usb/musb/ux500.c | 10 ++--
drivers/usb/phy/phy-ab8500-usb.c | 10 ++--
drivers/usb/phy/phy-fsl-usb.c | 10 ++--
drivers/usb/phy/phy-generic.c | 4 +-
drivers/usb/phy/phy-gpio-vbus-usb.c | 10 ++--
drivers/usb/phy/phy-msm-usb.c | 34 +++++++-------
drivers/usb/phy/phy-mv-usb.c | 46 +++++++++---------
include/linux/usb/otg.h | 2 +
include/linux/usb/phy.h | 1 -
25 files changed, 252 insertions(+), 255 deletions(-)

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 8c842980834a..9f4093590f4c 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)

static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct usb_phy *phy = otg->phy;
-
otg->host = host;
if (!host)
- phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

return 0;
}
@@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
static int omap_usb_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
{
- struct usb_phy *phy = otg->phy;
-
otg->gadget = gadget;
if (!gadget)
- phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

return 0;
}
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 795d6538d630..8878eea38d44 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)

/* ------ State ----- */
seq_printf(s, "OTG state: %s\n\n",
- usb_otg_state_string(ci->transceiver->state));
+ usb_otg_state_string(ci->transceiver->otg.state));

/* ------ State Machine Variables ----- */
seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index caaabc58021e..8cb2508a6b71 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
set_tmout(ci, indicator);

/* only vbus fall below B_sess_vld in b_idle state */
- if (ci->transceiver->state == OTG_STATE_B_IDLE)
+ if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
ci_otg_queue_work(ci);
}

@@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
* when there is no gadget class driver
*/
if (ci->fsm.id && !(ci->driver) &&
- ci->transceiver->state < OTG_STATE_A_IDLE)
+ ci->fsm.otg->state < OTG_STATE_A_IDLE)
return 0;

if (otg_statemachine(&ci->fsm)) {
- if (ci->transceiver->state == OTG_STATE_A_IDLE) {
+ if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
/*
* Further state change for cases:
* a_idle to b_idle; or
@@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
ci_otg_queue_work(ci);
if (ci->id_event)
ci->id_event = false;
- } else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
+ } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
if (ci->fsm.b_sess_vld) {
ci->fsm.power_up = 0;
/*
@@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);

- switch (ci->transceiver->state) {
+ switch (ci->fsm.otg->state) {
case OTG_STATE_A_WAIT_BCON:
if (port_conn) {
fsm->b_conn = 1;
@@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
ci->transceiver->otg = ci->fsm.otg;
ci->fsm.power_up = 1;
ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
- ci->transceiver->state = OTG_STATE_UNDEFINED;
+ ci->fsm.otg->state = OTG_STATE_UNDEFINED;
ci->fsm.ops = &ci_otg_ops;

mutex_init(&ci->fsm.lock);
diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
index 98e8340a5bb1..c6b35b77dab7 100644
--- a/drivers/usb/common/usb-otg-fsm.c
+++ b/drivers/usb/common/usb-otg-fsm.c
@@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{
state_changed = 1;
- if (fsm->otg->phy->state == new_state)
+ if (fsm->otg->state == new_state)
return 0;
VDBG("Set state: %s\n", usb_otg_state_string(new_state));
- otg_leave_state(fsm, fsm->otg->phy->state);
+ otg_leave_state(fsm, fsm->otg->state);
switch (new_state) {
case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0);
@@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
break;
}

- fsm->otg->phy->state = new_state;
+ fsm->otg->state = new_state;
return 0;
}

@@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm)

mutex_lock(&fsm->lock);

- state = fsm->otg->phy->state;
+ state = fsm->otg->state;
state_changed = 0;
/* State machine state change judgement */

diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 0231606d47c2..cf89b4b17f14 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
otg_start_hnp(hcd->usb_phy->otg);

local_irq_save(flags);
- hcd->usb_phy->state = OTG_STATE_A_SUSPEND;
+ hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
l = omap_readl(OTG_CTRL);
l &= ~OTG_A_BUSREQ;
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index a2735df24cc6..d836a3e1f8ec 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -149,25 +149,25 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
break;
@@ -176,7 +176,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -193,9 +193,9 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround);
last_timer = jiffies;
return;
@@ -208,7 +208,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout);
}
@@ -278,27 +278,27 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

/* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -324,7 +324,7 @@ eoi:
}

/* Poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index ac4422b33dcd..19a69b7f06db 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -185,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
}

/* Start sampling ID pin, when plug is removed from MUSB */
- if ((musb->xceiv->state == OTG_STATE_B_IDLE
- || musb->xceiv->state == OTG_STATE_A_WAIT_BCON) ||
+ if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE
+ || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) ||
(musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
musb->a_wait_bcon = TIMER_DELAY;
@@ -205,7 +205,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
static u8 toggle;

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE:
case OTG_STATE_A_WAIT_BCON:
/* Start a new session */
@@ -219,7 +219,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);
/* Ignore VBUSERROR and SUSPEND IRQ */
@@ -229,7 +229,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
musb_writeb(musb->mregs, MUSB_INTRUSB, val);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
break;
@@ -245,7 +245,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);

@@ -280,13 +280,13 @@ static void musb_conn_timer_handler(unsigned long _musb)
break;
default:
dev_dbg(musb->controller, "%s state not handled\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
spin_unlock_irqrestore(&musb->lock, flags);

dev_dbg(musb->controller, "state is %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}

static void bfin_musb_enable(struct musb *musb)
@@ -307,7 +307,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)

dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 058775e647ad..527c7fe60ece 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -198,20 +198,20 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
break;
@@ -248,7 +248,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -265,9 +265,9 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround);
last_timer = jiffies;
return;
@@ -280,7 +280,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout);
}
@@ -341,26 +341,26 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -375,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);

/* Poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 110b78415bf0..ae54188162cb 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -214,10 +214,10 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VFALL:
/* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL
* seems to mis-handle session "start" otherwise (or in our
@@ -228,7 +228,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
break;
@@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -325,20 +325,20 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
* to stop registering in devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

@@ -348,7 +348,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
davinci_musb_source_power(musb, drvvbus, 0);
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
retval = IRQ_HANDLED;
@@ -361,7 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
musb_writel(tibase, DAVINCI_USB_EOI_REG, 0);

/* poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b841ee0bff06..77996f1d3645 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -360,23 +360,23 @@ static void musb_otg_timer_func(unsigned long data)
unsigned long flags;

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: b_wait_acon timeout; back to b_peripheral\n");
musb_g_disconnect(musb);
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 0;
break;
case OTG_STATE_A_SUSPEND:
case OTG_STATE_A_WAIT_BCON:
dev_dbg(musb->controller, "HNP: %s timeout\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
musb_platform_set_vbus(musb, 0);
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
default:
dev_dbg(musb->controller, "HNP: Unhandled mode %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -391,19 +391,19 @@ void musb_hnp_stop(struct musb *musb)
u8 reg;

dev_dbg(musb->controller, "HNP: stop from %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
musb_g_disconnect(musb);
dev_dbg(musb->controller, "HNP: back to %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
case OTG_STATE_B_HOST:
dev_dbg(musb->controller, "HNP: Disabling HR\n");
if (hcd)
hcd->self.is_b_host = 0;
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
reg = musb_readb(mbase, MUSB_POWER);
reg |= MUSB_POWER_SUSPENDM;
@@ -412,7 +412,7 @@ void musb_hnp_stop(struct musb *musb)
break;
default:
dev_dbg(musb->controller, "HNP: Stopping in unknown state %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}

/*
@@ -449,13 +449,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
if (int_usb & MUSB_INTR_RESUME) {
handled = IRQ_HANDLED;
- dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->state));
+ dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->otg->state));

if (devctl & MUSB_DEVCTL_HM) {
void __iomem *mbase = musb->mregs;
u8 power;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
/* remote wakeup? later, GetPortStatus
* will stop RESUME signaling
@@ -482,25 +482,25 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
&musb->finish_resume_work,
msecs_to_jiffies(20));

- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
musb->is_active = 1;
musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 1;
MUSB_DEV_MODE(musb);
break;
default:
WARNING("bogus %s RESUME (%s)\n",
"host",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else {
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
/* possibly DISCONNECT is upcoming */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
@@ -523,7 +523,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
default:
WARNING("bogus %s RESUME (%s)\n",
"peripheral",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -539,7 +539,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
}

dev_dbg(musb->controller, "SESSION_REQUEST (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

/* IRQ arrives from ID pin sense or (later, if VBUS power
* is removed) SRP. responses are time critical:
@@ -550,7 +550,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
musb_writeb(mbase, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
musb->ep0_stage = MUSB_EP0_START;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
musb_platform_set_vbus(musb, 1);

@@ -576,7 +576,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
* REVISIT: do delays from lots of DEBUG_KERNEL checks
* make trouble here, keeping VBUS < 4.4V ?
*/
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
/* recovery is dicey once we've gotten past the
* initial stages of enumeration, but if VBUS
@@ -605,7 +605,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

dev_printk(ignore ? KERN_DEBUG : KERN_ERR, musb->controller,
"VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
devctl,
({ char *s;
switch (devctl & MUSB_DEVCTL_VBUS) {
@@ -630,10 +630,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

if (int_usb & MUSB_INTR_SUSPEND) {
dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
handled = IRQ_HANDLED;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
/* We also come here if the cable is removed, since
* this silicon doesn't report ID-no-longer-grounded.
@@ -657,7 +657,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb_g_suspend(musb);
musb->is_active = musb->g.b_hnp_enable;
if (musb->is_active) {
- musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(
@@ -670,7 +670,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
+ msecs_to_jiffies(musb->a_wait_bcon));
break;
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = musb->hcd->self.b_hnp_enable;
break;
case OTG_STATE_B_HOST:
@@ -713,7 +713,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb->port1_status |= USB_PORT_STAT_LOW_SPEED;

/* indicate new connection to OTG machine */
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL:
if (int_usb & MUSB_INTR_SUSPEND) {
dev_dbg(musb->controller, "HNP: SUSPEND+CONNECT, now b_host\n");
@@ -725,7 +725,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: CONNECT, now b_host\n");
b_host:
- musb->xceiv->state = OTG_STATE_B_HOST;
+ musb->xceiv->otg->state = OTG_STATE_B_HOST;
if (musb->hcd)
musb->hcd->self.is_b_host = 1;
del_timer(&musb->otg_timer);
@@ -733,7 +733,7 @@ b_host:
default:
if ((devctl & MUSB_DEVCTL_VBUS)
== (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
if (hcd)
hcd->self.is_b_host = 0;
}
@@ -743,16 +743,16 @@ b_host:
musb_host_poke_root_hub(musb);

dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
}

if (int_usb & MUSB_INTR_DISCONNECT) {
dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
MUSB_MODE(musb), devctl);
handled = IRQ_HANDLED;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
musb_host_resume_root_hub(musb);
@@ -770,7 +770,7 @@ b_host:
musb_root_disconnect(musb);
if (musb->hcd)
musb->hcd->self.is_b_host = 0;
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
musb_g_disconnect(musb);
break;
@@ -786,7 +786,7 @@ b_host:
break;
default:
WARNING("unhandled DISCONNECT transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
}
@@ -812,15 +812,15 @@ b_host:
}
} else {
dev_dbg(musb->controller, "BUS RESET as %s\n",
- usb_otg_state_string(musb->xceiv->state));
- switch (musb->xceiv->state) {
+ usb_otg_state_string(musb->xceiv->otg->state));
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
musb_g_reset(musb);
/* FALLTHROUGH */
case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
/* never use invalid T(a_wait_bcon) */
dev_dbg(musb->controller, "HNP: in %s, %d msec timeout\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
TA_WAIT_BCON(musb));
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(TA_WAIT_BCON(musb)));
@@ -831,19 +831,19 @@ b_host:
break;
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: RESET (%s), to b_peripheral\n",
- usb_otg_state_string(musb->xceiv->state));
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ usb_otg_state_string(musb->xceiv->otg->state));
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb_g_reset(musb);
break;
case OTG_STATE_B_IDLE:
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
/* FALLTHROUGH */
case OTG_STATE_B_PERIPHERAL:
musb_g_reset(musb);
break;
default:
dev_dbg(musb->controller, "Unhandled BUS RESET as %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -1630,7 +1630,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
int ret = -EINVAL;

spin_lock_irqsave(&musb->lock, flags);
- ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->state));
+ ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->otg->state));
spin_unlock_irqrestore(&musb->lock, flags);

return ret;
@@ -1675,7 +1675,7 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
spin_lock_irqsave(&musb->lock, flags);
/* force T(a_wait_bcon) to be zero/unlimited *OR* valid */
musb->a_wait_bcon = val ? max_t(int, val, OTG_TIME_A_WAIT_BCON) : 0 ;
- if (musb->xceiv->state == OTG_STATE_A_WAIT_BCON)
+ if (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)
musb->is_active = 0;
musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(val));
spin_unlock_irqrestore(&musb->lock, flags);
@@ -1743,8 +1743,8 @@ static void musb_irq_work(struct work_struct *data)
{
struct musb *musb = container_of(data, struct musb, irq_work);

- if (musb->xceiv->state != musb->xceiv_old_state) {
- musb->xceiv_old_state = musb->xceiv->state;
+ if (musb->xceiv->otg->state != musb->xceiv_old_state) {
+ musb->xceiv_old_state = musb->xceiv->otg->state;
sysfs_notify(&musb->controller->kobj, NULL, "mode");
}
}
@@ -1983,10 +1983,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)

if (musb->xceiv->otg->default_a) {
MUSB_HST_MODE(musb);
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
} else {
MUSB_DEV_MODE(musb);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}

switch (musb->port_mode) {
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 154bcf1b5dfa..a8863f088081 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -179,9 +179,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&glue->timer);
glue->last_timer = jiffies;
return;
@@ -201,7 +201,7 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
glue->last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&glue->timer, timeout);
}
@@ -265,10 +265,10 @@ static void otg_timer(unsigned long _musb)
*/
devctl = dsps_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
skip_session = 1;
@@ -277,10 +277,10 @@ static void otg_timer(unsigned long _musb)
case OTG_STATE_A_IDLE:
case OTG_STATE_B_IDLE:
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
@@ -288,7 +288,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
dsps_writel(musb->ctrl_base, wrp->coreintr_set,
MUSB_INTR_VBUSERROR << wrp->usb_shift);
break;
@@ -373,26 +373,26 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&glue->timer,
jiffies + wrp->poll_seconds * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
del_timer(&glue->timer);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}

/* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -402,7 +402,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
ret |= musb_interrupt(musb);

/* Poll for ID change in OTG port mode */
- if (musb->xceiv->state == OTG_STATE_B_IDLE &&
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
out:
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 24c8c0219790..e8a237d0377c 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1546,7 +1546,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL:
/* NOTE: OTG state machine doesn't include B_SUSPENDED;
* that's part of the standard usb 1.1 state machine, and
@@ -1587,7 +1587,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
goto done;
default:
dev_dbg(musb->controller, "Unhandled wake: %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
goto done;
}

@@ -1792,7 +1792,7 @@ int musb_gadget_setup(struct musb *musb)

MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;

/* this "gadget" abstracts/virtualizes the controller */
musb->g.name = musb_driver_name;
@@ -1860,7 +1860,7 @@ static int musb_gadget_start(struct usb_gadget *g,
musb->is_active = 1;

otg_set_peripheral(otg, &musb->g);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
spin_unlock_irqrestore(&musb->lock, flags);

musb_start(musb);
@@ -1945,7 +1945,7 @@ static int musb_gadget_stop(struct usb_gadget *g,

(void) musb_gadget_vbus_draw(&musb->g, 0);

- musb->xceiv->state = OTG_STATE_UNDEFINED;
+ musb->xceiv->otg->state = OTG_STATE_UNDEFINED;
stop_activity(musb, driver);
otg_set_peripheral(musb->xceiv->otg, NULL);

@@ -1975,7 +1975,7 @@ static int musb_gadget_stop(struct usb_gadget *g,
void musb_g_resume(struct musb *musb)
{
musb->is_suspended = 0;
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE:
break;
case OTG_STATE_B_WAIT_ACON:
@@ -1989,7 +1989,7 @@ void musb_g_resume(struct musb *musb)
break;
default:
WARNING("unhandled RESUME transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

@@ -2001,10 +2001,10 @@ void musb_g_suspend(struct musb *musb)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "devctl %02x\n", devctl);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE:
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
musb->is_suspended = 1;
@@ -2019,7 +2019,7 @@ void musb_g_suspend(struct musb *musb)
* A_PERIPHERAL may need care too
*/
WARNING("unhandled SUSPEND transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

@@ -2050,22 +2050,22 @@ void musb_g_disconnect(struct musb *musb)
spin_lock(&musb->lock);
}

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
default:
dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n",
- usb_otg_state_string(musb->xceiv->state));
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ usb_otg_state_string(musb->xceiv->otg->state));
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
break;
case OTG_STATE_A_PERIPHERAL:
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
MUSB_HST_MODE(musb);
break;
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_HOST:
case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_IDLE:
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_B_SRP_INIT:
break;
@@ -2125,13 +2125,13 @@ __acquires(musb->lock)
* In that case, do not rely on devctl for setting
* peripheral mode.
*/
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else {
- musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
}

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 855793d701bb..23d474d3d7f4 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2463,7 +2463,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
if (!is_host_active(musb))
return 0;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
return 0;
case OTG_STATE_A_WAIT_VRISE:
@@ -2473,7 +2473,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
*/
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
break;
default:
break;
@@ -2481,7 +2481,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)

if (musb->is_active) {
WARNING("trying to suspend as %s while active\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
return -EBUSY;
} else
return 0;
@@ -2678,7 +2678,7 @@ int musb_host_setup(struct musb *musb, int power_budget)

MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;

otg_set_host(musb->xceiv->otg, &hcd->self);
hcd->self.otg_port = 1;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index e2d2d8c9891b..a133bd8c5dc7 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -69,7 +69,7 @@ void musb_host_finish_resume(struct work_struct *work)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;

spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -107,9 +107,9 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);

musb->port1_status |= USB_PORT_STAT_SUSPEND;
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = otg->host->b_hnp_enable;
if (musb->is_active)
mod_timer(&musb->otg_timer, jiffies
@@ -118,13 +118,13 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
musb_platform_try_idle(musb, 0);
break;
case OTG_STATE_B_HOST:
- musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
musb->is_active = otg->host->b_hnp_enable;
musb_platform_try_idle(musb, 0);
break;
default:
dev_dbg(musb->controller, "bogus rh suspend? %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else if (power & MUSB_POWER_SUSPENDM) {
power &= ~MUSB_POWER_SUSPENDM;
@@ -145,7 +145,7 @@ void musb_port_reset(struct musb *musb, bool do_reset)
u8 power;
void __iomem *mbase = musb->mregs;

- if (musb->xceiv->state == OTG_STATE_B_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) {
dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n");
musb->port1_status &= ~USB_PORT_STAT_RESET;
return;
@@ -224,24 +224,24 @@ void musb_root_disconnect(struct musb *musb)
usb_hcd_poll_rh_status(musb->hcd);
musb->is_active = 0;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
if (otg->host->b_hnp_enable) {
- musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
break;
}
/* FALLTHROUGH */
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "host disconnect (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index d369bf1f3936..d1b08349f056 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
}
break;
case OTG_STATE_A_HOST:
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE)
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
else
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
default:
break;
}
@@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer);
last_timer = jiffies;
return;
@@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout);
}
@@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);

if (is_on) {
- if (musb->xceiv->state == OTG_STATE_A_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
int loops = 100;
/* start the session */
devctl |= MUSB_DEVCTL_SESSION;
@@ -179,7 +179,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 1;
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
}
@@ -191,7 +191,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
*/

otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
devctl &= ~MUSB_DEVCTL_SESSION;

MUSB_DEV_MODE(musb);
@@ -200,7 +200,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)

dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

@@ -265,7 +265,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "ID GND\n");

otg->default_a = true;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
musb->xceiv->last_event = USB_EVENT_ID;
if (musb->gadget_driver) {
pm_runtime_get_sync(dev);
@@ -279,7 +279,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "VBUS Connect\n");

otg->default_a = false;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->xceiv->last_event = USB_EVENT_VBUS;
if (musb->gadget_driver)
pm_runtime_get_sync(dev);
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 2daa779f1382..8187a94fc53f 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -415,13 +415,13 @@ static void musb_do_idle(unsigned long _musb)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
if ((musb->a_wait_bcon != 0)
&& (musb->idle_timeout == 0
|| time_after(jiffies, musb->idle_timeout))) {
dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
/* FALLTHROUGH */
case OTG_STATE_A_IDLE:
@@ -474,9 +474,9 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer);
last_timer = jiffies;
return;
@@ -493,7 +493,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout);
}
@@ -524,7 +524,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
if (is_on) {
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;

conf |= TUSB_DEV_CONF_USB_HOST_MODE;
@@ -537,16 +537,16 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
/* If ID pin is grounded, we want to be a_idle */
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE:
case OTG_STATE_A_WAIT_BCON:
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
}
musb->is_active = 0;
otg->default_a = 1;
@@ -554,7 +554,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 0;
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
}

@@ -569,7 +569,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL),
musb_readl(tbase, TUSB_DEV_OTG_STAT),
conf, prcm);
@@ -668,23 +668,23 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)

if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n");
- if (musb->xceiv->state != OTG_STATE_B_IDLE) {
+ if (musb->xceiv->otg->state != OTG_STATE_B_IDLE) {
/* INTR_DISCONNECT can hide... */
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->int_usb |= MUSB_INTR_DISCONNECT;
}
musb->is_active = 0;
}
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
idle_timeout = jiffies + (1 * HZ);
schedule_work(&musb->irq_work);

} else /* A-dev state machine */ {
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE:
dev_dbg(musb->controller, "Got SRP, turning on VBUS\n");
musb_platform_set_vbus(musb, 1);
@@ -731,9 +731,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
u8 devctl;

dev_dbg(musb->controller, "%s timer, %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE:
/* VBUS has probably been valid for a while now,
* but may well have bounced out of range a bit
@@ -745,7 +745,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
dev_dbg(musb->controller, "devctl %02x\n", devctl);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
idle_timeout = jiffies
+ msecs_to_jiffies(musb->a_wait_bcon);
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index dc666e96f45f..f6c49db8dbfe 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -56,7 +56,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);

if (is_on) {
- if (musb->xceiv->state == OTG_STATE_A_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
/* start the session */
devctl |= MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
@@ -76,7 +76,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 1;
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
}
@@ -102,7 +102,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
mdelay(200);

dev_dbg(musb->controller, "VBUS %s, devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

@@ -112,7 +112,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
struct musb *musb = container_of(nb, struct musb, nb);

dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n",
- event, usb_otg_state_string(musb->xceiv->state));
+ event, usb_otg_state_string(musb->xceiv->otg->state));

switch (event) {
case UX500_MUSB_ID:
@@ -127,7 +127,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
if (is_host_active(musb))
ux500_musb_set_vbus(musb, 0);
else
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "ID float\n");
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 11ab2c45e462..2d5250143ce1 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected. */
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_9540:
@@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing
* is connected
*/
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8540:
@@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing
* is connected
*/
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8505:
@@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected */
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8500:
@@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
ab->phy.label = "ab8500";
ab->phy.set_suspend = ab8500_usb_set_suspend;
ab->phy.set_power = ab8500_usb_set_power;
- ab->phy.state = OTG_STATE_UNDEFINED;
+ ab->phy.otg->state = OTG_STATE_UNDEFINED;

otg->phy = &ab->phy;
otg->set_host = ab8500_usb_set_host;
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index f1ea5990a50a..15d7a81eece5 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
/* Mini-A cable connected */
struct otg_fsm *fsm = &otg_dev->fsm;

- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg.state = OTG_STATE_UNDEFINED;
fsm->protocol = PROTO_UNDEF;
}
}
@@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
{
if (!fsl_otg_dev)
return -ENODEV;
- if (phy->state == OTG_STATE_B_PERIPHERAL)
+ if (phy->otg.state == OTG_STATE_B_PERIPHERAL)
pr_info("FSL OTG: Draw %d mA\n", mA);

return 0;
@@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
{
struct fsl_otg *otg_dev;

- if (!otg || otg->phy->state != OTG_STATE_B_IDLE)
+ if (!otg || otg.state != OTG_STATE_B_IDLE)
return -ENODEV;

otg_dev = container_of(otg->phy, struct fsl_otg, phy);
@@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev)
* Also: record initial state of ID pin
*/
if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
- p_otg->phy.state = OTG_STATE_UNDEFINED;
+ p_otg->phy->otg.state = OTG_STATE_UNDEFINED;
p_otg->fsm.id = 1;
} else {
- p_otg->phy.state = OTG_STATE_A_IDLE;
+ p_otg->phy->otg.state = OTG_STATE_A_IDLE;
p_otg->fsm.id = 0;
}

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 7594e5069ae5..280a3458ff6b 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
}

otg->gadget = gadget;
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
return 0;
}

@@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv";
nop->phy.set_suspend = nop_set_suspend;
- nop->phy.state = OTG_STATE_UNDEFINED;
nop->phy.type = type;

+ nop->phy.otg->state = OTG_STATE_UNDEFINED;
nop->phy.otg->phy = &nop->phy;
nop->phy.otg->set_host = nop_set_host;
nop->phy.otg->set_peripheral = nop_set_peripheral;
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index f4b14bd97e14..7a6be3e5dc23 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work)

if (vbus) {
status = USB_EVENT_VBUS;
- gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
+ gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL;
gpio_vbus->phy.last_event = status;
usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);

@@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work)

usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
status = USB_EVENT_NONE;
- gpio_vbus->phy.state = OTG_STATE_B_IDLE;
+ gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE;
gpio_vbus->phy.last_event = status;

atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
@@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
set_vbus_draw(gpio_vbus, 0);

usb_gadget_vbus_disconnect(otg->gadget);
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

otg->gadget = NULL;
return 0;
@@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)

gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);

- if (phy->state == OTG_STATE_B_PERIPHERAL)
+ if (phy->otg->state == OTG_STATE_B_PERIPHERAL)
set_vbus_draw(gpio_vbus, mA);
return 0;
}
@@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
gpio_vbus->phy.dev = gpio_vbus->dev;
gpio_vbus->phy.set_power = gpio_vbus_set_power;
gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
- gpio_vbus->phy.state = OTG_STATE_UNDEFINED;

+ gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 7843ef7dd0ff..8c22aeef0246 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
}

if (!host) {
- if (otg->phy->state == OTG_STATE_A_HOST) {
+ if (otg->state == OTG_STATE_A_HOST) {
pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_host(otg->phy, 0);
otg->host = NULL;
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
} else {
otg->host = NULL;
@@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
}

if (!gadget) {
- if (otg->phy->state == OTG_STATE_B_PERIPHERAL) {
+ if (otg->state == OTG_STATE_B_PERIPHERAL) {
pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_peripheral(otg->phy, 0);
otg->gadget = NULL;
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
} else {
otg->gadget = NULL;
@@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w)
struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
struct usb_otg *otg = motg->phy.otg;

- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_UNDEFINED:
dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
msm_otg_reset(otg->phy);
msm_otg_init_sm(motg);
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
@@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w)
/* disable BSV bit */
writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
msm_otg_start_host(otg->phy, 1);
- otg->phy->state = OTG_STATE_A_HOST;
+ otg->state = OTG_STATE_A_HOST;
} else if (test_bit(B_SESS_VLD, &motg->inputs)) {
switch (motg->chg_state) {
case USB_CHG_STATE_UNDEFINED:
@@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_notify_charger(motg,
IDEV_CHG_MAX);
msm_otg_start_peripheral(otg->phy, 1);
- otg->phy->state
+ otg->state
= OTG_STATE_B_PERIPHERAL;
break;
case USB_SDP_CHARGER:
msm_otg_notify_charger(motg, IUNIT);
msm_otg_start_peripheral(otg->phy, 1);
- otg->phy->state
+ otg->state
= OTG_STATE_B_PERIPHERAL;
break;
default:
@@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w)
motg->chg_type = USB_INVALID_CHARGER;
}

- if (otg->phy->state == OTG_STATE_B_IDLE)
+ if (otg->state == OTG_STATE_B_IDLE)
pm_runtime_put_sync(otg->phy->dev);
break;
case OTG_STATE_B_PERIPHERAL:
@@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_start_peripheral(otg->phy, 0);
motg->chg_state = USB_CHG_STATE_UNDEFINED;
motg->chg_type = USB_INVALID_CHARGER;
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy);
schedule_work(w);
}
@@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w)
dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
if (test_bit(ID, &motg->inputs)) {
msm_otg_start_host(otg->phy, 0);
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy);
schedule_work(w);
}
@@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
struct msm_otg *motg = s->private;
struct usb_otg *otg = motg->phy.otg;

- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_A_HOST:
seq_puts(s, "host\n");
break;
@@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,

switch (req_mode) {
case USB_DR_MODE_UNKNOWN:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_B_PERIPHERAL:
set_bit(ID, &motg->inputs);
@@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
}
break;
case USB_DR_MODE_PERIPHERAL:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_A_HOST:
set_bit(ID, &motg->inputs);
@@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
}
break;
case USB_DR_MODE_HOST:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_B_PERIPHERAL:
clear_bit(ID, &motg->inputs);
@@ -1775,7 +1775,7 @@ static int msm_otg_runtime_idle(struct device *dev)
* This 1 sec delay also prevents entering into LPM immediately
* after asynchronous interrupt.
*/
- if (otg->phy->state != OTG_STATE_UNDEFINED)
+ if (otg->state != OTG_STATE_UNDEFINED)
pm_schedule_suspend(dev, 1000);

return -EAGAIN;
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 7d80c54f0ac6..d6b3c473f068 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
{
struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
struct usb_phy *phy = &mvotg->phy;
- int old_state = phy->state;
+ int old_state = mvotg->phy.otg->state;

switch (old_state) {
case OTG_STATE_UNDEFINED:
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
if (otg_ctrl->id == 0)
- phy->state = OTG_STATE_A_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_A_IDLE;
else if (otg_ctrl->b_sess_vld)
- phy->state = OTG_STATE_B_PERIPHERAL;
+ mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_A_IDLE:
if (otg_ctrl->id)
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
else if (!(otg_ctrl->a_bus_drop) &&
(otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
- phy->state = OTG_STATE_A_WAIT_VRISE;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
break;
case OTG_STATE_A_WAIT_VRISE:
if (otg_ctrl->a_vbus_vld)
- phy->state = OTG_STATE_A_WAIT_BCON;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
break;
case OTG_STATE_A_WAIT_BCON:
if (otg_ctrl->id || otg_ctrl->a_bus_drop
|| otg_ctrl->a_wait_bcon_timeout) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_WAIT_VFALL;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
otg_ctrl->a_bus_req = 0;
} else if (!otg_ctrl->a_vbus_vld) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_VBUS_ERR;
+ mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
} else if (otg_ctrl->b_conn) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_HOST;
+ mvotg->phy.otg->state = OTG_STATE_A_HOST;
}
break;
case OTG_STATE_A_HOST:
if (otg_ctrl->id || !otg_ctrl->b_conn
|| otg_ctrl->a_bus_drop)
- phy->state = OTG_STATE_A_WAIT_BCON;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
else if (!otg_ctrl->a_vbus_vld)
- phy->state = OTG_STATE_A_VBUS_ERR;
+ mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
break;
case OTG_STATE_A_WAIT_VFALL:
if (otg_ctrl->id
|| (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
|| otg_ctrl->a_bus_req)
- phy->state = OTG_STATE_A_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_A_IDLE;
break;
case OTG_STATE_A_VBUS_ERR:
if (otg_ctrl->id || otg_ctrl->a_clr_err
|| otg_ctrl->a_bus_drop) {
otg_ctrl->a_clr_err = 0;
- phy->state = OTG_STATE_A_WAIT_VFALL;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
}
break;
default:
@@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work)
run:
/* work queue is single thread, or we need spin_lock to protect */
phy = &mvotg->phy;
- otg = phy->otg;
- old_state = phy->state;
+ otg = mvotg->phy.otg;
+ old_state = otg->state;

if (!mvotg->active)
return;
@@ -429,12 +429,12 @@ run:
mv_otg_update_inputs(mvotg);
mv_otg_update_state(mvotg);

- if (old_state != phy->state) {
+ if (old_state != mvotg->phy.otg->state) {
dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
state_string[old_state],
- state_string[phy->state]);
+ state_string[mvotg->phy.otg->state]);

- switch (phy->state) {
+ switch (mvotg->phy.otg->state) {
case OTG_STATE_B_IDLE:
otg->default_a = 0;
if (old_state == OTG_STATE_B_PERIPHERAL)
@@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
return -1;

/* We will use this interface to change to A device */
- if (mvotg->phy.state != OTG_STATE_B_IDLE
- && mvotg->phy.state != OTG_STATE_A_IDLE)
+ if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
+ && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
return -1;

/* The clock may disabled and we need to set irq for ID detected */
@@ -717,9 +717,9 @@ static int mv_otg_probe(struct platform_device *pdev)
mvotg->phy.dev = &pdev->dev;
mvotg->phy.otg = otg;
mvotg->phy.label = driver_name;
- mvotg->phy.state = OTG_STATE_UNDEFINED;

otg->phy = &mvotg->phy;
+ otg->state = OTG_STATE_UNDEFINED;
otg->set_host = mv_otg_set_host;
otg->set_peripheral = mv_otg_set_peripheral;
otg->set_vbus = mv_otg_set_vbus;
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 154332b7c8c0..33d3480c9cda 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -18,6 +18,8 @@ struct usb_otg {
struct usb_bus *host;
struct usb_gadget *gadget;

+ enum usb_otg_state state;
+
/* bind/unbind the host controller */
int (*set_host)(struct usb_otg *otg, struct usb_bus *host);

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 353053a33f21..ac7d7913694f 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -77,7 +77,6 @@ struct usb_phy {
unsigned int flags;

enum usb_phy_type type;
- enum usb_otg_state state;
enum usb_phy_events last_event;

struct usb_otg *otg;
--
1.9.1

2014-10-28 16:35:55

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH v7 5/7] usb: rename transceiver and phy to usb_phy in ChipIdea

This patch prepares the introduction of the generic PHY support in the
USB ChipIdea common functions. The USB PHY member of the ChipIdea
structure ('transceiver') is renamed to 'usb_phy', the 'phy' member of
the ChipIdea pdata structure is renamed to 'usb_phy' and modifications
are done in all drivers accessing it. Renaming this pointer will allow
to keep the compatibility for USB PHY drivers.

Signed-off-by: Antoine Tenart <[email protected]>
---
drivers/usb/chipidea/ci.h | 4 ++--
drivers/usb/chipidea/ci_hdrc_imx.c | 2 +-
drivers/usb/chipidea/ci_hdrc_msm.c | 8 ++++----
drivers/usb/chipidea/core.c | 20 ++++++++++----------
drivers/usb/chipidea/debug.c | 2 +-
drivers/usb/chipidea/host.c | 4 ++--
drivers/usb/chipidea/otg_fsm.c | 4 ++--
drivers/usb/chipidea/udc.c | 4 ++--
include/linux/usb/chipidea.h | 2 +-
9 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index ea40626e0246..b7f589b348e6 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -161,7 +161,7 @@ struct hw_bank {
* @test_mode: the selected test mode
* @platdata: platform specific information supplied by parent device
* @vbus_active: is VBUS active
- * @transceiver: pointer to USB PHY, if any
+ * @usb_phy: pointer to USB PHY, if any
* @hcd: pointer to usb_hcd for ehci host driver
* @debugfs: root dentry for this controller in debugfs
* @id_event: indicates there is an id event, and handled at ci_otg_work
@@ -201,7 +201,7 @@ struct ci_hdrc {

struct ci_hdrc_platform_data *platdata;
int vbus_active;
- struct usb_phy *transceiver;
+ struct usb_phy *usb_phy;
struct usb_hcd *hcd;
struct dentry *debugfs;
bool id_event;
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index a7ab0f15926e..6f8b1b1045b5 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -147,7 +147,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
goto err_clk;
}

- pdata.phy = data->phy;
+ pdata.usb_phy = data->phy;

if (imx_platform_flag->flags & CI_HDRC_IMX_IMX28_WRITE_FIX)
pdata.flags |= CI_HDRC_IMX28_WRITE_FIX;
diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c
index 4935ac38fd00..3edf969ed797 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -26,15 +26,15 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n");
writel(0, USB_AHBBURST);
writel(0, USB_AHBMODE);
- usb_phy_init(ci->transceiver);
+ usb_phy_init(ci->usb_phy);
break;
case CI_HDRC_CONTROLLER_STOPPED_EVENT:
dev_dbg(dev, "CI_HDRC_CONTROLLER_STOPPED_EVENT received\n");
/*
- * Put the transceiver in non-driving mode. Otherwise host
+ * Put the phy in non-driving mode. Otherwise host
* may not detect soft-disconnection.
*/
- usb_phy_notify_disconnect(ci->transceiver, USB_SPEED_UNKNOWN);
+ usb_phy_notify_disconnect(ci->usb_phy, USB_SPEED_UNKNOWN);
break;
default:
dev_dbg(dev, "unknown ci_hdrc event\n");
@@ -68,7 +68,7 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev)
if (IS_ERR(phy))
return PTR_ERR(phy);

- ci_hdrc_msm_platdata.phy = phy;
+ ci_hdrc_msm_platdata.usb_phy = phy;

plat_ci = ci_hdrc_add_device(&pdev->dev,
pdev->resource, pdev->num_resources,
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 3df5005c554d..b7b01694d52e 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -312,7 +312,7 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_UTMI:
case USBPHY_INTERFACE_MODE_UTMIW:
case USBPHY_INTERFACE_MODE_HSIC:
- ret = usb_phy_init(ci->transceiver);
+ ret = usb_phy_init(ci->usb_phy);
if (ret)
return ret;
hw_phymode_configure(ci);
@@ -320,12 +320,12 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_ULPI:
case USBPHY_INTERFACE_MODE_SERIAL:
hw_phymode_configure(ci);
- ret = usb_phy_init(ci->transceiver);
+ ret = usb_phy_init(ci->usb_phy);
if (ret)
return ret;
break;
default:
- ret = usb_phy_init(ci->transceiver);
+ ret = usb_phy_init(ci->usb_phy);
}

return ret;
@@ -605,13 +605,13 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}

- if (ci->platdata->phy)
- ci->transceiver = ci->platdata->phy;
+ if (ci->platdata->usb_phy)
+ ci->usb_phy = ci->platdata->usb_phy;
else
- ci->transceiver = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+ ci->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);

- if (IS_ERR(ci->transceiver)) {
- ret = PTR_ERR(ci->transceiver);
+ if (IS_ERR(ci->usb_phy)) {
+ ret = PTR_ERR(ci->usb_phy);
/*
* if -ENXIO is returned, it means PHY layer wasn't
* enabled, so it makes no sense to return -EPROBE_DEFER
@@ -728,7 +728,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
stop:
ci_role_destroy(ci);
deinit_phy:
- usb_phy_shutdown(ci->transceiver);
+ usb_phy_shutdown(ci->usb_phy);

return ret;
}
@@ -741,7 +741,7 @@ static int ci_hdrc_remove(struct platform_device *pdev)
free_irq(ci->irq, ci);
ci_role_destroy(ci);
ci_hdrc_enter_lpm(ci, true);
- usb_phy_shutdown(ci->transceiver);
+ usb_phy_shutdown(ci->usb_phy);
kfree(ci->hw_bank.regmap);

return 0;
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 8878eea38d44..8f437e1512fa 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)

/* ------ State ----- */
seq_printf(s, "OTG state: %s\n\n",
- usb_otg_state_string(ci->transceiver->otg.state));
+ usb_otg_state_string(ci->usb_phy->otg.state));

/* ------ State Machine Variables ----- */
seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index ebde7b6ce687..51b086d3bb11 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -59,7 +59,7 @@ static int host_start(struct ci_hdrc *ci)
hcd->has_tt = 1;

hcd->power_budget = ci->platdata->power_budget;
- hcd->usb_phy = ci->transceiver;
+ hcd->usb_phy = ci->usb_phy;
hcd->tpl_support = ci->platdata->tpl_support;

ehci = hcd_to_ehci(hcd);
@@ -86,7 +86,7 @@ static int host_start(struct ci_hdrc *ci)
if (ret) {
goto disable_reg;
} else {
- struct usb_otg *otg = ci->transceiver->otg;
+ struct usb_otg *otg = ci->usb_phy->otg;

ci->hcd = hcd;
if (otg) {
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index d8490e758a74..8a64ce87364e 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -788,10 +788,10 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
return -ENOMEM;
}

- otg->usb_phy = ci->transceiver;
+ otg->usb_phy = ci->usb_phy;
otg->gadget = &ci->gadget;
ci->fsm.otg = otg;
- ci->transceiver->otg = ci->fsm.otg;
+ ci->usb_phy->otg = ci->fsm.otg;
ci->fsm.power_up = 1;
ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
ci->fsm.otg->state = OTG_STATE_UNDEFINED;
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 0444d3f8971a..9af3ae0e5649 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1519,8 +1519,8 @@ static int ci_udc_vbus_draw(struct usb_gadget *_gadget, unsigned ma)
{
struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);

- if (ci->transceiver)
- return usb_phy_set_power(ci->transceiver, ma);
+ if (ci->usb_phy)
+ return usb_phy_set_power(ci->usb_phy, ma);
return -ENOTSUPP;
}

diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index e14c09a45c5a..4fe161a84c7d 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -13,7 +13,7 @@ struct ci_hdrc_platform_data {
/* offset of the capability registers */
uintptr_t capoffset;
unsigned power_budget;
- struct usb_phy *phy;
+ struct usb_phy *usb_phy;
enum usb_phy_interface phy_mode;
unsigned long flags;
#define CI_HDRC_REGS_SHARED BIT(0)
--
1.9.1

2014-10-28 16:35:53

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH v7 3/7] usb: add support to the generic PHY framework in OTG

This patch adds support of the PHY framework in OTG and keeps the USB
PHY compatibility. Here the only modification is to add PHY member in
the OTG structure, along with the USB PHY one.

Signed-off-by: Antoine Tenart <[email protected]>
---
include/linux/usb/otg.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 978fbbb0e266..52661c5da690 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -9,11 +9,14 @@
#ifndef __LINUX_USB_OTG_H
#define __LINUX_USB_OTG_H

+#include <linux/phy/phy.h>
#include <linux/usb/phy.h>

struct usb_otg {
u8 default_a;

+ struct phy *phy;
+ /* old usb_phy interface */
struct usb_phy *usb_phy;
struct usb_bus *host;
struct usb_gadget *gadget;
--
1.9.1

2014-10-28 16:35:52

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH v7 4/7] usb: allow to supply the PHY in the drivers when using HCD

This patch modify the generic code handling PHYs to allow them to be
supplied from the drivers. This adds checks to ensure no PHY was already
there when looking for one in the generic code. This also makes sure we
do not modify its state in the generic HCD functions, it was provided by
the driver.

Signed-off-by: Antoine Tenart <[email protected]>
Acked-by: Alan Stern <[email protected]>
---
drivers/usb/core/hcd.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index b84fb141e122..6a2a2fd990ab 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2648,7 +2648,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
}

- if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
+ if (IS_ENABLED(CONFIG_GENERIC_PHY) && !hcd->phy) {
struct phy *phy = phy_get(hcd->self.controller, "usb");

if (IS_ERR(phy)) {
@@ -2668,6 +2668,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
goto err_phy;
}
hcd->phy = phy;
+ hcd->remove_phy = 1;
}
}

@@ -2814,7 +2815,7 @@ err_allocate_root_hub:
err_register_bus:
hcd_buffer_destroy(hcd);
err_create_buf:
- if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->phy) {
+ if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
phy_power_off(hcd->phy);
phy_exit(hcd->phy);
phy_put(hcd->phy);
@@ -2898,7 +2899,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_deregister_bus(&hcd->self);
hcd_buffer_destroy(hcd);

- if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->phy) {
+ if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
phy_power_off(hcd->phy);
phy_exit(hcd->phy);
phy_put(hcd->phy);
--
1.9.1

2014-10-28 16:37:29

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH v7 7/7] usb: chipidea: add support to the generic PHY framework in ChipIdea

This patch adds support of the PHY framework for ChipIdea drivers.
Changes are done in both the ChipIdea common code and in the drivers
accessing the PHY. This is done by adding a new PHY member in
ChipIdea's structures and by taking care of it in the code.

Signed-off-by: Antoine Tenart <[email protected]>
---
drivers/usb/chipidea/ci.h | 5 ++-
drivers/usb/chipidea/core.c | 83 +++++++++++++++++++++++++++++++++---------
drivers/usb/chipidea/host.c | 5 ++-
drivers/usb/chipidea/otg_fsm.c | 6 ++-
include/linux/usb/chipidea.h | 2 +
5 files changed, 80 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 9015139a8027..5bbfcc73cf70 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -161,7 +161,8 @@ struct hw_bank {
* @test_mode: the selected test mode
* @platdata: platform specific information supplied by parent device
* @vbus_active: is VBUS active
- * @usb_phy: pointer to USB PHY, if any
+ * @phy: pointer to PHY, if any
+ * @usb_phy: pointer to USB PHY, if any and if using the USB PHY framework
* @hcd: pointer to usb_hcd for ehci host driver
* @debugfs: root dentry for this controller in debugfs
* @id_event: indicates there is an id event, and handled at ci_otg_work
@@ -202,6 +203,8 @@ struct ci_hdrc {

struct ci_hdrc_platform_data *platdata;
int vbus_active;
+ struct phy *phy;
+ /* old usb_phy interface */
struct usb_phy *usb_phy;
struct usb_hcd *hcd;
struct dentry *debugfs;
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index b7b01694d52e..ba0ac2723098 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -47,6 +47,7 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
+#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/idr.h>
@@ -299,6 +300,49 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
}

/**
+ * _ci_usb_phy_init: initialize phy taking in account both phy and usb_phy
+ * interfaces
+ * @ci: the controller
+ *
+ * This function returns an error code if the phy failed to init
+ */
+static int _ci_usb_phy_init(struct ci_hdrc *ci)
+{
+ int ret;
+
+ if (ci->phy) {
+ ret = phy_init(ci->phy);
+ if (ret)
+ return ret;
+
+ ret = phy_power_on(ci->phy);
+ if (ret) {
+ phy_exit(ci->phy);
+ return ret;
+ }
+ } else {
+ ret = usb_phy_init(ci->usb_phy);
+ }
+
+ return ret;
+}
+
+/**
+ * _ci_usb_phy_exit: deinitialize phy taking in account both phy and usb_phy
+ * interfaces
+ * @ci: the controller
+ */
+static void ci_usb_phy_exit(struct ci_hdrc *ci)
+{
+ if (ci->phy) {
+ phy_power_off(ci->phy);
+ phy_exit(ci->phy);
+ } else {
+ usb_phy_shutdown(ci->usb_phy);
+ }
+}
+
+/**
* ci_usb_phy_init: initialize phy according to different phy type
* @ci: the controller
*
@@ -312,7 +356,7 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_UTMI:
case USBPHY_INTERFACE_MODE_UTMIW:
case USBPHY_INTERFACE_MODE_HSIC:
- ret = usb_phy_init(ci->usb_phy);
+ ret = _ci_usb_phy_init(ci);
if (ret)
return ret;
hw_phymode_configure(ci);
@@ -320,12 +364,12 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
case USBPHY_INTERFACE_MODE_ULPI:
case USBPHY_INTERFACE_MODE_SERIAL:
hw_phymode_configure(ci);
- ret = usb_phy_init(ci->usb_phy);
+ ret = _ci_usb_phy_init(ci);
if (ret)
return ret;
break;
default:
- ret = usb_phy_init(ci->usb_phy);
+ ret = _ci_usb_phy_init(ci);
}

return ret;
@@ -605,23 +649,26 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}

- if (ci->platdata->usb_phy)
+ if (ci->platdata->phy) {
+ ci->phy = ci->platdata->phy;
+ } else if (ci->platdata->usb_phy) {
ci->usb_phy = ci->platdata->usb_phy;
- else
+ } else {
+ ci->phy = devm_phy_get(dev, "usb-phy");
ci->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);

- if (IS_ERR(ci->usb_phy)) {
- ret = PTR_ERR(ci->usb_phy);
- /*
- * if -ENXIO is returned, it means PHY layer wasn't
- * enabled, so it makes no sense to return -EPROBE_DEFER
- * in that case, since no PHY driver will ever probe.
- */
- if (ret == -ENXIO)
- return ret;
+ /* if both generic PHY and USB PHY layers aren't enabled */
+ if (PTR_ERR(ci->phy) == -ENOSYS &&
+ PTR_ERR(ci->usb_phy) == -ENXIO)
+ return -ENXIO;
+
+ if (IS_ERR(ci->phy) && IS_ERR(ci->usb_phy))
+ return -EPROBE_DEFER;

- dev_err(dev, "no usb2 phy configured\n");
- return -EPROBE_DEFER;
+ if (IS_ERR(ci->phy))
+ ci->phy = NULL;
+ else if (IS_ERR(ci->usb_phy))
+ ci->usb_phy = NULL;
}

ret = ci_usb_phy_init(ci);
@@ -728,7 +775,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
stop:
ci_role_destroy(ci);
deinit_phy:
- usb_phy_shutdown(ci->usb_phy);
+ ci_usb_phy_exit(ci);

return ret;
}
@@ -741,7 +788,7 @@ static int ci_hdrc_remove(struct platform_device *pdev)
free_irq(ci->irq, ci);
ci_role_destroy(ci);
ci_hdrc_enter_lpm(ci, true);
- usb_phy_shutdown(ci->usb_phy);
+ ci_usb_phy_exit(ci);
kfree(ci->hw_bank.regmap);

return 0;
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 789809f680aa..4f8eb40ad93a 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -59,8 +59,11 @@ static int host_start(struct ci_hdrc *ci)
hcd->has_tt = 1;

hcd->power_budget = ci->platdata->power_budget;
- hcd->usb_phy = ci->usb_phy;
hcd->tpl_support = ci->platdata->tpl_support;
+ if (ci->phy)
+ hcd->phy = ci->phy;
+ else
+ hcd->usb_phy = ci->usb_phy;

ehci = hcd_to_ehci(hcd);
ehci->caps = ci->hw_bank.cap;
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 862d7cb01b92..3c2ab1ae00fc 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -779,7 +779,11 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
{
int retval = 0;

- ci->otg.usb_phy = ci->usb_phy;
+ if (ci->phy)
+ ci->otg.phy = ci->phy;
+ else
+ ci->otg.usb_phy = ci->usb_phy;
+
ci->otg.gadget = &ci->gadget;
ci->fsm.otg = &ci->otg;
ci->fsm.power_up = 1;
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 4fe161a84c7d..c01bf4ea27b9 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -13,6 +13,8 @@ struct ci_hdrc_platform_data {
/* offset of the capability registers */
uintptr_t capoffset;
unsigned power_budget;
+ struct phy *phy;
+ /* old usb_phy interface */
struct usb_phy *usb_phy;
enum usb_phy_interface phy_mode;
unsigned long flags;
--
1.9.1

2014-10-28 16:38:30

by Antoine Tenart

[permalink] [raw]
Subject: [PATCH v7 6/7] usb: chipidea: move usb_otg into struct ci_hdrc

Move the usb_otg member from struct usb_phy to struct ci_hdrc. Rework
its initialization taking in account this modification.

Signed-off-by: Antoine Tenart <[email protected]>
Acked-by: Peter Chen <[email protected]>
---
drivers/usb/chipidea/ci.h | 1 +
drivers/usb/chipidea/debug.c | 2 +-
drivers/usb/chipidea/host.c | 5 +++--
drivers/usb/chipidea/otg_fsm.c | 16 +++-------------
4 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index b7f589b348e6..9015139a8027 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -177,6 +177,7 @@ struct ci_hdrc {
struct ci_role_driver *roles[CI_ROLE_END];
enum ci_role role;
bool is_otg;
+ struct usb_otg otg;
struct otg_fsm fsm;
struct ci_otg_fsm_timer_list *fsm_timer;
struct work_struct work;
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 8f437e1512fa..999e9d683d7a 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)

/* ------ State ----- */
seq_printf(s, "OTG state: %s\n\n",
- usb_otg_state_string(ci->usb_phy->otg.state));
+ usb_otg_state_string(ci->otg.state));

/* ------ State Machine Variables ----- */
seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 51b086d3bb11..789809f680aa 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -86,10 +86,11 @@ static int host_start(struct ci_hdrc *ci)
if (ret) {
goto disable_reg;
} else {
- struct usb_otg *otg = ci->usb_phy->otg;
+ struct usb_otg *otg = &ci->otg;

ci->hcd = hcd;
- if (otg) {
+
+ if (ci_otg_is_fsm_mode(ci)) {
otg->host = &hcd->self;
hcd->self.otg_port = 1;
}
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 8a64ce87364e..862d7cb01b92 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -778,20 +778,10 @@ void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
{
int retval = 0;
- struct usb_otg *otg;

- otg = devm_kzalloc(ci->dev,
- sizeof(struct usb_otg), GFP_KERNEL);
- if (!otg) {
- dev_err(ci->dev,
- "Failed to allocate usb_otg structure for ci hdrc otg!\n");
- return -ENOMEM;
- }
-
- otg->usb_phy = ci->usb_phy;
- otg->gadget = &ci->gadget;
- ci->fsm.otg = otg;
- ci->usb_phy->otg = ci->fsm.otg;
+ ci->otg.usb_phy = ci->usb_phy;
+ ci->otg.gadget = &ci->gadget;
+ ci->fsm.otg = &ci->otg;
ci->fsm.power_up = 1;
ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
ci->fsm.otg->state = OTG_STATE_UNDEFINED;
--
1.9.1

2014-10-28 17:43:22

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH v7 6/7] usb: chipidea: move usb_otg into struct ci_hdrc

Hello.

On 10/28/2014 07:35 PM, Antoine Tenart wrote:

> Move the usb_otg member from struct usb_phy to struct ci_hdrc. Rework

You're not reallky touching 'struct usb_phy'. ;-)

> its initialization taking in account this modification.

> Signed-off-by: Antoine Tenart <[email protected]>
> Acked-by: Peter Chen <[email protected]>

WBR, Sergei

2014-10-29 03:33:13

by Peter Chen

[permalink] [raw]
Subject: Re: [PATCH v7 0/7] usb: add support for the generic PHY framework

On Tue, Oct 28, 2014 at 05:35:34PM +0100, Antoine Tenart wrote:
> The series can be found at:
> git://git.free-electrons.com:users/antoine-tenart/linux.git usb-phy
>
> Changes since v6:
> - rebased on top of v3.18-rc2
>
> Changes since v5:
> - rebased on the latest version of Sergei's series[1]
> - fixed one modifiaction made in the wrong patch
>
> Changes since v4:
> - reworked the PHY handling in ci_hdrc_probe()
> - fixed a rebase error
>
> Changes since v3:
> - moved phy_exit() after phy_power_on()
> - fixed the PHY handling in ci_hdrc_probe()
> - some little fixes
>
> Changes since v2:
> - rebased the series on top of v3.17-rc1
> - switched to devm_phy_get() to handle non DT cases
> - moved usb_otg into the ci_hdrc structure
>
> Changes since v1:
> - rebased the series on top of [2] (generic PHY support for HCD)
> - split s/phy/usb_phy/ renaming and generic PHY support in separate
> patches
>
> [1] https://www.mail-archive.com/linux-usb%40vger.kernel.org/msg48068.html
>
> Antoine Tenart (7):
> usb: move the OTG state from the USB PHY to the OTG structure
> usb: rename phy to usb_phy in OTG
> usb: add support to the generic PHY framework in OTG
> usb: allow to supply the PHY in the drivers when using HCD
> usb: rename transceiver and phy to usb_phy in ChipIdea
> usb: chipidea: move usb_otg into struct ci_hdrc
> usb: chipidea: add support to the generic PHY framework in ChipIdea
>
> drivers/phy/phy-omap-usb2.c | 14 ++----
> drivers/usb/chipidea/ci.h | 8 +++-
> drivers/usb/chipidea/ci_hdrc_imx.c | 2 +-
> drivers/usb/chipidea/ci_hdrc_msm.c | 8 ++--
> drivers/usb/chipidea/core.c | 89 ++++++++++++++++++++++++++--------
> drivers/usb/chipidea/debug.c | 2 +-
> drivers/usb/chipidea/host.c | 10 ++--
> drivers/usb/chipidea/otg_fsm.c | 30 +++++-------
> drivers/usb/chipidea/udc.c | 4 +-
> drivers/usb/common/usb-otg-fsm.c | 8 ++--
> drivers/usb/core/hcd.c | 7 +--
> drivers/usb/host/ohci-omap.c | 2 +-
> drivers/usb/musb/am35x.c | 28 +++++------
> drivers/usb/musb/blackfin.c | 18 +++----
> drivers/usb/musb/da8xx.c | 28 +++++------
> drivers/usb/musb/davinci.c | 18 +++----
> drivers/usb/musb/musb_core.c | 94 ++++++++++++++++++------------------
> drivers/usb/musb/musb_dsps.c | 26 +++++-----
> drivers/usb/musb/musb_gadget.c | 36 +++++++-------
> drivers/usb/musb/musb_host.c | 8 ++--
> drivers/usb/musb/musb_virthub.c | 22 ++++-----
> drivers/usb/musb/omap2430.c | 30 ++++++------
> drivers/usb/musb/tusb6010.c | 40 ++++++++--------
> drivers/usb/musb/ux500.c | 10 ++--
> drivers/usb/phy/phy-ab8500-usb.c | 16 +++----
> drivers/usb/phy/phy-fsl-usb.c | 23 ++++-----
> drivers/usb/phy/phy-generic.c | 6 +--
> drivers/usb/phy/phy-gpio-vbus-usb.c | 14 +++---
> drivers/usb/phy/phy-isp1301-omap.c | 10 ++--
> drivers/usb/phy/phy-msm-usb.c | 95 +++++++++++++++++++------------------
> drivers/usb/phy/phy-mv-usb.c | 50 +++++++++----------
> drivers/usb/phy/phy-tahvo.c | 8 ++--
> drivers/usb/phy/phy-ulpi.c | 6 +--
> include/linux/usb/chipidea.h | 4 +-
> include/linux/usb/otg.h | 7 ++-
> include/linux/usb/phy.h | 1 -
> 36 files changed, 420 insertions(+), 362 deletions(-)
>
> --
> 1.9.1
>

Tested the whole patch set at imx6 hardware, and you can add
my Acked-by to the last three chipidea patches.

I hope your patch-set can be queued soon, since I find the rebase
error with my next tree, I can put your patches on the top.

--
Best Regards,
Peter Chen

2014-10-30 16:32:26

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

On Tue, Oct 28, 2014 at 05:35:35PM +0100, Antoine Tenart wrote:
> Before using the PHY framework instead of the USB PHY one, we need to
> move the OTG state into another place, since it won't be available when
> USB PHY isn't used. This patch moves the OTG state into the OTG
> structure, and makes all the needed modifications in the drivers
> using the OTG state.
>
> Signed-off-by: Antoine Tenart <[email protected]>
> Acked-by: Peter Chen <[email protected]>

Acked-by: Felipe Balbi <[email protected]>

> ---
> drivers/phy/phy-omap-usb2.c | 8 +---
> drivers/usb/chipidea/debug.c | 2 +-
> drivers/usb/chipidea/otg_fsm.c | 12 ++---
> drivers/usb/common/usb-otg-fsm.c | 8 ++--
> drivers/usb/host/ohci-omap.c | 2 +-
> drivers/usb/musb/am35x.c | 28 +++++------
> drivers/usb/musb/blackfin.c | 18 +++----
> drivers/usb/musb/da8xx.c | 28 +++++------
> drivers/usb/musb/davinci.c | 18 +++----
> drivers/usb/musb/musb_core.c | 94 ++++++++++++++++++-------------------
> drivers/usb/musb/musb_dsps.c | 26 +++++-----
> drivers/usb/musb/musb_gadget.c | 36 +++++++-------
> drivers/usb/musb/musb_host.c | 8 ++--
> drivers/usb/musb/musb_virthub.c | 22 ++++-----
> drivers/usb/musb/omap2430.c | 30 ++++++------
> drivers/usb/musb/tusb6010.c | 40 ++++++++--------
> drivers/usb/musb/ux500.c | 10 ++--
> drivers/usb/phy/phy-ab8500-usb.c | 10 ++--
> drivers/usb/phy/phy-fsl-usb.c | 10 ++--
> drivers/usb/phy/phy-generic.c | 4 +-
> drivers/usb/phy/phy-gpio-vbus-usb.c | 10 ++--
> drivers/usb/phy/phy-msm-usb.c | 34 +++++++-------
> drivers/usb/phy/phy-mv-usb.c | 46 +++++++++---------
> include/linux/usb/otg.h | 2 +
> include/linux/usb/phy.h | 1 -
> 25 files changed, 252 insertions(+), 255 deletions(-)
>
> diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
> index 8c842980834a..9f4093590f4c 100644
> --- a/drivers/phy/phy-omap-usb2.c
> +++ b/drivers/phy/phy-omap-usb2.c
> @@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)
>
> static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
> {
> - struct usb_phy *phy = otg->phy;
> -
> otg->host = host;
> if (!host)
> - phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
>
> return 0;
> }
> @@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
> static int omap_usb_set_peripheral(struct usb_otg *otg,
> struct usb_gadget *gadget)
> {
> - struct usb_phy *phy = otg->phy;
> -
> otg->gadget = gadget;
> if (!gadget)
> - phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
>
> return 0;
> }
> diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
> index 795d6538d630..8878eea38d44 100644
> --- a/drivers/usb/chipidea/debug.c
> +++ b/drivers/usb/chipidea/debug.c
> @@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)
>
> /* ------ State ----- */
> seq_printf(s, "OTG state: %s\n\n",
> - usb_otg_state_string(ci->transceiver->state));
> + usb_otg_state_string(ci->transceiver->otg.state));
>
> /* ------ State Machine Variables ----- */
> seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> index caaabc58021e..8cb2508a6b71 100644
> --- a/drivers/usb/chipidea/otg_fsm.c
> +++ b/drivers/usb/chipidea/otg_fsm.c
> @@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
> set_tmout(ci, indicator);
>
> /* only vbus fall below B_sess_vld in b_idle state */
> - if (ci->transceiver->state == OTG_STATE_B_IDLE)
> + if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
> ci_otg_queue_work(ci);
> }
>
> @@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
> * when there is no gadget class driver
> */
> if (ci->fsm.id && !(ci->driver) &&
> - ci->transceiver->state < OTG_STATE_A_IDLE)
> + ci->fsm.otg->state < OTG_STATE_A_IDLE)
> return 0;
>
> if (otg_statemachine(&ci->fsm)) {
> - if (ci->transceiver->state == OTG_STATE_A_IDLE) {
> + if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
> /*
> * Further state change for cases:
> * a_idle to b_idle; or
> @@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
> ci_otg_queue_work(ci);
> if (ci->id_event)
> ci->id_event = false;
> - } else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
> + } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
> if (ci->fsm.b_sess_vld) {
> ci->fsm.power_up = 0;
> /*
> @@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
> otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
> port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);
>
> - switch (ci->transceiver->state) {
> + switch (ci->fsm.otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> if (port_conn) {
> fsm->b_conn = 1;
> @@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
> ci->transceiver->otg = ci->fsm.otg;
> ci->fsm.power_up = 1;
> ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
> - ci->transceiver->state = OTG_STATE_UNDEFINED;
> + ci->fsm.otg->state = OTG_STATE_UNDEFINED;
> ci->fsm.ops = &ci_otg_ops;
>
> mutex_init(&ci->fsm.lock);
> diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
> index 98e8340a5bb1..c6b35b77dab7 100644
> --- a/drivers/usb/common/usb-otg-fsm.c
> +++ b/drivers/usb/common/usb-otg-fsm.c
> @@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
> static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
> {
> state_changed = 1;
> - if (fsm->otg->phy->state == new_state)
> + if (fsm->otg->state == new_state)
> return 0;
> VDBG("Set state: %s\n", usb_otg_state_string(new_state));
> - otg_leave_state(fsm, fsm->otg->phy->state);
> + otg_leave_state(fsm, fsm->otg->state);
> switch (new_state) {
> case OTG_STATE_B_IDLE:
> otg_drv_vbus(fsm, 0);
> @@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
> break;
> }
>
> - fsm->otg->phy->state = new_state;
> + fsm->otg->state = new_state;
> return 0;
> }
>
> @@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm)
>
> mutex_lock(&fsm->lock);
>
> - state = fsm->otg->phy->state;
> + state = fsm->otg->state;
> state_changed = 0;
> /* State machine state change judgement */
>
> diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
> index 0231606d47c2..cf89b4b17f14 100644
> --- a/drivers/usb/host/ohci-omap.c
> +++ b/drivers/usb/host/ohci-omap.c
> @@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
> otg_start_hnp(hcd->usb_phy->otg);
>
> local_irq_save(flags);
> - hcd->usb_phy->state = OTG_STATE_A_SUSPEND;
> + hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
> writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
> l = omap_readl(OTG_CTRL);
> l &= ~OTG_A_BUSREQ;
> diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
> index a2735df24cc6..d836a3e1f8ec 100644
> --- a/drivers/usb/musb/am35x.c
> +++ b/drivers/usb/musb/am35x.c
> @@ -149,25 +149,25 @@ static void otg_timer(unsigned long _musb)
> */
> devctl = musb_readb(mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> devctl &= ~MUSB_DEVCTL_SESSION;
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
>
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> } else {
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> }
> break;
> case OTG_STATE_A_WAIT_VFALL:
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
> MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
> break;
> @@ -176,7 +176,7 @@ static void otg_timer(unsigned long _musb)
> if (devctl & MUSB_DEVCTL_BDEVICE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> else
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> break;
> @@ -193,9 +193,9 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || (musb->a_wait_bcon == 0 &&
> - musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
> + musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&otg_workaround);
> last_timer = jiffies;
> return;
> @@ -208,7 +208,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
> last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> jiffies_to_msecs(timeout - jiffies));
> mod_timer(&otg_workaround, timeout);
> }
> @@ -278,27 +278,27 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
> * devctl.
> */
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> WARNING("VBUS error workaround (delay coming)\n");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> portstate(musb->port1_status |= USB_PORT_STAT_POWER);
> del_timer(&otg_workaround);
> } else {
> musb->is_active = 0;
> MUSB_DEV_MODE(musb);
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
> }
>
> /* NOTE: this must complete power-on within 100 ms. */
> dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
> drvvbus ? "on" : "off",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> err ? " ERROR" : "",
> devctl);
> ret = IRQ_HANDLED;
> @@ -324,7 +324,7 @@ eoi:
> }
>
> /* Poll for ID change */
> - if (musb->xceiv->state == OTG_STATE_B_IDLE)
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
>
> spin_unlock_irqrestore(&musb->lock, flags);
> diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
> index ac4422b33dcd..19a69b7f06db 100644
> --- a/drivers/usb/musb/blackfin.c
> +++ b/drivers/usb/musb/blackfin.c
> @@ -185,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
> }
>
> /* Start sampling ID pin, when plug is removed from MUSB */
> - if ((musb->xceiv->state == OTG_STATE_B_IDLE
> - || musb->xceiv->state == OTG_STATE_A_WAIT_BCON) ||
> + if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE
> + || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) ||
> (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
> mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
> musb->a_wait_bcon = TIMER_DELAY;
> @@ -205,7 +205,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
> static u8 toggle;
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_IDLE:
> case OTG_STATE_A_WAIT_BCON:
> /* Start a new session */
> @@ -219,7 +219,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
>
> if (!(val & MUSB_DEVCTL_BDEVICE)) {
> gpio_set_value(musb->config->gpio_vrsel, 1);
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> } else {
> gpio_set_value(musb->config->gpio_vrsel, 0);
> /* Ignore VBUSERROR and SUSPEND IRQ */
> @@ -229,7 +229,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
>
> val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
> musb_writeb(musb->mregs, MUSB_INTRUSB, val);
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> }
> mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
> break;
> @@ -245,7 +245,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
>
> if (!(val & MUSB_DEVCTL_BDEVICE)) {
> gpio_set_value(musb->config->gpio_vrsel, 1);
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> } else {
> gpio_set_value(musb->config->gpio_vrsel, 0);
>
> @@ -280,13 +280,13 @@ static void musb_conn_timer_handler(unsigned long _musb)
> break;
> default:
> dev_dbg(musb->controller, "%s state not handled\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> break;
> }
> spin_unlock_irqrestore(&musb->lock, flags);
>
> dev_dbg(musb->controller, "state is %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
>
> static void bfin_musb_enable(struct musb *musb)
> @@ -307,7 +307,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)
>
> dev_dbg(musb->controller, "VBUS %s, devctl %02x "
> /* otg %3x conf %08x prcm %08x */ "\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> musb_readb(musb->mregs, MUSB_DEVCTL));
> }
>
> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> index 058775e647ad..527c7fe60ece 100644
> --- a/drivers/usb/musb/da8xx.c
> +++ b/drivers/usb/musb/da8xx.c
> @@ -198,20 +198,20 @@ static void otg_timer(unsigned long _musb)
> */
> devctl = musb_readb(mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> devctl &= ~MUSB_DEVCTL_SESSION;
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
>
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> } else {
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> }
> break;
> @@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> break;
> }
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
> MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
> break;
> @@ -248,7 +248,7 @@ static void otg_timer(unsigned long _musb)
> if (devctl & MUSB_DEVCTL_BDEVICE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> else
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> break;
> @@ -265,9 +265,9 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || (musb->a_wait_bcon == 0 &&
> - musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
> + musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&otg_workaround);
> last_timer = jiffies;
> return;
> @@ -280,7 +280,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
> last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> jiffies_to_msecs(timeout - jiffies));
> mod_timer(&otg_workaround, timeout);
> }
> @@ -341,26 +341,26 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
> * devctl.
> */
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> WARNING("VBUS error workaround (delay coming)\n");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> portstate(musb->port1_status |= USB_PORT_STAT_POWER);
> del_timer(&otg_workaround);
> } else {
> musb->is_active = 0;
> MUSB_DEV_MODE(musb);
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
> }
>
> dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
> drvvbus ? "on" : "off",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> err ? " ERROR" : "",
> devctl);
> ret = IRQ_HANDLED;
> @@ -375,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
> musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
>
> /* Poll for ID change */
> - if (musb->xceiv->state == OTG_STATE_B_IDLE)
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
>
> spin_unlock_irqrestore(&musb->lock, flags);
> diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
> index 110b78415bf0..ae54188162cb 100644
> --- a/drivers/usb/musb/davinci.c
> +++ b/drivers/usb/musb/davinci.c
> @@ -214,10 +214,10 @@ static void otg_timer(unsigned long _musb)
> */
> devctl = musb_readb(mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl,
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_VFALL:
> /* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL
> * seems to mis-handle session "start" otherwise (or in our
> @@ -228,7 +228,7 @@ static void otg_timer(unsigned long _musb)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> break;
> }
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
> MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
> break;
> @@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb)
> if (devctl & MUSB_DEVCTL_BDEVICE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> else
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> break;
> @@ -325,20 +325,20 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
> * to stop registering in devctl.
> */
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> WARNING("VBUS error workaround (delay coming)\n");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> portstate(musb->port1_status |= USB_PORT_STAT_POWER);
> del_timer(&otg_workaround);
> } else {
> musb->is_active = 0;
> MUSB_DEV_MODE(musb);
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
> }
>
> @@ -348,7 +348,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
> davinci_musb_source_power(musb, drvvbus, 0);
> dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
> drvvbus ? "on" : "off",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> err ? " ERROR" : "",
> devctl);
> retval = IRQ_HANDLED;
> @@ -361,7 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
> musb_writel(tibase, DAVINCI_USB_EOI_REG, 0);
>
> /* poll for ID change */
> - if (musb->xceiv->state == OTG_STATE_B_IDLE)
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
>
> spin_unlock_irqrestore(&musb->lock, flags);
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index b841ee0bff06..77996f1d3645 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -360,23 +360,23 @@ static void musb_otg_timer_func(unsigned long data)
> unsigned long flags;
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_WAIT_ACON:
> dev_dbg(musb->controller, "HNP: b_wait_acon timeout; back to b_peripheral\n");
> musb_g_disconnect(musb);
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->is_active = 0;
> break;
> case OTG_STATE_A_SUSPEND:
> case OTG_STATE_A_WAIT_BCON:
> dev_dbg(musb->controller, "HNP: %s timeout\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> musb_platform_set_vbus(musb, 0);
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> break;
> default:
> dev_dbg(musb->controller, "HNP: Unhandled mode %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> spin_unlock_irqrestore(&musb->lock, flags);
> }
> @@ -391,19 +391,19 @@ void musb_hnp_stop(struct musb *musb)
> u8 reg;
>
> dev_dbg(musb->controller, "HNP: stop from %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_PERIPHERAL:
> musb_g_disconnect(musb);
> dev_dbg(musb->controller, "HNP: back to %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> break;
> case OTG_STATE_B_HOST:
> dev_dbg(musb->controller, "HNP: Disabling HR\n");
> if (hcd)
> hcd->self.is_b_host = 0;
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> MUSB_DEV_MODE(musb);
> reg = musb_readb(mbase, MUSB_POWER);
> reg |= MUSB_POWER_SUSPENDM;
> @@ -412,7 +412,7 @@ void musb_hnp_stop(struct musb *musb)
> break;
> default:
> dev_dbg(musb->controller, "HNP: Stopping in unknown state %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
>
> /*
> @@ -449,13 +449,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> */
> if (int_usb & MUSB_INTR_RESUME) {
> handled = IRQ_HANDLED;
> - dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->state));
> + dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->otg->state));
>
> if (devctl & MUSB_DEVCTL_HM) {
> void __iomem *mbase = musb->mregs;
> u8 power;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> /* remote wakeup? later, GetPortStatus
> * will stop RESUME signaling
> @@ -482,25 +482,25 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> &musb->finish_resume_work,
> msecs_to_jiffies(20));
>
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
> musb->is_active = 1;
> musb_host_resume_root_hub(musb);
> break;
> case OTG_STATE_B_WAIT_ACON:
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->is_active = 1;
> MUSB_DEV_MODE(musb);
> break;
> default:
> WARNING("bogus %s RESUME (%s)\n",
> "host",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> } else {
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> /* possibly DISCONNECT is upcoming */
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
> musb_host_resume_root_hub(musb);
> break;
> case OTG_STATE_B_WAIT_ACON:
> @@ -523,7 +523,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> default:
> WARNING("bogus %s RESUME (%s)\n",
> "peripheral",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
> }
> @@ -539,7 +539,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> }
>
> dev_dbg(musb->controller, "SESSION_REQUEST (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> /* IRQ arrives from ID pin sense or (later, if VBUS power
> * is removed) SRP. responses are time critical:
> @@ -550,7 +550,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> */
> musb_writeb(mbase, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
> musb->ep0_stage = MUSB_EP0_START;
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> musb_platform_set_vbus(musb, 1);
>
> @@ -576,7 +576,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> * REVISIT: do delays from lots of DEBUG_KERNEL checks
> * make trouble here, keeping VBUS < 4.4V ?
> */
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_HOST:
> /* recovery is dicey once we've gotten past the
> * initial stages of enumeration, but if VBUS
> @@ -605,7 +605,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
>
> dev_printk(ignore ? KERN_DEBUG : KERN_ERR, musb->controller,
> "VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> devctl,
> ({ char *s;
> switch (devctl & MUSB_DEVCTL_VBUS) {
> @@ -630,10 +630,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
>
> if (int_usb & MUSB_INTR_SUSPEND) {
> dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n",
> - usb_otg_state_string(musb->xceiv->state), devctl);
> + usb_otg_state_string(musb->xceiv->otg->state), devctl);
> handled = IRQ_HANDLED;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_PERIPHERAL:
> /* We also come here if the cable is removed, since
> * this silicon doesn't report ID-no-longer-grounded.
> @@ -657,7 +657,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> musb_g_suspend(musb);
> musb->is_active = musb->g.b_hnp_enable;
> if (musb->is_active) {
> - musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
> + musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
> dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
> mod_timer(&musb->otg_timer, jiffies
> + msecs_to_jiffies(
> @@ -670,7 +670,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> + msecs_to_jiffies(musb->a_wait_bcon));
> break;
> case OTG_STATE_A_HOST:
> - musb->xceiv->state = OTG_STATE_A_SUSPEND;
> + musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
> musb->is_active = musb->hcd->self.b_hnp_enable;
> break;
> case OTG_STATE_B_HOST:
> @@ -713,7 +713,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> musb->port1_status |= USB_PORT_STAT_LOW_SPEED;
>
> /* indicate new connection to OTG machine */
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_PERIPHERAL:
> if (int_usb & MUSB_INTR_SUSPEND) {
> dev_dbg(musb->controller, "HNP: SUSPEND+CONNECT, now b_host\n");
> @@ -725,7 +725,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> case OTG_STATE_B_WAIT_ACON:
> dev_dbg(musb->controller, "HNP: CONNECT, now b_host\n");
> b_host:
> - musb->xceiv->state = OTG_STATE_B_HOST;
> + musb->xceiv->otg->state = OTG_STATE_B_HOST;
> if (musb->hcd)
> musb->hcd->self.is_b_host = 1;
> del_timer(&musb->otg_timer);
> @@ -733,7 +733,7 @@ b_host:
> default:
> if ((devctl & MUSB_DEVCTL_VBUS)
> == (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
> if (hcd)
> hcd->self.is_b_host = 0;
> }
> @@ -743,16 +743,16 @@ b_host:
> musb_host_poke_root_hub(musb);
>
> dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
> - usb_otg_state_string(musb->xceiv->state), devctl);
> + usb_otg_state_string(musb->xceiv->otg->state), devctl);
> }
>
> if (int_usb & MUSB_INTR_DISCONNECT) {
> dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> MUSB_MODE(musb), devctl);
> handled = IRQ_HANDLED;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_HOST:
> case OTG_STATE_A_SUSPEND:
> musb_host_resume_root_hub(musb);
> @@ -770,7 +770,7 @@ b_host:
> musb_root_disconnect(musb);
> if (musb->hcd)
> musb->hcd->self.is_b_host = 0;
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> MUSB_DEV_MODE(musb);
> musb_g_disconnect(musb);
> break;
> @@ -786,7 +786,7 @@ b_host:
> break;
> default:
> WARNING("unhandled DISCONNECT transition (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> break;
> }
> }
> @@ -812,15 +812,15 @@ b_host:
> }
> } else {
> dev_dbg(musb->controller, "BUS RESET as %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> - switch (musb->xceiv->state) {
> + usb_otg_state_string(musb->xceiv->otg->state));
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> musb_g_reset(musb);
> /* FALLTHROUGH */
> case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
> /* never use invalid T(a_wait_bcon) */
> dev_dbg(musb->controller, "HNP: in %s, %d msec timeout\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> TA_WAIT_BCON(musb));
> mod_timer(&musb->otg_timer, jiffies
> + msecs_to_jiffies(TA_WAIT_BCON(musb)));
> @@ -831,19 +831,19 @@ b_host:
> break;
> case OTG_STATE_B_WAIT_ACON:
> dev_dbg(musb->controller, "HNP: RESET (%s), to b_peripheral\n",
> - usb_otg_state_string(musb->xceiv->state));
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + usb_otg_state_string(musb->xceiv->otg->state));
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb_g_reset(musb);
> break;
> case OTG_STATE_B_IDLE:
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> /* FALLTHROUGH */
> case OTG_STATE_B_PERIPHERAL:
> musb_g_reset(musb);
> break;
> default:
> dev_dbg(musb->controller, "Unhandled BUS RESET as %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
> }
> @@ -1630,7 +1630,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
> int ret = -EINVAL;
>
> spin_lock_irqsave(&musb->lock, flags);
> - ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->state));
> + ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->otg->state));
> spin_unlock_irqrestore(&musb->lock, flags);
>
> return ret;
> @@ -1675,7 +1675,7 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
> spin_lock_irqsave(&musb->lock, flags);
> /* force T(a_wait_bcon) to be zero/unlimited *OR* valid */
> musb->a_wait_bcon = val ? max_t(int, val, OTG_TIME_A_WAIT_BCON) : 0 ;
> - if (musb->xceiv->state == OTG_STATE_A_WAIT_BCON)
> + if (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)
> musb->is_active = 0;
> musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(val));
> spin_unlock_irqrestore(&musb->lock, flags);
> @@ -1743,8 +1743,8 @@ static void musb_irq_work(struct work_struct *data)
> {
> struct musb *musb = container_of(data, struct musb, irq_work);
>
> - if (musb->xceiv->state != musb->xceiv_old_state) {
> - musb->xceiv_old_state = musb->xceiv->state;
> + if (musb->xceiv->otg->state != musb->xceiv_old_state) {
> + musb->xceiv_old_state = musb->xceiv->otg->state;
> sysfs_notify(&musb->controller->kobj, NULL, "mode");
> }
> }
> @@ -1983,10 +1983,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
>
> if (musb->xceiv->otg->default_a) {
> MUSB_HST_MODE(musb);
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> } else {
> MUSB_DEV_MODE(musb);
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> }
>
> switch (musb->port_mode) {
> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
> index 154bcf1b5dfa..a8863f088081 100644
> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -179,9 +179,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || (musb->a_wait_bcon == 0 &&
> - musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
> + musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&glue->timer);
> glue->last_timer = jiffies;
> return;
> @@ -201,7 +201,7 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
> glue->last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> jiffies_to_msecs(timeout - jiffies));
> mod_timer(&glue->timer, timeout);
> }
> @@ -265,10 +265,10 @@ static void otg_timer(unsigned long _musb)
> */
> devctl = dsps_readb(mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
> skip_session = 1;
> @@ -277,10 +277,10 @@ static void otg_timer(unsigned long _musb)
> case OTG_STATE_A_IDLE:
> case OTG_STATE_B_IDLE:
> if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> } else {
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> }
> if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
> @@ -288,7 +288,7 @@ static void otg_timer(unsigned long _musb)
> mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
> break;
> case OTG_STATE_A_WAIT_VFALL:
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> dsps_writel(musb->ctrl_base, wrp->coreintr_set,
> MUSB_INTR_VBUSERROR << wrp->usb_shift);
> break;
> @@ -373,26 +373,26 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
> * devctl.
> */
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&glue->timer,
> jiffies + wrp->poll_seconds * HZ);
> WARNING("VBUS error workaround (delay coming)\n");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> musb->xceiv->otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> del_timer(&glue->timer);
> } else {
> musb->is_active = 0;
> MUSB_DEV_MODE(musb);
> musb->xceiv->otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> }
>
> /* NOTE: this must complete power-on within 100 ms. */
> dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
> drvvbus ? "on" : "off",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> err ? " ERROR" : "",
> devctl);
> ret = IRQ_HANDLED;
> @@ -402,7 +402,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
> ret |= musb_interrupt(musb);
>
> /* Poll for ID change in OTG port mode */
> - if (musb->xceiv->state == OTG_STATE_B_IDLE &&
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
> musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
> mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
> out:
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index 24c8c0219790..e8a237d0377c 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -1546,7 +1546,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
>
> spin_lock_irqsave(&musb->lock, flags);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_PERIPHERAL:
> /* NOTE: OTG state machine doesn't include B_SUSPENDED;
> * that's part of the standard usb 1.1 state machine, and
> @@ -1587,7 +1587,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
> goto done;
> default:
> dev_dbg(musb->controller, "Unhandled wake: %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> goto done;
> }
>
> @@ -1792,7 +1792,7 @@ int musb_gadget_setup(struct musb *musb)
>
> MUSB_DEV_MODE(musb);
> musb->xceiv->otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
>
> /* this "gadget" abstracts/virtualizes the controller */
> musb->g.name = musb_driver_name;
> @@ -1860,7 +1860,7 @@ static int musb_gadget_start(struct usb_gadget *g,
> musb->is_active = 1;
>
> otg_set_peripheral(otg, &musb->g);
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> spin_unlock_irqrestore(&musb->lock, flags);
>
> musb_start(musb);
> @@ -1945,7 +1945,7 @@ static int musb_gadget_stop(struct usb_gadget *g,
>
> (void) musb_gadget_vbus_draw(&musb->g, 0);
>
> - musb->xceiv->state = OTG_STATE_UNDEFINED;
> + musb->xceiv->otg->state = OTG_STATE_UNDEFINED;
> stop_activity(musb, driver);
> otg_set_peripheral(musb->xceiv->otg, NULL);
>
> @@ -1975,7 +1975,7 @@ static int musb_gadget_stop(struct usb_gadget *g,
> void musb_g_resume(struct musb *musb)
> {
> musb->is_suspended = 0;
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_IDLE:
> break;
> case OTG_STATE_B_WAIT_ACON:
> @@ -1989,7 +1989,7 @@ void musb_g_resume(struct musb *musb)
> break;
> default:
> WARNING("unhandled RESUME transition (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
>
> @@ -2001,10 +2001,10 @@ void musb_g_suspend(struct musb *musb)
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "devctl %02x\n", devctl);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_IDLE:
> if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> break;
> case OTG_STATE_B_PERIPHERAL:
> musb->is_suspended = 1;
> @@ -2019,7 +2019,7 @@ void musb_g_suspend(struct musb *musb)
> * A_PERIPHERAL may need care too
> */
> WARNING("unhandled SUSPEND transition (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
>
> @@ -2050,22 +2050,22 @@ void musb_g_disconnect(struct musb *musb)
> spin_lock(&musb->lock);
> }
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> default:
> dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n",
> - usb_otg_state_string(musb->xceiv->state));
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + usb_otg_state_string(musb->xceiv->otg->state));
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> break;
> case OTG_STATE_A_PERIPHERAL:
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> MUSB_HST_MODE(musb);
> break;
> case OTG_STATE_B_WAIT_ACON:
> case OTG_STATE_B_HOST:
> case OTG_STATE_B_PERIPHERAL:
> case OTG_STATE_B_IDLE:
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> break;
> case OTG_STATE_B_SRP_INIT:
> break;
> @@ -2125,13 +2125,13 @@ __acquires(musb->lock)
> * In that case, do not rely on devctl for setting
> * peripheral mode.
> */
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->g.is_a_peripheral = 0;
> } else if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->g.is_a_peripheral = 0;
> } else {
> - musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
> musb->g.is_a_peripheral = 1;
> }
>
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index 855793d701bb..23d474d3d7f4 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -2463,7 +2463,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
> if (!is_host_active(musb))
> return 0;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> return 0;
> case OTG_STATE_A_WAIT_VRISE:
> @@ -2473,7 +2473,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
> */
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> break;
> default:
> break;
> @@ -2481,7 +2481,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
>
> if (musb->is_active) {
> WARNING("trying to suspend as %s while active\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> return -EBUSY;
> } else
> return 0;
> @@ -2678,7 +2678,7 @@ int musb_host_setup(struct musb *musb, int power_budget)
>
> MUSB_HST_MODE(musb);
> musb->xceiv->otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
>
> otg_set_host(musb->xceiv->otg, &hcd->self);
> hcd->self.otg_port = 1;
> diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
> index e2d2d8c9891b..a133bd8c5dc7 100644
> --- a/drivers/usb/musb/musb_virthub.c
> +++ b/drivers/usb/musb/musb_virthub.c
> @@ -69,7 +69,7 @@ void musb_host_finish_resume(struct work_struct *work)
> musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
> usb_hcd_poll_rh_status(musb->hcd);
> /* NOTE: it might really be A_WAIT_BCON ... */
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
>
> spin_unlock_irqrestore(&musb->lock, flags);
> }
> @@ -107,9 +107,9 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
> dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);
>
> musb->port1_status |= USB_PORT_STAT_SUSPEND;
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_HOST:
> - musb->xceiv->state = OTG_STATE_A_SUSPEND;
> + musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
> musb->is_active = otg->host->b_hnp_enable;
> if (musb->is_active)
> mod_timer(&musb->otg_timer, jiffies
> @@ -118,13 +118,13 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
> musb_platform_try_idle(musb, 0);
> break;
> case OTG_STATE_B_HOST:
> - musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
> + musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
> musb->is_active = otg->host->b_hnp_enable;
> musb_platform_try_idle(musb, 0);
> break;
> default:
> dev_dbg(musb->controller, "bogus rh suspend? %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> } else if (power & MUSB_POWER_SUSPENDM) {
> power &= ~MUSB_POWER_SUSPENDM;
> @@ -145,7 +145,7 @@ void musb_port_reset(struct musb *musb, bool do_reset)
> u8 power;
> void __iomem *mbase = musb->mregs;
>
> - if (musb->xceiv->state == OTG_STATE_B_IDLE) {
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) {
> dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n");
> musb->port1_status &= ~USB_PORT_STAT_RESET;
> return;
> @@ -224,24 +224,24 @@ void musb_root_disconnect(struct musb *musb)
> usb_hcd_poll_rh_status(musb->hcd);
> musb->is_active = 0;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> if (otg->host->b_hnp_enable) {
> - musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
> musb->g.is_a_peripheral = 1;
> break;
> }
> /* FALLTHROUGH */
> case OTG_STATE_A_HOST:
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> musb->is_active = 0;
> break;
> case OTG_STATE_A_WAIT_VFALL:
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> break;
> default:
> dev_dbg(musb->controller, "host disconnect (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
>
> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> index d369bf1f3936..d1b08349f056 100644
> --- a/drivers/usb/musb/omap2430.c
> +++ b/drivers/usb/musb/omap2430.c
> @@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb)
>
> spin_lock_irqsave(&musb->lock, flags);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
>
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> } else {
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> }
> break;
> @@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb)
> musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
> usb_hcd_poll_rh_status(musb->hcd);
> /* NOTE: it might really be A_WAIT_BCON ... */
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
> }
> break;
> case OTG_STATE_A_HOST:
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if (devctl & MUSB_DEVCTL_BDEVICE)
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> else
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> default:
> break;
> }
> @@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || ((musb->a_wait_bcon == 0)
> - && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
> + && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&musb_idle_timer);
> last_timer = jiffies;
> return;
> @@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
> last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> (unsigned long)jiffies_to_msecs(timeout - jiffies));
> mod_timer(&musb_idle_timer, timeout);
> }
> @@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
>
> if (is_on) {
> - if (musb->xceiv->state == OTG_STATE_A_IDLE) {
> + if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
> int loops = 100;
> /* start the session */
> devctl |= MUSB_DEVCTL_SESSION;
> @@ -179,7 +179,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
> } else {
> musb->is_active = 1;
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> devctl |= MUSB_DEVCTL_SESSION;
> MUSB_HST_MODE(musb);
> }
> @@ -191,7 +191,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
> */
>
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> devctl &= ~MUSB_DEVCTL_SESSION;
>
> MUSB_DEV_MODE(musb);
> @@ -200,7 +200,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
>
> dev_dbg(musb->controller, "VBUS %s, devctl %02x "
> /* otg %3x conf %08x prcm %08x */ "\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> musb_readb(musb->mregs, MUSB_DEVCTL));
> }
>
> @@ -265,7 +265,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
> dev_dbg(dev, "ID GND\n");
>
> otg->default_a = true;
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> musb->xceiv->last_event = USB_EVENT_ID;
> if (musb->gadget_driver) {
> pm_runtime_get_sync(dev);
> @@ -279,7 +279,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
> dev_dbg(dev, "VBUS Connect\n");
>
> otg->default_a = false;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> musb->xceiv->last_event = USB_EVENT_VBUS;
> if (musb->gadget_driver)
> pm_runtime_get_sync(dev);
> diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
> index 2daa779f1382..8187a94fc53f 100644
> --- a/drivers/usb/musb/tusb6010.c
> +++ b/drivers/usb/musb/tusb6010.c
> @@ -415,13 +415,13 @@ static void musb_do_idle(unsigned long _musb)
>
> spin_lock_irqsave(&musb->lock, flags);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> if ((musb->a_wait_bcon != 0)
> && (musb->idle_timeout == 0
> || time_after(jiffies, musb->idle_timeout))) {
> dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> /* FALLTHROUGH */
> case OTG_STATE_A_IDLE:
> @@ -474,9 +474,9 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || ((musb->a_wait_bcon == 0)
> - && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
> + && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&musb_idle_timer);
> last_timer = jiffies;
> return;
> @@ -493,7 +493,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
> last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> (unsigned long)jiffies_to_msecs(timeout - jiffies));
> mod_timer(&musb_idle_timer, timeout);
> }
> @@ -524,7 +524,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
> if (is_on) {
> timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> devctl |= MUSB_DEVCTL_SESSION;
>
> conf |= TUSB_DEV_CONF_USB_HOST_MODE;
> @@ -537,16 +537,16 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
> /* If ID pin is grounded, we want to be a_idle */
> otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
> if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_VRISE:
> case OTG_STATE_A_WAIT_BCON:
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> break;
> case OTG_STATE_A_WAIT_VFALL:
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> }
> musb->is_active = 0;
> otg->default_a = 1;
> @@ -554,7 +554,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
> } else {
> musb->is_active = 0;
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> }
>
> @@ -569,7 +569,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
>
> dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> musb_readb(musb->mregs, MUSB_DEVCTL),
> musb_readl(tbase, TUSB_DEV_OTG_STAT),
> conf, prcm);
> @@ -668,23 +668,23 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
>
> if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
> dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n");
> - if (musb->xceiv->state != OTG_STATE_B_IDLE) {
> + if (musb->xceiv->otg->state != OTG_STATE_B_IDLE) {
> /* INTR_DISCONNECT can hide... */
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> musb->int_usb |= MUSB_INTR_DISCONNECT;
> }
> musb->is_active = 0;
> }
> dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
> - usb_otg_state_string(musb->xceiv->state), otg_stat);
> + usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
> idle_timeout = jiffies + (1 * HZ);
> schedule_work(&musb->irq_work);
>
> } else /* A-dev state machine */ {
> dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
> - usb_otg_state_string(musb->xceiv->state), otg_stat);
> + usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_IDLE:
> dev_dbg(musb->controller, "Got SRP, turning on VBUS\n");
> musb_platform_set_vbus(musb, 1);
> @@ -731,9 +731,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
> u8 devctl;
>
> dev_dbg(musb->controller, "%s timer, %03x\n",
> - usb_otg_state_string(musb->xceiv->state), otg_stat);
> + usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_VRISE:
> /* VBUS has probably been valid for a while now,
> * but may well have bounced out of range a bit
> @@ -745,7 +745,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
> dev_dbg(musb->controller, "devctl %02x\n", devctl);
> break;
> }
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> musb->is_active = 0;
> idle_timeout = jiffies
> + msecs_to_jiffies(musb->a_wait_bcon);
> diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
> index dc666e96f45f..f6c49db8dbfe 100644
> --- a/drivers/usb/musb/ux500.c
> +++ b/drivers/usb/musb/ux500.c
> @@ -56,7 +56,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
>
> if (is_on) {
> - if (musb->xceiv->state == OTG_STATE_A_IDLE) {
> + if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
> /* start the session */
> devctl |= MUSB_DEVCTL_SESSION;
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
> @@ -76,7 +76,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
> } else {
> musb->is_active = 1;
> musb->xceiv->otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> devctl |= MUSB_DEVCTL_SESSION;
> MUSB_HST_MODE(musb);
> }
> @@ -102,7 +102,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
> mdelay(200);
>
> dev_dbg(musb->controller, "VBUS %s, devctl %02x\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> musb_readb(musb->mregs, MUSB_DEVCTL));
> }
>
> @@ -112,7 +112,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
> struct musb *musb = container_of(nb, struct musb, nb);
>
> dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n",
> - event, usb_otg_state_string(musb->xceiv->state));
> + event, usb_otg_state_string(musb->xceiv->otg->state));
>
> switch (event) {
> case UX500_MUSB_ID:
> @@ -127,7 +127,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
> if (is_host_active(musb))
> ux500_musb_set_vbus(musb, 0);
> else
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> break;
> default:
> dev_dbg(musb->controller, "ID float\n");
> diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
> index 11ab2c45e462..2d5250143ce1 100644
> --- a/drivers/usb/phy/phy-ab8500-usb.c
> +++ b/drivers/usb/phy/phy-ab8500-usb.c
> @@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
> if (event != UX500_MUSB_RIDB)
> event = UX500_MUSB_NONE;
> /* Fallback to default B_IDLE as nothing is connected. */
> - ab->phy.state = OTG_STATE_B_IDLE;
> + ab->phy.otg->state = OTG_STATE_B_IDLE;
> break;
>
> case USB_LINK_ACA_RID_C_NM_9540:
> @@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
> * Fallback to default B_IDLE as nothing
> * is connected
> */
> - ab->phy.state = OTG_STATE_B_IDLE;
> + ab->phy.otg->state = OTG_STATE_B_IDLE;
> break;
>
> case USB_LINK_ACA_RID_C_NM_8540:
> @@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
> * Fallback to default B_IDLE as nothing
> * is connected
> */
> - ab->phy.state = OTG_STATE_B_IDLE;
> + ab->phy.otg->state = OTG_STATE_B_IDLE;
> break;
>
> case USB_LINK_ACA_RID_C_NM_8505:
> @@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,
> if (event != UX500_MUSB_RIDB)
> event = UX500_MUSB_NONE;
> /* Fallback to default B_IDLE as nothing is connected */
> - ab->phy.state = OTG_STATE_B_IDLE;
> + ab->phy.otg->state = OTG_STATE_B_IDLE;
> break;
>
> case USB_LINK_ACA_RID_C_NM_8500:
> @@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
> ab->phy.label = "ab8500";
> ab->phy.set_suspend = ab8500_usb_set_suspend;
> ab->phy.set_power = ab8500_usb_set_power;
> - ab->phy.state = OTG_STATE_UNDEFINED;
> + ab->phy.otg->state = OTG_STATE_UNDEFINED;
>
> otg->phy = &ab->phy;
> otg->set_host = ab8500_usb_set_host;
> diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
> index f1ea5990a50a..15d7a81eece5 100644
> --- a/drivers/usb/phy/phy-fsl-usb.c
> +++ b/drivers/usb/phy/phy-fsl-usb.c
> @@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
> /* Mini-A cable connected */
> struct otg_fsm *fsm = &otg_dev->fsm;
>
> - otg->phy->state = OTG_STATE_UNDEFINED;
> + otg.state = OTG_STATE_UNDEFINED;
> fsm->protocol = PROTO_UNDEF;
> }
> }
> @@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
> {
> if (!fsl_otg_dev)
> return -ENODEV;
> - if (phy->state == OTG_STATE_B_PERIPHERAL)
> + if (phy->otg.state == OTG_STATE_B_PERIPHERAL)
> pr_info("FSL OTG: Draw %d mA\n", mA);
>
> return 0;
> @@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
> {
> struct fsl_otg *otg_dev;
>
> - if (!otg || otg->phy->state != OTG_STATE_B_IDLE)
> + if (!otg || otg.state != OTG_STATE_B_IDLE)
> return -ENODEV;
>
> otg_dev = container_of(otg->phy, struct fsl_otg, phy);
> @@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev)
> * Also: record initial state of ID pin
> */
> if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
> - p_otg->phy.state = OTG_STATE_UNDEFINED;
> + p_otg->phy->otg.state = OTG_STATE_UNDEFINED;
> p_otg->fsm.id = 1;
> } else {
> - p_otg->phy.state = OTG_STATE_A_IDLE;
> + p_otg->phy->otg.state = OTG_STATE_A_IDLE;
> p_otg->fsm.id = 0;
> }
>
> diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
> index 7594e5069ae5..280a3458ff6b 100644
> --- a/drivers/usb/phy/phy-generic.c
> +++ b/drivers/usb/phy/phy-generic.c
> @@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
> }
>
> otg->gadget = gadget;
> - otg->phy->state = OTG_STATE_B_IDLE;
> + otg->state = OTG_STATE_B_IDLE;
> return 0;
> }
>
> @@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
> nop->phy.dev = nop->dev;
> nop->phy.label = "nop-xceiv";
> nop->phy.set_suspend = nop_set_suspend;
> - nop->phy.state = OTG_STATE_UNDEFINED;
> nop->phy.type = type;
>
> + nop->phy.otg->state = OTG_STATE_UNDEFINED;
> nop->phy.otg->phy = &nop->phy;
> nop->phy.otg->set_host = nop_set_host;
> nop->phy.otg->set_peripheral = nop_set_peripheral;
> diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
> index f4b14bd97e14..7a6be3e5dc23 100644
> --- a/drivers/usb/phy/phy-gpio-vbus-usb.c
> +++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
> @@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work)
>
> if (vbus) {
> status = USB_EVENT_VBUS;
> - gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
> + gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL;
> gpio_vbus->phy.last_event = status;
> usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);
>
> @@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work)
>
> usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
> status = USB_EVENT_NONE;
> - gpio_vbus->phy.state = OTG_STATE_B_IDLE;
> + gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE;
> gpio_vbus->phy.last_event = status;
>
> atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
> @@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
> set_vbus_draw(gpio_vbus, 0);
>
> usb_gadget_vbus_disconnect(otg->gadget);
> - otg->phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
>
> otg->gadget = NULL;
> return 0;
> @@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)
>
> gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);
>
> - if (phy->state == OTG_STATE_B_PERIPHERAL)
> + if (phy->otg->state == OTG_STATE_B_PERIPHERAL)
> set_vbus_draw(gpio_vbus, mA);
> return 0;
> }
> @@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
> gpio_vbus->phy.dev = gpio_vbus->dev;
> gpio_vbus->phy.set_power = gpio_vbus_set_power;
> gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
> - gpio_vbus->phy.state = OTG_STATE_UNDEFINED;
>
> + gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
> gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
> gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
>
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index 7843ef7dd0ff..8c22aeef0246 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
> }
>
> if (!host) {
> - if (otg->phy->state == OTG_STATE_A_HOST) {
> + if (otg->state == OTG_STATE_A_HOST) {
> pm_runtime_get_sync(otg->phy->dev);
> msm_otg_start_host(otg->phy, 0);
> otg->host = NULL;
> - otg->phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
> schedule_work(&motg->sm_work);
> } else {
> otg->host = NULL;
> @@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
> }
>
> if (!gadget) {
> - if (otg->phy->state == OTG_STATE_B_PERIPHERAL) {
> + if (otg->state == OTG_STATE_B_PERIPHERAL) {
> pm_runtime_get_sync(otg->phy->dev);
> msm_otg_start_peripheral(otg->phy, 0);
> otg->gadget = NULL;
> - otg->phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
> schedule_work(&motg->sm_work);
> } else {
> otg->gadget = NULL;
> @@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w)
> struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
> struct usb_otg *otg = motg->phy.otg;
>
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_UNDEFINED:
> dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
> msm_otg_reset(otg->phy);
> msm_otg_init_sm(motg);
> - otg->phy->state = OTG_STATE_B_IDLE;
> + otg->state = OTG_STATE_B_IDLE;
> /* FALL THROUGH */
> case OTG_STATE_B_IDLE:
> dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
> @@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w)
> /* disable BSV bit */
> writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
> msm_otg_start_host(otg->phy, 1);
> - otg->phy->state = OTG_STATE_A_HOST;
> + otg->state = OTG_STATE_A_HOST;
> } else if (test_bit(B_SESS_VLD, &motg->inputs)) {
> switch (motg->chg_state) {
> case USB_CHG_STATE_UNDEFINED:
> @@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w)
> msm_otg_notify_charger(motg,
> IDEV_CHG_MAX);
> msm_otg_start_peripheral(otg->phy, 1);
> - otg->phy->state
> + otg->state
> = OTG_STATE_B_PERIPHERAL;
> break;
> case USB_SDP_CHARGER:
> msm_otg_notify_charger(motg, IUNIT);
> msm_otg_start_peripheral(otg->phy, 1);
> - otg->phy->state
> + otg->state
> = OTG_STATE_B_PERIPHERAL;
> break;
> default:
> @@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w)
> motg->chg_type = USB_INVALID_CHARGER;
> }
>
> - if (otg->phy->state == OTG_STATE_B_IDLE)
> + if (otg->state == OTG_STATE_B_IDLE)
> pm_runtime_put_sync(otg->phy->dev);
> break;
> case OTG_STATE_B_PERIPHERAL:
> @@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w)
> msm_otg_start_peripheral(otg->phy, 0);
> motg->chg_state = USB_CHG_STATE_UNDEFINED;
> motg->chg_type = USB_INVALID_CHARGER;
> - otg->phy->state = OTG_STATE_B_IDLE;
> + otg->state = OTG_STATE_B_IDLE;
> msm_otg_reset(otg->phy);
> schedule_work(w);
> }
> @@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w)
> dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
> if (test_bit(ID, &motg->inputs)) {
> msm_otg_start_host(otg->phy, 0);
> - otg->phy->state = OTG_STATE_B_IDLE;
> + otg->state = OTG_STATE_B_IDLE;
> msm_otg_reset(otg->phy);
> schedule_work(w);
> }
> @@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
> struct msm_otg *motg = s->private;
> struct usb_otg *otg = motg->phy.otg;
>
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_A_HOST:
> seq_puts(s, "host\n");
> break;
> @@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
>
> switch (req_mode) {
> case USB_DR_MODE_UNKNOWN:
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_A_HOST:
> case OTG_STATE_B_PERIPHERAL:
> set_bit(ID, &motg->inputs);
> @@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
> }
> break;
> case USB_DR_MODE_PERIPHERAL:
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_B_IDLE:
> case OTG_STATE_A_HOST:
> set_bit(ID, &motg->inputs);
> @@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
> }
> break;
> case USB_DR_MODE_HOST:
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_B_IDLE:
> case OTG_STATE_B_PERIPHERAL:
> clear_bit(ID, &motg->inputs);
> @@ -1775,7 +1775,7 @@ static int msm_otg_runtime_idle(struct device *dev)
> * This 1 sec delay also prevents entering into LPM immediately
> * after asynchronous interrupt.
> */
> - if (otg->phy->state != OTG_STATE_UNDEFINED)
> + if (otg->state != OTG_STATE_UNDEFINED)
> pm_schedule_suspend(dev, 1000);
>
> return -EAGAIN;
> diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
> index 7d80c54f0ac6..d6b3c473f068 100644
> --- a/drivers/usb/phy/phy-mv-usb.c
> +++ b/drivers/usb/phy/phy-mv-usb.c
> @@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
> {
> struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
> struct usb_phy *phy = &mvotg->phy;
> - int old_state = phy->state;
> + int old_state = mvotg->phy.otg->state;
>
> switch (old_state) {
> case OTG_STATE_UNDEFINED:
> - phy->state = OTG_STATE_B_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_B_IDLE;
> /* FALL THROUGH */
> case OTG_STATE_B_IDLE:
> if (otg_ctrl->id == 0)
> - phy->state = OTG_STATE_A_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_A_IDLE;
> else if (otg_ctrl->b_sess_vld)
> - phy->state = OTG_STATE_B_PERIPHERAL;
> + mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
> break;
> case OTG_STATE_B_PERIPHERAL:
> if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
> - phy->state = OTG_STATE_B_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_B_IDLE;
> break;
> case OTG_STATE_A_IDLE:
> if (otg_ctrl->id)
> - phy->state = OTG_STATE_B_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_B_IDLE;
> else if (!(otg_ctrl->a_bus_drop) &&
> (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
> - phy->state = OTG_STATE_A_WAIT_VRISE;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
> break;
> case OTG_STATE_A_WAIT_VRISE:
> if (otg_ctrl->a_vbus_vld)
> - phy->state = OTG_STATE_A_WAIT_BCON;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
> break;
> case OTG_STATE_A_WAIT_BCON:
> if (otg_ctrl->id || otg_ctrl->a_bus_drop
> || otg_ctrl->a_wait_bcon_timeout) {
> mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
> mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
> - phy->state = OTG_STATE_A_WAIT_VFALL;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
> otg_ctrl->a_bus_req = 0;
> } else if (!otg_ctrl->a_vbus_vld) {
> mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
> mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
> - phy->state = OTG_STATE_A_VBUS_ERR;
> + mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
> } else if (otg_ctrl->b_conn) {
> mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
> mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
> - phy->state = OTG_STATE_A_HOST;
> + mvotg->phy.otg->state = OTG_STATE_A_HOST;
> }
> break;
> case OTG_STATE_A_HOST:
> if (otg_ctrl->id || !otg_ctrl->b_conn
> || otg_ctrl->a_bus_drop)
> - phy->state = OTG_STATE_A_WAIT_BCON;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
> else if (!otg_ctrl->a_vbus_vld)
> - phy->state = OTG_STATE_A_VBUS_ERR;
> + mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
> break;
> case OTG_STATE_A_WAIT_VFALL:
> if (otg_ctrl->id
> || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
> || otg_ctrl->a_bus_req)
> - phy->state = OTG_STATE_A_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_A_IDLE;
> break;
> case OTG_STATE_A_VBUS_ERR:
> if (otg_ctrl->id || otg_ctrl->a_clr_err
> || otg_ctrl->a_bus_drop) {
> otg_ctrl->a_clr_err = 0;
> - phy->state = OTG_STATE_A_WAIT_VFALL;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
> }
> break;
> default:
> @@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work)
> run:
> /* work queue is single thread, or we need spin_lock to protect */
> phy = &mvotg->phy;
> - otg = phy->otg;
> - old_state = phy->state;
> + otg = mvotg->phy.otg;
> + old_state = otg->state;
>
> if (!mvotg->active)
> return;
> @@ -429,12 +429,12 @@ run:
> mv_otg_update_inputs(mvotg);
> mv_otg_update_state(mvotg);
>
> - if (old_state != phy->state) {
> + if (old_state != mvotg->phy.otg->state) {
> dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
> state_string[old_state],
> - state_string[phy->state]);
> + state_string[mvotg->phy.otg->state]);
>
> - switch (phy->state) {
> + switch (mvotg->phy.otg->state) {
> case OTG_STATE_B_IDLE:
> otg->default_a = 0;
> if (old_state == OTG_STATE_B_PERIPHERAL)
> @@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
> return -1;
>
> /* We will use this interface to change to A device */
> - if (mvotg->phy.state != OTG_STATE_B_IDLE
> - && mvotg->phy.state != OTG_STATE_A_IDLE)
> + if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
> + && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
> return -1;
>
> /* The clock may disabled and we need to set irq for ID detected */
> @@ -717,9 +717,9 @@ static int mv_otg_probe(struct platform_device *pdev)
> mvotg->phy.dev = &pdev->dev;
> mvotg->phy.otg = otg;
> mvotg->phy.label = driver_name;
> - mvotg->phy.state = OTG_STATE_UNDEFINED;
>
> otg->phy = &mvotg->phy;
> + otg->state = OTG_STATE_UNDEFINED;
> otg->set_host = mv_otg_set_host;
> otg->set_peripheral = mv_otg_set_peripheral;
> otg->set_vbus = mv_otg_set_vbus;
> diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
> index 154332b7c8c0..33d3480c9cda 100644
> --- a/include/linux/usb/otg.h
> +++ b/include/linux/usb/otg.h
> @@ -18,6 +18,8 @@ struct usb_otg {
> struct usb_bus *host;
> struct usb_gadget *gadget;
>
> + enum usb_otg_state state;
> +
> /* bind/unbind the host controller */
> int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
>
> diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
> index 353053a33f21..ac7d7913694f 100644
> --- a/include/linux/usb/phy.h
> +++ b/include/linux/usb/phy.h
> @@ -77,7 +77,6 @@ struct usb_phy {
> unsigned int flags;
>
> enum usb_phy_type type;
> - enum usb_otg_state state;
> enum usb_phy_events last_event;
>
> struct usb_otg *otg;
> --
> 1.9.1
>

--
balbi


Attachments:
(No filename) (76.01 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-10-30 16:32:45

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 2/7] usb: rename phy to usb_phy in OTG

On Tue, Oct 28, 2014 at 05:35:36PM +0100, Antoine Tenart wrote:
> This patch prepares the introduction of the generic PHY support in the
> USB OTG common functions. The USB PHY member of the OTG structure is
> renamed to 'usb_phy' and modifications are done in all drivers accessing
> it. Renaming this pointer will allow to keep the compatibility for USB
> PHY drivers.
>
> Signed-off-by: Antoine Tenart <[email protected]>

Acked-by: Felipe Balbi <[email protected]>

> ---
> drivers/phy/phy-omap-usb2.c | 6 ++--
> drivers/usb/chipidea/otg_fsm.c | 2 +-
> drivers/usb/phy/phy-ab8500-usb.c | 6 ++--
> drivers/usb/phy/phy-fsl-usb.c | 13 ++++----
> drivers/usb/phy/phy-generic.c | 2 +-
> drivers/usb/phy/phy-gpio-vbus-usb.c | 4 +--
> drivers/usb/phy/phy-isp1301-omap.c | 10 +++---
> drivers/usb/phy/phy-msm-usb.c | 61 +++++++++++++++++++------------------
> drivers/usb/phy/phy-mv-usb.c | 4 +--
> drivers/usb/phy/phy-tahvo.c | 8 +++--
> drivers/usb/phy/phy-ulpi.c | 6 ++--
> include/linux/usb/otg.h | 2 +-
> 12 files changed, 65 insertions(+), 59 deletions(-)
>
> diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
> index 9f4093590f4c..32c3e86b4935 100644
> --- a/drivers/phy/phy-omap-usb2.c
> +++ b/drivers/phy/phy-omap-usb2.c
> @@ -60,7 +60,7 @@ EXPORT_SYMBOL_GPL(omap_usb2_set_comparator);
>
> static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
> {
> - struct omap_usb *phy = phy_to_omapusb(otg->phy);
> + struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);
>
> if (!phy->comparator)
> return -ENODEV;
> @@ -70,7 +70,7 @@ static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
>
> static int omap_usb_start_srp(struct usb_otg *otg)
> {
> - struct omap_usb *phy = phy_to_omapusb(otg->phy);
> + struct omap_usb *phy = phy_to_omapusb(otg->usb_phy);
>
> if (!phy->comparator)
> return -ENODEV;
> @@ -251,7 +251,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
> otg->set_vbus = omap_usb_set_vbus;
> if (phy_data->flags & OMAP_USB2_HAS_START_SRP)
> otg->start_srp = omap_usb_start_srp;
> - otg->phy = &phy->phy;
> + otg->usb_phy = &phy->phy;
>
> platform_set_drvdata(pdev, phy);
>
> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> index 8cb2508a6b71..d8490e758a74 100644
> --- a/drivers/usb/chipidea/otg_fsm.c
> +++ b/drivers/usb/chipidea/otg_fsm.c
> @@ -788,7 +788,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
> return -ENOMEM;
> }
>
> - otg->phy = ci->transceiver;
> + otg->usb_phy = ci->transceiver;
> otg->gadget = &ci->gadget;
> ci->fsm.otg = otg;
> ci->transceiver->otg = ci->fsm.otg;
> diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
> index 2d5250143ce1..3a802fa7dae2 100644
> --- a/drivers/usb/phy/phy-ab8500-usb.c
> +++ b/drivers/usb/phy/phy-ab8500-usb.c
> @@ -1056,7 +1056,7 @@ static int ab8500_usb_set_peripheral(struct usb_otg *otg,
> if (!otg)
> return -ENODEV;
>
> - ab = phy_to_ab(otg->phy);
> + ab = phy_to_ab(otg->usb_phy);
>
> ab->phy.otg->gadget = gadget;
>
> @@ -1080,7 +1080,7 @@ static int ab8500_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
> if (!otg)
> return -ENODEV;
>
> - ab = phy_to_ab(otg->phy);
> + ab = phy_to_ab(otg->usb_phy);
>
> ab->phy.otg->host = host;
>
> @@ -1382,7 +1382,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
> ab->phy.set_power = ab8500_usb_set_power;
> ab->phy.otg->state = OTG_STATE_UNDEFINED;
>
> - otg->phy = &ab->phy;
> + otg->usb_phy = &ab->phy;
> otg->set_host = ab8500_usb_set_host;
> otg->set_peripheral = ab8500_usb_set_peripheral;
>
> diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
> index 15d7a81eece5..b7f36b212422 100644
> --- a/drivers/usb/phy/phy-fsl-usb.c
> +++ b/drivers/usb/phy/phy-fsl-usb.c
> @@ -499,7 +499,8 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
> {
> struct usb_otg *otg = fsm->otg;
> struct device *dev;
> - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy);
> + struct fsl_otg *otg_dev =
> + container_of(otg->usb_phy, struct fsl_otg, phy);
> u32 retval = 0;
>
> if (!otg->host)
> @@ -594,7 +595,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
> if (!otg)
> return -ENODEV;
>
> - otg_dev = container_of(otg->phy, struct fsl_otg, phy);
> + otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy);
> if (otg_dev != fsl_otg_dev)
> return -ENODEV;
>
> @@ -644,7 +645,7 @@ static int fsl_otg_set_peripheral(struct usb_otg *otg,
> if (!otg)
> return -ENODEV;
>
> - otg_dev = container_of(otg->phy, struct fsl_otg, phy);
> + otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy);
> VDBG("otg_dev 0x%x\n", (int)otg_dev);
> VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev);
> if (otg_dev != fsl_otg_dev)
> @@ -717,7 +718,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
> if (!otg || otg.state != OTG_STATE_B_IDLE)
> return -ENODEV;
>
> - otg_dev = container_of(otg->phy, struct fsl_otg, phy);
> + otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy);
> if (otg_dev != fsl_otg_dev)
> return -ENODEV;
>
> @@ -735,7 +736,7 @@ static int fsl_otg_start_hnp(struct usb_otg *otg)
> if (!otg)
> return -ENODEV;
>
> - otg_dev = container_of(otg->phy, struct fsl_otg, phy);
> + otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy);
> if (otg_dev != fsl_otg_dev)
> return -ENODEV;
>
> @@ -857,7 +858,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
> fsl_otg_tc->phy.dev = &pdev->dev;
> fsl_otg_tc->phy.set_power = fsl_otg_set_power;
>
> - fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy;
> + fsl_otg_tc->phy.otg->usb_phy = &fsl_otg_tc->phy;
> fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host;
> fsl_otg_tc->phy.otg->set_peripheral = fsl_otg_set_peripheral;
> fsl_otg_tc->phy.otg->start_hnp = fsl_otg_start_hnp;
> diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
> index 280a3458ff6b..0c01bd12cabc 100644
> --- a/drivers/usb/phy/phy-generic.c
> +++ b/drivers/usb/phy/phy-generic.c
> @@ -228,7 +228,7 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
> nop->phy.type = type;
>
> nop->phy.otg->state = OTG_STATE_UNDEFINED;
> - nop->phy.otg->phy = &nop->phy;
> + nop->phy.otg->usb_phy = &nop->phy;
> nop->phy.otg->set_host = nop_set_host;
> nop->phy.otg->set_peripheral = nop_set_peripheral;
>
> diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
> index 7a6be3e5dc23..9fcf19ba1416 100644
> --- a/drivers/usb/phy/phy-gpio-vbus-usb.c
> +++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
> @@ -180,7 +180,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
> struct platform_device *pdev;
> int gpio;
>
> - gpio_vbus = container_of(otg->phy, struct gpio_vbus_data, phy);
> + gpio_vbus = container_of(otg->usb_phy, struct gpio_vbus_data, phy);
> pdev = to_platform_device(gpio_vbus->dev);
> pdata = dev_get_platdata(gpio_vbus->dev);
> gpio = pdata->gpio_pullup;
> @@ -271,7 +271,7 @@ static int gpio_vbus_probe(struct platform_device *pdev)
> gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
>
> gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
> - gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
> + gpio_vbus->phy.otg->usb_phy = &gpio_vbus->phy;
> gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
>
> err = devm_gpio_request(&pdev->dev, gpio, "vbus_detect");
> diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c
> index 8eea56d3ded6..dc2f41eb8b75 100644
> --- a/drivers/usb/phy/phy-isp1301-omap.c
> +++ b/drivers/usb/phy/phy-isp1301-omap.c
> @@ -1275,7 +1275,7 @@ static int isp1301_otg_enable(struct isp1301 *isp)
> static int
> isp1301_set_host(struct usb_otg *otg, struct usb_bus *host)
> {
> - struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
> + struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy);
>
> if (isp != the_transceiver)
> return -ENODEV;
> @@ -1331,7 +1331,7 @@ isp1301_set_host(struct usb_otg *otg, struct usb_bus *host)
> static int
> isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
> {
> - struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
> + struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy);
>
> if (isp != the_transceiver)
> return -ENODEV;
> @@ -1411,7 +1411,7 @@ isp1301_set_power(struct usb_phy *dev, unsigned mA)
> static int
> isp1301_start_srp(struct usb_otg *otg)
> {
> - struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
> + struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy);
> u32 otg_ctrl;
>
> if (isp != the_transceiver || isp->phy.state != OTG_STATE_B_IDLE)
> @@ -1438,7 +1438,7 @@ static int
> isp1301_start_hnp(struct usb_otg *otg)
> {
> #ifdef CONFIG_USB_OTG
> - struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
> + struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy);
> u32 l;
>
> if (isp != the_transceiver)
> @@ -1583,7 +1583,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
> isp->phy.label = DRIVER_NAME;
> isp->phy.set_power = isp1301_set_power,
>
> - isp->phy.otg->phy = &isp->phy;
> + isp->phy.otg->usb_phy = &isp->phy;
> isp->phy.otg->set_host = isp1301_set_host,
> isp->phy.otg->set_peripheral = isp1301_set_peripheral,
> isp->phy.otg->start_srp = isp1301_start_srp,
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index 8c22aeef0246..0d35b17c97fb 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -708,7 +708,7 @@ static void msm_otg_start_host(struct usb_phy *phy, int on)
>
> static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
> {
> - struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy);
> + struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy);
> struct usb_hcd *hcd;
>
> /*
> @@ -716,14 +716,14 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
> * only peripheral configuration.
> */
> if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) {
> - dev_info(otg->phy->dev, "Host mode is not supported\n");
> + dev_info(otg->usb_phy->dev, "Host mode is not supported\n");
> return -ENODEV;
> }
>
> if (!host) {
> if (otg->state == OTG_STATE_A_HOST) {
> - pm_runtime_get_sync(otg->phy->dev);
> - msm_otg_start_host(otg->phy, 0);
> + pm_runtime_get_sync(otg->usb_phy->dev);
> + msm_otg_start_host(otg->usb_phy, 0);
> otg->host = NULL;
> otg->state = OTG_STATE_UNDEFINED;
> schedule_work(&motg->sm_work);
> @@ -738,14 +738,14 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
> hcd->power_budget = motg->pdata->power_budget;
>
> otg->host = host;
> - dev_dbg(otg->phy->dev, "host driver registered w/ tranceiver\n");
> + dev_dbg(otg->usb_phy->dev, "host driver registered w/ tranceiver\n");
>
> /*
> * Kick the state machine work, if peripheral is not supported
> * or peripheral is already registered with us.
> */
> if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
> - pm_runtime_get_sync(otg->phy->dev);
> + pm_runtime_get_sync(otg->usb_phy->dev);
> schedule_work(&motg->sm_work);
> }
>
> @@ -782,21 +782,21 @@ static void msm_otg_start_peripheral(struct usb_phy *phy, int on)
> static int msm_otg_set_peripheral(struct usb_otg *otg,
> struct usb_gadget *gadget)
> {
> - struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy);
> + struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy);
>
> /*
> * Fail peripheral registration if this board can support
> * only host configuration.
> */
> if (motg->pdata->mode == USB_DR_MODE_HOST) {
> - dev_info(otg->phy->dev, "Peripheral mode is not supported\n");
> + dev_info(otg->usb_phy->dev, "Peripheral mode is not supported\n");
> return -ENODEV;
> }
>
> if (!gadget) {
> if (otg->state == OTG_STATE_B_PERIPHERAL) {
> - pm_runtime_get_sync(otg->phy->dev);
> - msm_otg_start_peripheral(otg->phy, 0);
> + pm_runtime_get_sync(otg->usb_phy->dev);
> + msm_otg_start_peripheral(otg->usb_phy, 0);
> otg->gadget = NULL;
> otg->state = OTG_STATE_UNDEFINED;
> schedule_work(&motg->sm_work);
> @@ -807,14 +807,15 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
> return 0;
> }
> otg->gadget = gadget;
> - dev_dbg(otg->phy->dev, "peripheral driver registered w/ tranceiver\n");
> + dev_dbg(otg->usb_phy->dev,
> + "peripheral driver registered w/ tranceiver\n");
>
> /*
> * Kick the state machine work, if host is not supported
> * or host is already registered with us.
> */
> if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
> - pm_runtime_get_sync(otg->phy->dev);
> + pm_runtime_get_sync(otg->usb_phy->dev);
> schedule_work(&motg->sm_work);
> }
>
> @@ -1172,17 +1173,17 @@ static void msm_otg_sm_work(struct work_struct *w)
>
> switch (otg->state) {
> case OTG_STATE_UNDEFINED:
> - dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
> - msm_otg_reset(otg->phy);
> + dev_dbg(otg->usb_phy->dev, "OTG_STATE_UNDEFINED state\n");
> + msm_otg_reset(otg->usb_phy);
> msm_otg_init_sm(motg);
> otg->state = OTG_STATE_B_IDLE;
> /* FALL THROUGH */
> case OTG_STATE_B_IDLE:
> - dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
> + dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_IDLE state\n");
> if (!test_bit(ID, &motg->inputs) && otg->host) {
> /* disable BSV bit */
> writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
> - msm_otg_start_host(otg->phy, 1);
> + msm_otg_start_host(otg->usb_phy, 1);
> otg->state = OTG_STATE_A_HOST;
> } else if (test_bit(B_SESS_VLD, &motg->inputs)) {
> switch (motg->chg_state) {
> @@ -1198,13 +1199,15 @@ static void msm_otg_sm_work(struct work_struct *w)
> case USB_CDP_CHARGER:
> msm_otg_notify_charger(motg,
> IDEV_CHG_MAX);
> - msm_otg_start_peripheral(otg->phy, 1);
> + msm_otg_start_peripheral(otg->usb_phy,
> + 1);
> otg->state
> = OTG_STATE_B_PERIPHERAL;
> break;
> case USB_SDP_CHARGER:
> msm_otg_notify_charger(motg, IUNIT);
> - msm_otg_start_peripheral(otg->phy, 1);
> + msm_otg_start_peripheral(otg->usb_phy,
> + 1);
> otg->state
> = OTG_STATE_B_PERIPHERAL;
> break;
> @@ -1222,8 +1225,8 @@ static void msm_otg_sm_work(struct work_struct *w)
> * is incremented in charger detection work.
> */
> if (cancel_delayed_work_sync(&motg->chg_work)) {
> - pm_runtime_put_sync(otg->phy->dev);
> - msm_otg_reset(otg->phy);
> + pm_runtime_put_sync(otg->usb_phy->dev);
> + msm_otg_reset(otg->usb_phy);
> }
> msm_otg_notify_charger(motg, 0);
> motg->chg_state = USB_CHG_STATE_UNDEFINED;
> @@ -1231,27 +1234,27 @@ static void msm_otg_sm_work(struct work_struct *w)
> }
>
> if (otg->state == OTG_STATE_B_IDLE)
> - pm_runtime_put_sync(otg->phy->dev);
> + pm_runtime_put_sync(otg->usb_phy->dev);
> break;
> case OTG_STATE_B_PERIPHERAL:
> - dev_dbg(otg->phy->dev, "OTG_STATE_B_PERIPHERAL state\n");
> + dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_PERIPHERAL state\n");
> if (!test_bit(B_SESS_VLD, &motg->inputs) ||
> !test_bit(ID, &motg->inputs)) {
> msm_otg_notify_charger(motg, 0);
> - msm_otg_start_peripheral(otg->phy, 0);
> + msm_otg_start_peripheral(otg->usb_phy, 0);
> motg->chg_state = USB_CHG_STATE_UNDEFINED;
> motg->chg_type = USB_INVALID_CHARGER;
> otg->state = OTG_STATE_B_IDLE;
> - msm_otg_reset(otg->phy);
> + msm_otg_reset(otg->usb_phy);
> schedule_work(w);
> }
> break;
> case OTG_STATE_A_HOST:
> - dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
> + dev_dbg(otg->usb_phy->dev, "OTG_STATE_A_HOST state\n");
> if (test_bit(ID, &motg->inputs)) {
> - msm_otg_start_host(otg->phy, 0);
> + msm_otg_start_host(otg->usb_phy, 0);
> otg->state = OTG_STATE_B_IDLE;
> - msm_otg_reset(otg->phy);
> + msm_otg_reset(otg->usb_phy);
> schedule_work(w);
> }
> break;
> @@ -1388,7 +1391,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
> goto out;
> }
>
> - pm_runtime_get_sync(otg->phy->dev);
> + pm_runtime_get_sync(otg->usb_phy->dev);
> schedule_work(&motg->sm_work);
> out:
> return status;
> @@ -1674,7 +1677,7 @@ static int msm_otg_probe(struct platform_device *pdev)
>
> phy->io_ops = &msm_otg_io_ops;
>
> - phy->otg->phy = &motg->phy;
> + phy->otg->usb_phy = &motg->phy;
> phy->otg->set_host = msm_otg_set_host;
> phy->otg->set_peripheral = msm_otg_set_peripheral;
>
> diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
> index d6b3c473f068..d948275d55e5 100644
> --- a/drivers/usb/phy/phy-mv-usb.c
> +++ b/drivers/usb/phy/phy-mv-usb.c
> @@ -56,7 +56,7 @@ static char *state_string[] = {
>
> static int mv_otg_set_vbus(struct usb_otg *otg, bool on)
> {
> - struct mv_otg *mvotg = container_of(otg->phy, struct mv_otg, phy);
> + struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, phy);
> if (mvotg->pdata->set_vbus == NULL)
> return -ENODEV;
>
> @@ -718,8 +718,8 @@ static int mv_otg_probe(struct platform_device *pdev)
> mvotg->phy.otg = otg;
> mvotg->phy.label = driver_name;
>
> - otg->phy = &mvotg->phy;
> otg->state = OTG_STATE_UNDEFINED;
> + otg->usb_phy = &mvotg->phy;
> otg->set_host = mv_otg_set_host;
> otg->set_peripheral = mv_otg_set_peripheral;
> otg->set_vbus = mv_otg_set_vbus;
> diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
> index cc61ee44b911..402e6af29c65 100644
> --- a/drivers/usb/phy/phy-tahvo.c
> +++ b/drivers/usb/phy/phy-tahvo.c
> @@ -196,7 +196,8 @@ static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend)
>
> static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
> {
> - struct tahvo_usb *tu = container_of(otg->phy, struct tahvo_usb, phy);
> + struct tahvo_usb *tu = container_of(otg->usb_phy, struct tahvo_usb,
> + phy);
>
> dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, host);
>
> @@ -225,7 +226,8 @@ static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
> static int tahvo_usb_set_peripheral(struct usb_otg *otg,
> struct usb_gadget *gadget)
> {
> - struct tahvo_usb *tu = container_of(otg->phy, struct tahvo_usb, phy);
> + struct tahvo_usb *tu = container_of(otg->usb_phy, struct tahvo_usb,
> + phy);
>
> dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, gadget);
>
> @@ -383,7 +385,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
> tu->phy.label = DRIVER_NAME;
> tu->phy.set_suspend = tahvo_usb_set_suspend;
>
> - tu->phy.otg->phy = &tu->phy;
> + tu->phy.otg->usb_phy = &tu->phy;
> tu->phy.otg->set_host = tahvo_usb_set_host;
> tu->phy.otg->set_peripheral = tahvo_usb_set_peripheral;
>
> diff --git a/drivers/usb/phy/phy-ulpi.c b/drivers/usb/phy/phy-ulpi.c
> index 4e3877c329f2..f48a7a21e3c2 100644
> --- a/drivers/usb/phy/phy-ulpi.c
> +++ b/drivers/usb/phy/phy-ulpi.c
> @@ -211,7 +211,7 @@ static int ulpi_init(struct usb_phy *phy)
>
> static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host)
> {
> - struct usb_phy *phy = otg->phy;
> + struct usb_phy *phy = otg->usb_phy;
> unsigned int flags = usb_phy_io_read(phy, ULPI_IFC_CTRL);
>
> if (!host) {
> @@ -237,7 +237,7 @@ static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host)
>
> static int ulpi_set_vbus(struct usb_otg *otg, bool on)
> {
> - struct usb_phy *phy = otg->phy;
> + struct usb_phy *phy = otg->usb_phy;
> unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL);
>
> flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
> @@ -276,7 +276,7 @@ otg_ulpi_create(struct usb_phy_io_ops *ops,
> phy->otg = otg;
> phy->init = ulpi_init;
>
> - otg->phy = phy;
> + otg->usb_phy = phy;
> otg->set_host = ulpi_set_host;
> otg->set_vbus = ulpi_set_vbus;
>
> diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
> index 33d3480c9cda..978fbbb0e266 100644
> --- a/include/linux/usb/otg.h
> +++ b/include/linux/usb/otg.h
> @@ -14,7 +14,7 @@
> struct usb_otg {
> u8 default_a;
>
> - struct usb_phy *phy;
> + struct usb_phy *usb_phy;
> struct usb_bus *host;
> struct usb_gadget *gadget;
>
> --
> 1.9.1
>

--
balbi


Attachments:
(No filename) (20.17 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-10-30 16:33:23

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 0/7] usb: add support for the generic PHY framework

Hi,

On Tue, Oct 28, 2014 at 05:35:34PM +0100, Antoine Tenart wrote:
> The series can be found at:
> git://git.free-electrons.com:users/antoine-tenart/linux.git usb-phy
>
> Changes since v6:
> - rebased on top of v3.18-rc2
>
> Changes since v5:
> - rebased on the latest version of Sergei's series[1]
> - fixed one modifiaction made in the wrong patch
>
> Changes since v4:
> - reworked the PHY handling in ci_hdrc_probe()
> - fixed a rebase error
>
> Changes since v3:
> - moved phy_exit() after phy_power_on()
> - fixed the PHY handling in ci_hdrc_probe()
> - some little fixes
>
> Changes since v2:
> - rebased the series on top of v3.17-rc1
> - switched to devm_phy_get() to handle non DT cases
> - moved usb_otg into the ci_hdrc structure
>
> Changes since v1:
> - rebased the series on top of [2] (generic PHY support for HCD)
> - split s/phy/usb_phy/ renaming and generic PHY support in separate
> patches
>
> [1] https://www.mail-archive.com/linux-usb%40vger.kernel.org/msg48068.html
>
> Antoine Tenart (7):
> usb: move the OTG state from the USB PHY to the OTG structure
> usb: rename phy to usb_phy in OTG
> usb: add support to the generic PHY framework in OTG
> usb: allow to supply the PHY in the drivers when using HCD
> usb: rename transceiver and phy to usb_phy in ChipIdea
> usb: chipidea: move usb_otg into struct ci_hdrc
> usb: chipidea: add support to the generic PHY framework in ChipIdea

quick question, who do you guys want this patchset to go through ? If
it's me, I can take them no problem.

--
balbi


Attachments:
(No filename) (1.62 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-10-30 16:35:45

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

On Thu, Oct 30, 2014 at 11:31:48AM -0500, Felipe Balbi wrote:
> On Tue, Oct 28, 2014 at 05:35:35PM +0100, Antoine Tenart wrote:
> > Before using the PHY framework instead of the USB PHY one, we need to
> > move the OTG state into another place, since it won't be available when
> > USB PHY isn't used. This patch moves the OTG state into the OTG
> > structure, and makes all the needed modifications in the drivers
> > using the OTG state.
> >
> > Signed-off-by: Antoine Tenart <[email protected]>
> > Acked-by: Peter Chen <[email protected]>
>
> Acked-by: Felipe Balbi <[email protected]>

fails to apply:

$ patch -p1 --dry-run < patch.diff
checking file drivers/phy/phy-omap-usb2.c
checking file drivers/usb/chipidea/debug.c
checking file drivers/usb/chipidea/otg_fsm.c
checking file drivers/usb/common/usb-otg-fsm.c
checking file drivers/usb/host/ohci-omap.c
checking file drivers/usb/musb/am35x.c
checking file drivers/usb/musb/blackfin.c
checking file drivers/usb/musb/da8xx.c
checking file drivers/usb/musb/davinci.c
checking file drivers/usb/musb/musb_core.c
checking file drivers/usb/musb/musb_dsps.c
checking file drivers/usb/musb/musb_gadget.c
Hunk #3 succeeded at 1791 (offset -1 lines).
Hunk #4 succeeded at 1857 (offset -3 lines).
Hunk #5 FAILED at 1945.
Hunk #6 succeeded at 1968 (offset -7 lines).
Hunk #7 succeeded at 1982 (offset -7 lines).
Hunk #8 succeeded at 1994 (offset -7 lines).
Hunk #9 succeeded at 2012 (offset -7 lines).
Hunk #10 succeeded at 2043 (offset -7 lines).
Hunk #11 succeeded at 2118 (offset -7 lines).
1 out of 11 hunks FAILED
checking file drivers/usb/musb/musb_host.c
checking file drivers/usb/musb/musb_virthub.c
checking file drivers/usb/musb/omap2430.c
Hunk #6 succeeded at 180 (offset 1 line).
Hunk #7 succeeded at 192 (offset 1 line).
Hunk #8 succeeded at 201 (offset 1 line).
Hunk #9 succeeded at 266 (offset 1 line).
Hunk #10 succeeded at 280 (offset 1 line).
checking file drivers/usb/musb/tusb6010.c
checking file drivers/usb/musb/ux500.c
checking file drivers/usb/phy/phy-ab8500-usb.c
checking file drivers/usb/phy/phy-fsl-usb.c
checking file drivers/usb/phy/phy-generic.c
checking file drivers/usb/phy/phy-gpio-vbus-usb.c
checking file drivers/usb/phy/phy-msm-usb.c
Hunk #13 succeeded at 1769 (offset -6 lines).
checking file drivers/usb/phy/phy-mv-usb.c
Hunk #5 succeeded at 715 (offset -2 lines).
checking file include/linux/usb/otg.h
checking file include/linux/usb/phy.h

Please rebase on my testing/next and I'll take the series. When
rebasing, then add Peter's Tested-by/Acked-by where they're missing.

cheers

--
balbi


Attachments:
(No filename) (2.54 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-10-30 17:43:06

by Antoine Tenart

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

Hi Felipe,

On Thu, Oct 30, 2014 at 11:35:13AM -0500, Felipe Balbi wrote:
> On Thu, Oct 30, 2014 at 11:31:48AM -0500, Felipe Balbi wrote:
> > On Tue, Oct 28, 2014 at 05:35:35PM +0100, Antoine Tenart wrote:
> > > Before using the PHY framework instead of the USB PHY one, we need to
> > > move the OTG state into another place, since it won't be available when
> > > USB PHY isn't used. This patch moves the OTG state into the OTG
> > > structure, and makes all the needed modifications in the drivers
> > > using the OTG state.
> > >
> > > Signed-off-by: Antoine Tenart <[email protected]>
> > > Acked-by: Peter Chen <[email protected]>
> >
> > Acked-by: Felipe Balbi <[email protected]>
>
> Please rebase on my testing/next and I'll take the series. When
> rebasing, then add Peter's Tested-by/Acked-by where they're missing.

I just re-sent the series, rebased on your testing/next branch.

Antoine

--
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

2014-10-30 17:48:08

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

On Thu, Oct 30, 2014 at 06:42:54PM +0100, Antoine Tenart wrote:
> Hi Felipe,
>
> On Thu, Oct 30, 2014 at 11:35:13AM -0500, Felipe Balbi wrote:
> > On Thu, Oct 30, 2014 at 11:31:48AM -0500, Felipe Balbi wrote:
> > > On Tue, Oct 28, 2014 at 05:35:35PM +0100, Antoine Tenart wrote:
> > > > Before using the PHY framework instead of the USB PHY one, we need to
> > > > move the OTG state into another place, since it won't be available when
> > > > USB PHY isn't used. This patch moves the OTG state into the OTG
> > > > structure, and makes all the needed modifications in the drivers
> > > > using the OTG state.
> > > >
> > > > Signed-off-by: Antoine Tenart <[email protected]>
> > > > Acked-by: Peter Chen <[email protected]>
> > >
> > > Acked-by: Felipe Balbi <[email protected]>
> >
> > Please rebase on my testing/next and I'll take the series. When
> > rebasing, then add Peter's Tested-by/Acked-by where they're missing.
>
> I just re-sent the series, rebased on your testing/next branch.

Thanks, I put them on my testing/next and I'm running build tests.

--
balbi


Attachments:
(No filename) (1.07 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-10-31 00:38:28

by Peter Chen

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

On Thu, Oct 30, 2014 at 12:47:34PM -0500, Felipe Balbi wrote:
> On Thu, Oct 30, 2014 at 06:42:54PM +0100, Antoine Tenart wrote:
> > Hi Felipe,
> >
> > On Thu, Oct 30, 2014 at 11:35:13AM -0500, Felipe Balbi wrote:
> > > On Thu, Oct 30, 2014 at 11:31:48AM -0500, Felipe Balbi wrote:
> > > > On Tue, Oct 28, 2014 at 05:35:35PM +0100, Antoine Tenart wrote:
> > > > > Before using the PHY framework instead of the USB PHY one, we need to
> > > > > move the OTG state into another place, since it won't be available when
> > > > > USB PHY isn't used. This patch moves the OTG state into the OTG
> > > > > structure, and makes all the needed modifications in the drivers
> > > > > using the OTG state.
> > > > >
> > > > > Signed-off-by: Antoine Tenart <[email protected]>
> > > > > Acked-by: Peter Chen <[email protected]>
> > > >
> > > > Acked-by: Felipe Balbi <[email protected]>
> > >
> > > Please rebase on my testing/next and I'll take the series. When
> > > rebasing, then add Peter's Tested-by/Acked-by where they're missing.
> >
> > I just re-sent the series, rebased on your testing/next branch.
>
> Thanks, I put them on my testing/next and I'm running build tests.
>

I see them, I will rebase your testing/next tree for coming chipidea dev, thanks.

--
Best Regards,
Peter Chen

2014-10-31 00:47:59

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

Hi,

On Fri, Oct 31, 2014 at 08:38:14AM +0800, Peter Chen wrote:
> On Thu, Oct 30, 2014 at 12:47:34PM -0500, Felipe Balbi wrote:
> > On Thu, Oct 30, 2014 at 06:42:54PM +0100, Antoine Tenart wrote:
> > > Hi Felipe,
> > >
> > > On Thu, Oct 30, 2014 at 11:35:13AM -0500, Felipe Balbi wrote:
> > > > On Thu, Oct 30, 2014 at 11:31:48AM -0500, Felipe Balbi wrote:
> > > > > On Tue, Oct 28, 2014 at 05:35:35PM +0100, Antoine Tenart wrote:
> > > > > > Before using the PHY framework instead of the USB PHY one, we need to
> > > > > > move the OTG state into another place, since it won't be available when
> > > > > > USB PHY isn't used. This patch moves the OTG state into the OTG
> > > > > > structure, and makes all the needed modifications in the drivers
> > > > > > using the OTG state.
> > > > > >
> > > > > > Signed-off-by: Antoine Tenart <[email protected]>
> > > > > > Acked-by: Peter Chen <[email protected]>
> > > > >
> > > > > Acked-by: Felipe Balbi <[email protected]>
> > > >
> > > > Please rebase on my testing/next and I'll take the series. When
> > > > rebasing, then add Peter's Tested-by/Acked-by where they're missing.
> > >
> > > I just re-sent the series, rebased on your testing/next branch.
> >
> > Thanks, I put them on my testing/next and I'm running build tests.
> >
>
> I see them, I will rebase your testing/next tree for coming chipidea dev, thanks.

I fixed a build breakage caused by $subject which I fixed, updated patch
below: (Aaro, can I get a tested-by by any chance ?)

8<------------------------------------------------------------------

commit 9057203a959384ef4d0324b2fa724c37169b05c9
Author: Antoine Tenart <[email protected]>
Date: Thu Oct 30 18:41:13 2014 +0100

usb: move the OTG state from the USB PHY to the OTG structure

Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.

[ [email protected] : fix build regression with phy-tahvo.c ]

Signed-off-by: Antoine Tenart <[email protected]>
Acked-by: Peter Chen <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 8c84298..9f409359 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)

static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct usb_phy *phy = otg->phy;
-
otg->host = host;
if (!host)
- phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

return 0;
}
@@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
static int omap_usb_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
{
- struct usb_phy *phy = otg->phy;
-
otg->gadget = gadget;
if (!gadget)
- phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

return 0;
}
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 795d653..8878eea 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)

/* ------ State ----- */
seq_printf(s, "OTG state: %s\n\n",
- usb_otg_state_string(ci->transceiver->state));
+ usb_otg_state_string(ci->transceiver->otg.state));

/* ------ State Machine Variables ----- */
seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index caaabc5..8cb2508 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
set_tmout(ci, indicator);

/* only vbus fall below B_sess_vld in b_idle state */
- if (ci->transceiver->state == OTG_STATE_B_IDLE)
+ if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
ci_otg_queue_work(ci);
}

@@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
* when there is no gadget class driver
*/
if (ci->fsm.id && !(ci->driver) &&
- ci->transceiver->state < OTG_STATE_A_IDLE)
+ ci->fsm.otg->state < OTG_STATE_A_IDLE)
return 0;

if (otg_statemachine(&ci->fsm)) {
- if (ci->transceiver->state == OTG_STATE_A_IDLE) {
+ if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
/*
* Further state change for cases:
* a_idle to b_idle; or
@@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
ci_otg_queue_work(ci);
if (ci->id_event)
ci->id_event = false;
- } else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
+ } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
if (ci->fsm.b_sess_vld) {
ci->fsm.power_up = 0;
/*
@@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);

- switch (ci->transceiver->state) {
+ switch (ci->fsm.otg->state) {
case OTG_STATE_A_WAIT_BCON:
if (port_conn) {
fsm->b_conn = 1;
@@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
ci->transceiver->otg = ci->fsm.otg;
ci->fsm.power_up = 1;
ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
- ci->transceiver->state = OTG_STATE_UNDEFINED;
+ ci->fsm.otg->state = OTG_STATE_UNDEFINED;
ci->fsm.ops = &ci_otg_ops;

mutex_init(&ci->fsm.lock);
diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
index 98e8340..c6b35b7 100644
--- a/drivers/usb/common/usb-otg-fsm.c
+++ b/drivers/usb/common/usb-otg-fsm.c
@@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{
state_changed = 1;
- if (fsm->otg->phy->state == new_state)
+ if (fsm->otg->state == new_state)
return 0;
VDBG("Set state: %s\n", usb_otg_state_string(new_state));
- otg_leave_state(fsm, fsm->otg->phy->state);
+ otg_leave_state(fsm, fsm->otg->state);
switch (new_state) {
case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0);
@@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
break;
}

- fsm->otg->phy->state = new_state;
+ fsm->otg->state = new_state;
return 0;
}

@@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm)

mutex_lock(&fsm->lock);

- state = fsm->otg->phy->state;
+ state = fsm->otg->state;
state_changed = 0;
/* State machine state change judgement */

diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 0231606d..cf89b4b1 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
otg_start_hnp(hcd->usb_phy->otg);

local_irq_save(flags);
- hcd->usb_phy->state = OTG_STATE_A_SUSPEND;
+ hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
l = omap_readl(OTG_CTRL);
l &= ~OTG_A_BUSREQ;
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index a2735df..d836a3e 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -149,25 +149,25 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
break;
@@ -176,7 +176,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -193,9 +193,9 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround);
last_timer = jiffies;
return;
@@ -208,7 +208,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout);
}
@@ -278,27 +278,27 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

/* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -324,7 +324,7 @@ eoi:
}

/* Poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 8554c6f..f23ce40b 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -185,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
}

/* Start sampling ID pin, when plug is removed from MUSB */
- if ((musb->xceiv->state == OTG_STATE_B_IDLE
- || musb->xceiv->state == OTG_STATE_A_WAIT_BCON) ||
+ if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE
+ || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) ||
(musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
musb->a_wait_bcon = TIMER_DELAY;
@@ -205,7 +205,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
static u8 toggle;

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE:
case OTG_STATE_A_WAIT_BCON:
/* Start a new session */
@@ -219,7 +219,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);
/* Ignore VBUSERROR and SUSPEND IRQ */
@@ -229,7 +229,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
musb_writeb(musb->mregs, MUSB_INTRUSB, val);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
break;
@@ -245,7 +245,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);

@@ -280,13 +280,13 @@ static void musb_conn_timer_handler(unsigned long _musb)
break;
default:
dev_dbg(musb->controller, "%s state not handled\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
spin_unlock_irqrestore(&musb->lock, flags);

dev_dbg(musb->controller, "state is %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}

static void bfin_musb_enable(struct musb *musb)
@@ -307,7 +307,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)

dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 058775e..527c7fe 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -198,20 +198,20 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
break;
@@ -248,7 +248,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -265,9 +265,9 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround);
last_timer = jiffies;
return;
@@ -280,7 +280,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout);
}
@@ -341,26 +341,26 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -375,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);

/* Poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 04de3ac..3c1d9b2 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -214,10 +214,10 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VFALL:
/* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL
* seems to mis-handle session "start" otherwise (or in our
@@ -228,7 +228,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
break;
@@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -325,20 +325,20 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
* to stop registering in devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

@@ -348,7 +348,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
davinci_musb_source_power(musb, drvvbus, 0);
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
retval = IRQ_HANDLED;
@@ -361,7 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
musb_writel(tibase, DAVINCI_USB_EOI_REG, 0);

/* poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index e46e295..df9c5fa 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -360,23 +360,23 @@ static void musb_otg_timer_func(unsigned long data)
unsigned long flags;

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: b_wait_acon timeout; back to b_peripheral\n");
musb_g_disconnect(musb);
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 0;
break;
case OTG_STATE_A_SUSPEND:
case OTG_STATE_A_WAIT_BCON:
dev_dbg(musb->controller, "HNP: %s timeout\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
musb_platform_set_vbus(musb, 0);
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
default:
dev_dbg(musb->controller, "HNP: Unhandled mode %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -391,19 +391,19 @@ void musb_hnp_stop(struct musb *musb)
u8 reg;

dev_dbg(musb->controller, "HNP: stop from %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
musb_g_disconnect(musb);
dev_dbg(musb->controller, "HNP: back to %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
case OTG_STATE_B_HOST:
dev_dbg(musb->controller, "HNP: Disabling HR\n");
if (hcd)
hcd->self.is_b_host = 0;
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
reg = musb_readb(mbase, MUSB_POWER);
reg |= MUSB_POWER_SUSPENDM;
@@ -412,7 +412,7 @@ void musb_hnp_stop(struct musb *musb)
break;
default:
dev_dbg(musb->controller, "HNP: Stopping in unknown state %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}

/*
@@ -449,13 +449,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
if (int_usb & MUSB_INTR_RESUME) {
handled = IRQ_HANDLED;
- dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->state));
+ dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->otg->state));

if (devctl & MUSB_DEVCTL_HM) {
void __iomem *mbase = musb->mregs;
u8 power;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
/* remote wakeup? later, GetPortStatus
* will stop RESUME signaling
@@ -482,25 +482,25 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
&musb->finish_resume_work,
msecs_to_jiffies(20));

- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
musb->is_active = 1;
musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 1;
MUSB_DEV_MODE(musb);
break;
default:
WARNING("bogus %s RESUME (%s)\n",
"host",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else {
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
/* possibly DISCONNECT is upcoming */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
@@ -523,7 +523,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
default:
WARNING("bogus %s RESUME (%s)\n",
"peripheral",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -539,7 +539,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
}

dev_dbg(musb->controller, "SESSION_REQUEST (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

/* IRQ arrives from ID pin sense or (later, if VBUS power
* is removed) SRP. responses are time critical:
@@ -550,7 +550,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
musb_writeb(mbase, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
musb->ep0_stage = MUSB_EP0_START;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
musb_platform_set_vbus(musb, 1);

@@ -576,7 +576,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
* REVISIT: do delays from lots of DEBUG_KERNEL checks
* make trouble here, keeping VBUS < 4.4V ?
*/
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
/* recovery is dicey once we've gotten past the
* initial stages of enumeration, but if VBUS
@@ -605,7 +605,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

dev_printk(ignore ? KERN_DEBUG : KERN_ERR, musb->controller,
"VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
devctl,
({ char *s;
switch (devctl & MUSB_DEVCTL_VBUS) {
@@ -630,10 +630,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

if (int_usb & MUSB_INTR_SUSPEND) {
dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
handled = IRQ_HANDLED;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
/* We also come here if the cable is removed, since
* this silicon doesn't report ID-no-longer-grounded.
@@ -657,7 +657,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb_g_suspend(musb);
musb->is_active = musb->g.b_hnp_enable;
if (musb->is_active) {
- musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(
@@ -670,7 +670,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
+ msecs_to_jiffies(musb->a_wait_bcon));
break;
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = musb->hcd->self.b_hnp_enable;
break;
case OTG_STATE_B_HOST:
@@ -713,7 +713,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb->port1_status |= USB_PORT_STAT_LOW_SPEED;

/* indicate new connection to OTG machine */
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL:
if (int_usb & MUSB_INTR_SUSPEND) {
dev_dbg(musb->controller, "HNP: SUSPEND+CONNECT, now b_host\n");
@@ -725,7 +725,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: CONNECT, now b_host\n");
b_host:
- musb->xceiv->state = OTG_STATE_B_HOST;
+ musb->xceiv->otg->state = OTG_STATE_B_HOST;
if (musb->hcd)
musb->hcd->self.is_b_host = 1;
del_timer(&musb->otg_timer);
@@ -733,7 +733,7 @@ b_host:
default:
if ((devctl & MUSB_DEVCTL_VBUS)
== (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
if (hcd)
hcd->self.is_b_host = 0;
}
@@ -743,16 +743,16 @@ b_host:
musb_host_poke_root_hub(musb);

dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
}

if (int_usb & MUSB_INTR_DISCONNECT) {
dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
MUSB_MODE(musb), devctl);
handled = IRQ_HANDLED;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
musb_host_resume_root_hub(musb);
@@ -770,7 +770,7 @@ b_host:
musb_root_disconnect(musb);
if (musb->hcd)
musb->hcd->self.is_b_host = 0;
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
musb_g_disconnect(musb);
break;
@@ -786,7 +786,7 @@ b_host:
break;
default:
WARNING("unhandled DISCONNECT transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
}
@@ -812,15 +812,15 @@ b_host:
}
} else {
dev_dbg(musb->controller, "BUS RESET as %s\n",
- usb_otg_state_string(musb->xceiv->state));
- switch (musb->xceiv->state) {
+ usb_otg_state_string(musb->xceiv->otg->state));
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
musb_g_reset(musb);
/* FALLTHROUGH */
case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
/* never use invalid T(a_wait_bcon) */
dev_dbg(musb->controller, "HNP: in %s, %d msec timeout\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
TA_WAIT_BCON(musb));
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(TA_WAIT_BCON(musb)));
@@ -831,19 +831,19 @@ b_host:
break;
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: RESET (%s), to b_peripheral\n",
- usb_otg_state_string(musb->xceiv->state));
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ usb_otg_state_string(musb->xceiv->otg->state));
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb_g_reset(musb);
break;
case OTG_STATE_B_IDLE:
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
/* FALLTHROUGH */
case OTG_STATE_B_PERIPHERAL:
musb_g_reset(musb);
break;
default:
dev_dbg(musb->controller, "Unhandled BUS RESET as %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -1630,7 +1630,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
int ret = -EINVAL;

spin_lock_irqsave(&musb->lock, flags);
- ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->state));
+ ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->otg->state));
spin_unlock_irqrestore(&musb->lock, flags);

return ret;
@@ -1675,7 +1675,7 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
spin_lock_irqsave(&musb->lock, flags);
/* force T(a_wait_bcon) to be zero/unlimited *OR* valid */
musb->a_wait_bcon = val ? max_t(int, val, OTG_TIME_A_WAIT_BCON) : 0 ;
- if (musb->xceiv->state == OTG_STATE_A_WAIT_BCON)
+ if (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)
musb->is_active = 0;
musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(val));
spin_unlock_irqrestore(&musb->lock, flags);
@@ -1743,8 +1743,8 @@ static void musb_irq_work(struct work_struct *data)
{
struct musb *musb = container_of(data, struct musb, irq_work);

- if (musb->xceiv->state != musb->xceiv_old_state) {
- musb->xceiv_old_state = musb->xceiv->state;
+ if (musb->xceiv->otg->state != musb->xceiv_old_state) {
+ musb->xceiv_old_state = musb->xceiv->otg->state;
sysfs_notify(&musb->controller->kobj, NULL, "mode");
}
}
@@ -1983,10 +1983,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)

if (musb->xceiv->otg->default_a) {
MUSB_HST_MODE(musb);
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
} else {
MUSB_DEV_MODE(musb);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}

switch (musb->port_mode) {
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 759ef1d..a44d9e3 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -179,9 +179,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&glue->timer);
glue->last_timer = jiffies;
return;
@@ -201,7 +201,7 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
glue->last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&glue->timer, timeout);
}
@@ -265,10 +265,10 @@ static void otg_timer(unsigned long _musb)
*/
devctl = dsps_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
skip_session = 1;
@@ -277,10 +277,10 @@ static void otg_timer(unsigned long _musb)
case OTG_STATE_A_IDLE:
case OTG_STATE_B_IDLE:
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
@@ -288,7 +288,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
dsps_writel(musb->ctrl_base, wrp->coreintr_set,
MUSB_INTR_VBUSERROR << wrp->usb_shift);
break;
@@ -373,26 +373,26 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&glue->timer,
jiffies + wrp->poll_seconds * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
del_timer(&glue->timer);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}

/* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -402,7 +402,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
ret |= musb_interrupt(musb);

/* Poll for ID change in OTG port mode */
- if (musb->xceiv->state == OTG_STATE_B_IDLE &&
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
out:
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 4ab1896..56c31b7 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1546,7 +1546,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL:
/* NOTE: OTG state machine doesn't include B_SUSPENDED;
* that's part of the standard usb 1.1 state machine, and
@@ -1587,7 +1587,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
goto done;
default:
dev_dbg(musb->controller, "Unhandled wake: %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
goto done;
}

@@ -1791,7 +1791,7 @@ int musb_gadget_setup(struct musb *musb)

MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;

/* this "gadget" abstracts/virtualizes the controller */
musb->g.name = musb_driver_name;
@@ -1857,7 +1857,7 @@ static int musb_gadget_start(struct usb_gadget *g,
musb->is_active = 1;

otg_set_peripheral(otg, &musb->g);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
spin_unlock_irqrestore(&musb->lock, flags);

musb_start(musb);
@@ -1941,7 +1941,7 @@ static int musb_gadget_stop(struct usb_gadget *g)

(void) musb_gadget_vbus_draw(&musb->g, 0);

- musb->xceiv->state = OTG_STATE_UNDEFINED;
+ musb->xceiv->otg->state = OTG_STATE_UNDEFINED;
stop_activity(musb, NULL);
otg_set_peripheral(musb->xceiv->otg, NULL);

@@ -1968,7 +1968,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
void musb_g_resume(struct musb *musb)
{
musb->is_suspended = 0;
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE:
break;
case OTG_STATE_B_WAIT_ACON:
@@ -1982,7 +1982,7 @@ void musb_g_resume(struct musb *musb)
break;
default:
WARNING("unhandled RESUME transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

@@ -1994,10 +1994,10 @@ void musb_g_suspend(struct musb *musb)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "devctl %02x\n", devctl);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE:
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
musb->is_suspended = 1;
@@ -2012,7 +2012,7 @@ void musb_g_suspend(struct musb *musb)
* A_PERIPHERAL may need care too
*/
WARNING("unhandled SUSPEND transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

@@ -2043,22 +2043,22 @@ void musb_g_disconnect(struct musb *musb)
spin_lock(&musb->lock);
}

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
default:
dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n",
- usb_otg_state_string(musb->xceiv->state));
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ usb_otg_state_string(musb->xceiv->otg->state));
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
break;
case OTG_STATE_A_PERIPHERAL:
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
MUSB_HST_MODE(musb);
break;
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_HOST:
case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_IDLE:
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_B_SRP_INIT:
break;
@@ -2118,13 +2118,13 @@ __acquires(musb->lock)
* In that case, do not rely on devctl for setting
* peripheral mode.
*/
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else {
- musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
}

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 855793d..23d474d 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2463,7 +2463,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
if (!is_host_active(musb))
return 0;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
return 0;
case OTG_STATE_A_WAIT_VRISE:
@@ -2473,7 +2473,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
*/
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
break;
default:
break;
@@ -2481,7 +2481,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)

if (musb->is_active) {
WARNING("trying to suspend as %s while active\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
return -EBUSY;
} else
return 0;
@@ -2678,7 +2678,7 @@ int musb_host_setup(struct musb *musb, int power_budget)

MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;

otg_set_host(musb->xceiv->otg, &hcd->self);
hcd->self.otg_port = 1;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index e2d2d8c..a133bd8 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -69,7 +69,7 @@ void musb_host_finish_resume(struct work_struct *work)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;

spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -107,9 +107,9 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);

musb->port1_status |= USB_PORT_STAT_SUSPEND;
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = otg->host->b_hnp_enable;
if (musb->is_active)
mod_timer(&musb->otg_timer, jiffies
@@ -118,13 +118,13 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
musb_platform_try_idle(musb, 0);
break;
case OTG_STATE_B_HOST:
- musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
musb->is_active = otg->host->b_hnp_enable;
musb_platform_try_idle(musb, 0);
break;
default:
dev_dbg(musb->controller, "bogus rh suspend? %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else if (power & MUSB_POWER_SUSPENDM) {
power &= ~MUSB_POWER_SUSPENDM;
@@ -145,7 +145,7 @@ void musb_port_reset(struct musb *musb, bool do_reset)
u8 power;
void __iomem *mbase = musb->mregs;

- if (musb->xceiv->state == OTG_STATE_B_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) {
dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n");
musb->port1_status &= ~USB_PORT_STAT_RESET;
return;
@@ -224,24 +224,24 @@ void musb_root_disconnect(struct musb *musb)
usb_hcd_poll_rh_status(musb->hcd);
musb->is_active = 0;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
if (otg->host->b_hnp_enable) {
- musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
break;
}
/* FALLTHROUGH */
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "host disconnect (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 20fc2a5..763649e 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
}
break;
case OTG_STATE_A_HOST:
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE)
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
else
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
default:
break;
}
@@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer);
last_timer = jiffies;
return;
@@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout);
}
@@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);

if (is_on) {
- if (musb->xceiv->state == OTG_STATE_A_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
int loops = 100;
/* start the session */
devctl |= MUSB_DEVCTL_SESSION;
@@ -180,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 1;
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
}
@@ -192,7 +192,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
*/

otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
devctl &= ~MUSB_DEVCTL_SESSION;

MUSB_DEV_MODE(musb);
@@ -201,7 +201,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)

dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

@@ -266,7 +266,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "ID GND\n");

otg->default_a = true;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
musb->xceiv->last_event = USB_EVENT_ID;
if (musb->gadget_driver) {
pm_runtime_get_sync(dev);
@@ -280,7 +280,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "VBUS Connect\n");

otg->default_a = false;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->xceiv->last_event = USB_EVENT_VBUS;
if (musb->gadget_driver)
pm_runtime_get_sync(dev);
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 25f02df..69ca92d6 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -415,13 +415,13 @@ static void musb_do_idle(unsigned long _musb)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
if ((musb->a_wait_bcon != 0)
&& (musb->idle_timeout == 0
|| time_after(jiffies, musb->idle_timeout))) {
dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
/* FALLTHROUGH */
case OTG_STATE_A_IDLE:
@@ -474,9 +474,9 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer);
last_timer = jiffies;
return;
@@ -493,7 +493,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout);
}
@@ -524,7 +524,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
if (is_on) {
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;

conf |= TUSB_DEV_CONF_USB_HOST_MODE;
@@ -537,16 +537,16 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
/* If ID pin is grounded, we want to be a_idle */
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE:
case OTG_STATE_A_WAIT_BCON:
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
}
musb->is_active = 0;
otg->default_a = 1;
@@ -554,7 +554,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 0;
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
}

@@ -569,7 +569,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL),
musb_readl(tbase, TUSB_DEV_OTG_STAT),
conf, prcm);
@@ -668,23 +668,23 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)

if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n");
- if (musb->xceiv->state != OTG_STATE_B_IDLE) {
+ if (musb->xceiv->otg->state != OTG_STATE_B_IDLE) {
/* INTR_DISCONNECT can hide... */
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->int_usb |= MUSB_INTR_DISCONNECT;
}
musb->is_active = 0;
}
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
idle_timeout = jiffies + (1 * HZ);
schedule_work(&musb->irq_work);

} else /* A-dev state machine */ {
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE:
dev_dbg(musb->controller, "Got SRP, turning on VBUS\n");
musb_platform_set_vbus(musb, 1);
@@ -731,9 +731,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
u8 devctl;

dev_dbg(musb->controller, "%s timer, %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE:
/* VBUS has probably been valid for a while now,
* but may well have bounced out of range a bit
@@ -745,7 +745,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
dev_dbg(musb->controller, "devctl %02x\n", devctl);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
idle_timeout = jiffies
+ msecs_to_jiffies(musb->a_wait_bcon);
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index d0180a7..1d631d5 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -56,7 +56,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);

if (is_on) {
- if (musb->xceiv->state == OTG_STATE_A_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
/* start the session */
devctl |= MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
@@ -76,7 +76,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 1;
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
}
@@ -102,7 +102,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
mdelay(200);

dev_dbg(musb->controller, "VBUS %s, devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

@@ -112,7 +112,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
struct musb *musb = container_of(nb, struct musb, nb);

dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n",
- event, usb_otg_state_string(musb->xceiv->state));
+ event, usb_otg_state_string(musb->xceiv->otg->state));

switch (event) {
case UX500_MUSB_ID:
@@ -127,7 +127,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
if (is_host_active(musb))
ux500_musb_set_vbus(musb, 0);
else
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "ID float\n");
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 11ab2c4..2d52501 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected. */
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_9540:
@@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing
* is connected
*/
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8540:
@@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing
* is connected
*/
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8505:
@@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected */
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8500:
@@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
ab->phy.label = "ab8500";
ab->phy.set_suspend = ab8500_usb_set_suspend;
ab->phy.set_power = ab8500_usb_set_power;
- ab->phy.state = OTG_STATE_UNDEFINED;
+ ab->phy.otg->state = OTG_STATE_UNDEFINED;

otg->phy = &ab->phy;
otg->set_host = ab8500_usb_set_host;
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index f1ea599..15d7a81 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
/* Mini-A cable connected */
struct otg_fsm *fsm = &otg_dev->fsm;

- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg.state = OTG_STATE_UNDEFINED;
fsm->protocol = PROTO_UNDEF;
}
}
@@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
{
if (!fsl_otg_dev)
return -ENODEV;
- if (phy->state == OTG_STATE_B_PERIPHERAL)
+ if (phy->otg.state == OTG_STATE_B_PERIPHERAL)
pr_info("FSL OTG: Draw %d mA\n", mA);

return 0;
@@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
{
struct fsl_otg *otg_dev;

- if (!otg || otg->phy->state != OTG_STATE_B_IDLE)
+ if (!otg || otg.state != OTG_STATE_B_IDLE)
return -ENODEV;

otg_dev = container_of(otg->phy, struct fsl_otg, phy);
@@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev)
* Also: record initial state of ID pin
*/
if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
- p_otg->phy.state = OTG_STATE_UNDEFINED;
+ p_otg->phy->otg.state = OTG_STATE_UNDEFINED;
p_otg->fsm.id = 1;
} else {
- p_otg->phy.state = OTG_STATE_A_IDLE;
+ p_otg->phy->otg.state = OTG_STATE_A_IDLE;
p_otg->fsm.id = 0;
}

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 7594e50..280a345 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
}

otg->gadget = gadget;
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
return 0;
}

@@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv";
nop->phy.set_suspend = nop_set_suspend;
- nop->phy.state = OTG_STATE_UNDEFINED;
nop->phy.type = type;

+ nop->phy.otg->state = OTG_STATE_UNDEFINED;
nop->phy.otg->phy = &nop->phy;
nop->phy.otg->set_host = nop_set_host;
nop->phy.otg->set_peripheral = nop_set_peripheral;
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index f4b14bd..7a6be3e 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work)

if (vbus) {
status = USB_EVENT_VBUS;
- gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
+ gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL;
gpio_vbus->phy.last_event = status;
usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);

@@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work)

usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
status = USB_EVENT_NONE;
- gpio_vbus->phy.state = OTG_STATE_B_IDLE;
+ gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE;
gpio_vbus->phy.last_event = status;

atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
@@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
set_vbus_draw(gpio_vbus, 0);

usb_gadget_vbus_disconnect(otg->gadget);
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

otg->gadget = NULL;
return 0;
@@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)

gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);

- if (phy->state == OTG_STATE_B_PERIPHERAL)
+ if (phy->otg->state == OTG_STATE_B_PERIPHERAL)
set_vbus_draw(gpio_vbus, mA);
return 0;
}
@@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
gpio_vbus->phy.dev = gpio_vbus->dev;
gpio_vbus->phy.set_power = gpio_vbus_set_power;
gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
- gpio_vbus->phy.state = OTG_STATE_UNDEFINED;

+ gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 471e69d..18015b7 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
}

if (!host) {
- if (otg->phy->state == OTG_STATE_A_HOST) {
+ if (otg->state == OTG_STATE_A_HOST) {
pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_host(otg->phy, 0);
otg->host = NULL;
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
} else {
otg->host = NULL;
@@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
}

if (!gadget) {
- if (otg->phy->state == OTG_STATE_B_PERIPHERAL) {
+ if (otg->state == OTG_STATE_B_PERIPHERAL) {
pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_peripheral(otg->phy, 0);
otg->gadget = NULL;
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
} else {
otg->gadget = NULL;
@@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w)
struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
struct usb_otg *otg = motg->phy.otg;

- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_UNDEFINED:
dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
msm_otg_reset(otg->phy);
msm_otg_init_sm(motg);
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
@@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w)
/* disable BSV bit */
writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
msm_otg_start_host(otg->phy, 1);
- otg->phy->state = OTG_STATE_A_HOST;
+ otg->state = OTG_STATE_A_HOST;
} else if (test_bit(B_SESS_VLD, &motg->inputs)) {
switch (motg->chg_state) {
case USB_CHG_STATE_UNDEFINED:
@@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_notify_charger(motg,
IDEV_CHG_MAX);
msm_otg_start_peripheral(otg->phy, 1);
- otg->phy->state
+ otg->state
= OTG_STATE_B_PERIPHERAL;
break;
case USB_SDP_CHARGER:
msm_otg_notify_charger(motg, IUNIT);
msm_otg_start_peripheral(otg->phy, 1);
- otg->phy->state
+ otg->state
= OTG_STATE_B_PERIPHERAL;
break;
default:
@@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w)
motg->chg_type = USB_INVALID_CHARGER;
}

- if (otg->phy->state == OTG_STATE_B_IDLE)
+ if (otg->state == OTG_STATE_B_IDLE)
pm_runtime_put_sync(otg->phy->dev);
break;
case OTG_STATE_B_PERIPHERAL:
@@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_start_peripheral(otg->phy, 0);
motg->chg_state = USB_CHG_STATE_UNDEFINED;
motg->chg_type = USB_INVALID_CHARGER;
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy);
schedule_work(w);
}
@@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w)
dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
if (test_bit(ID, &motg->inputs)) {
msm_otg_start_host(otg->phy, 0);
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy);
schedule_work(w);
}
@@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
struct msm_otg *motg = s->private;
struct usb_otg *otg = motg->phy.otg;

- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_A_HOST:
seq_puts(s, "host\n");
break;
@@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,

switch (req_mode) {
case USB_DR_MODE_UNKNOWN:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_B_PERIPHERAL:
set_bit(ID, &motg->inputs);
@@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
}
break;
case USB_DR_MODE_PERIPHERAL:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_A_HOST:
set_bit(ID, &motg->inputs);
@@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
}
break;
case USB_DR_MODE_HOST:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_B_PERIPHERAL:
clear_bit(ID, &motg->inputs);
@@ -1769,7 +1769,7 @@ static int msm_otg_runtime_idle(struct device *dev)
* This 1 sec delay also prevents entering into LPM immediately
* after asynchronous interrupt.
*/
- if (otg->phy->state != OTG_STATE_UNDEFINED)
+ if (otg->state != OTG_STATE_UNDEFINED)
pm_schedule_suspend(dev, 1000);

return -EAGAIN;
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index c9517d8..ee87aa7 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
{
struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
struct usb_phy *phy = &mvotg->phy;
- int old_state = phy->state;
+ int old_state = mvotg->phy.otg->state;

switch (old_state) {
case OTG_STATE_UNDEFINED:
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
if (otg_ctrl->id == 0)
- phy->state = OTG_STATE_A_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_A_IDLE;
else if (otg_ctrl->b_sess_vld)
- phy->state = OTG_STATE_B_PERIPHERAL;
+ mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_A_IDLE:
if (otg_ctrl->id)
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
else if (!(otg_ctrl->a_bus_drop) &&
(otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
- phy->state = OTG_STATE_A_WAIT_VRISE;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
break;
case OTG_STATE_A_WAIT_VRISE:
if (otg_ctrl->a_vbus_vld)
- phy->state = OTG_STATE_A_WAIT_BCON;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
break;
case OTG_STATE_A_WAIT_BCON:
if (otg_ctrl->id || otg_ctrl->a_bus_drop
|| otg_ctrl->a_wait_bcon_timeout) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_WAIT_VFALL;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
otg_ctrl->a_bus_req = 0;
} else if (!otg_ctrl->a_vbus_vld) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_VBUS_ERR;
+ mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
} else if (otg_ctrl->b_conn) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_HOST;
+ mvotg->phy.otg->state = OTG_STATE_A_HOST;
}
break;
case OTG_STATE_A_HOST:
if (otg_ctrl->id || !otg_ctrl->b_conn
|| otg_ctrl->a_bus_drop)
- phy->state = OTG_STATE_A_WAIT_BCON;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
else if (!otg_ctrl->a_vbus_vld)
- phy->state = OTG_STATE_A_VBUS_ERR;
+ mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
break;
case OTG_STATE_A_WAIT_VFALL:
if (otg_ctrl->id
|| (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
|| otg_ctrl->a_bus_req)
- phy->state = OTG_STATE_A_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_A_IDLE;
break;
case OTG_STATE_A_VBUS_ERR:
if (otg_ctrl->id || otg_ctrl->a_clr_err
|| otg_ctrl->a_bus_drop) {
otg_ctrl->a_clr_err = 0;
- phy->state = OTG_STATE_A_WAIT_VFALL;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
}
break;
default:
@@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work)
run:
/* work queue is single thread, or we need spin_lock to protect */
phy = &mvotg->phy;
- otg = phy->otg;
- old_state = phy->state;
+ otg = mvotg->phy.otg;
+ old_state = otg->state;

if (!mvotg->active)
return;
@@ -429,12 +429,12 @@ run:
mv_otg_update_inputs(mvotg);
mv_otg_update_state(mvotg);

- if (old_state != phy->state) {
+ if (old_state != mvotg->phy.otg->state) {
dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
state_string[old_state],
- state_string[phy->state]);
+ state_string[mvotg->phy.otg->state]);

- switch (phy->state) {
+ switch (mvotg->phy.otg->state) {
case OTG_STATE_B_IDLE:
otg->default_a = 0;
if (old_state == OTG_STATE_B_PERIPHERAL)
@@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
return -1;

/* We will use this interface to change to A device */
- if (mvotg->phy.state != OTG_STATE_B_IDLE
- && mvotg->phy.state != OTG_STATE_A_IDLE)
+ if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
+ && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
return -1;

/* The clock may disabled and we need to set irq for ID detected */
@@ -715,9 +715,9 @@ static int mv_otg_probe(struct platform_device *pdev)
mvotg->phy.dev = &pdev->dev;
mvotg->phy.otg = otg;
mvotg->phy.label = driver_name;
- mvotg->phy.state = OTG_STATE_UNDEFINED;

otg->phy = &mvotg->phy;
+ otg->state = OTG_STATE_UNDEFINED;
otg->set_host = mv_otg_set_host;
otg->set_peripheral = mv_otg_set_peripheral;
otg->set_vbus = mv_otg_set_vbus;
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index cc61ee4..04ece53 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -81,33 +81,33 @@ static void check_vbus_state(struct tahvo_usb *tu)

reg = retu_read(rdev, TAHVO_REG_IDSR);
if (reg & TAHVO_STAT_VBUS) {
- switch (tu->phy.state) {
+ switch (tu->phy.otg->state) {
case OTG_STATE_B_IDLE:
/* Enable the gadget driver */
if (tu->phy.otg->gadget)
usb_gadget_vbus_connect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_PERIPHERAL;
+ tu->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_A_IDLE:
/*
* Session is now valid assuming the USB hub is driving
* Vbus.
*/
- tu->phy.state = OTG_STATE_A_HOST;
+ tu->phy.otg->state = OTG_STATE_A_HOST;
break;
default:
break;
}
dev_info(&tu->pt_dev->dev, "USB cable connected\n");
} else {
- switch (tu->phy.state) {
+ switch (tu->phy.otg->state) {
case OTG_STATE_B_PERIPHERAL:
if (tu->phy.otg->gadget)
usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_A_HOST:
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -132,14 +132,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu)
/* Power up the transceiver in USB host mode */
retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
USBR_MASTER_SW2 | USBR_MASTER_SW1);
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;

check_vbus_state(tu);
}

static void tahvo_usb_stop_host(struct tahvo_usb *tu)
{
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;
}

static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
@@ -151,7 +151,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
/* Power up transceiver and set it in USB peripheral mode */
retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT |
USBR_NSUSPEND | USBR_SLAVE_SW);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;

check_vbus_state(tu);
}
@@ -160,7 +160,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu)
{
if (tu->phy.otg->gadget)
usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;
}

static void tahvo_usb_power_off(struct tahvo_usb *tu)
@@ -173,7 +173,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu)

/* Power off transceiver */
retu_write(rdev, TAHVO_REG_USBR, 0);
- tu->phy.state = OTG_STATE_UNDEFINED;
+ tu->phy.otg->state = OTG_STATE_UNDEFINED;
}

static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend)
@@ -379,7 +379,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
/* Create OTG interface */
tahvo_usb_power_off(tu);
tu->phy.dev = &pdev->dev;
- tu->phy.state = OTG_STATE_UNDEFINED;
+ tu->phy.otg->state = OTG_STATE_UNDEFINED;
tu->phy.label = DRIVER_NAME;
tu->phy.set_suspend = tahvo_usb_set_suspend;

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 154332b..33d3480 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -18,6 +18,8 @@ struct usb_otg {
struct usb_bus *host;
struct usb_gadget *gadget;

+ enum usb_otg_state state;
+
/* bind/unbind the host controller */
int (*set_host)(struct usb_otg *otg, struct usb_bus *host);

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 353053a..ac7d791 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -77,7 +77,6 @@ struct usb_phy {
unsigned int flags;

enum usb_phy_type type;
- enum usb_otg_state state;
enum usb_phy_events last_event;

struct usb_otg *otg;



--
balbi


Attachments:
(No filename) (75.40 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-10-31 05:31:22

by Kishon Vijay Abraham I

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure



On Friday 31 October 2014 06:17 AM, Felipe Balbi wrote:
> Hi,
>
> On Fri, Oct 31, 2014 at 08:38:14AM +0800, Peter Chen wrote:
>> On Thu, Oct 30, 2014 at 12:47:34PM -0500, Felipe Balbi wrote:
>>> On Thu, Oct 30, 2014 at 06:42:54PM +0100, Antoine Tenart wrote:
>>>> Hi Felipe,
>>>>
>>>> On Thu, Oct 30, 2014 at 11:35:13AM -0500, Felipe Balbi wrote:
>>>>> On Thu, Oct 30, 2014 at 11:31:48AM -0500, Felipe Balbi wrote:
>>>>>> On Tue, Oct 28, 2014 at 05:35:35PM +0100, Antoine Tenart wrote:
>>>>>>> Before using the PHY framework instead of the USB PHY one, we need to
>>>>>>> move the OTG state into another place, since it won't be available when
>>>>>>> USB PHY isn't used. This patch moves the OTG state into the OTG
>>>>>>> structure, and makes all the needed modifications in the drivers
>>>>>>> using the OTG state.
>>>>>>>
>>>>>>> Signed-off-by: Antoine Tenart <[email protected]>
>>>>>>> Acked-by: Peter Chen <[email protected]>
>>>>>>
>>>>>> Acked-by: Felipe Balbi <[email protected]>
>>>>>
>>>>> Please rebase on my testing/next and I'll take the series. When
>>>>> rebasing, then add Peter's Tested-by/Acked-by where they're missing.
>>>>
>>>> I just re-sent the series, rebased on your testing/next branch.
>>>
>>> Thanks, I put them on my testing/next and I'm running build tests.
>>>
>>
>> I see them, I will rebase your testing/next tree for coming chipidea dev, thanks.
>
> I fixed a build breakage caused by $subject which I fixed, updated patch
> below: (Aaro, can I get a tested-by by any chance ?)
>
> 8<------------------------------------------------------------------
>
> commit 9057203a959384ef4d0324b2fa724c37169b05c9
> Author: Antoine Tenart <[email protected]>
> Date: Thu Oct 30 18:41:13 2014 +0100
>
> usb: move the OTG state from the USB PHY to the OTG structure
>
> Before using the PHY framework instead of the USB PHY one, we need to
> move the OTG state into another place, since it won't be available when
> USB PHY isn't used. This patch moves the OTG state into the OTG
> structure, and makes all the needed modifications in the drivers
> using the OTG state.
>
> [ [email protected] : fix build regression with phy-tahvo.c ]
>
> Signed-off-by: Antoine Tenart <[email protected]>
> Acked-by: Peter Chen <[email protected]>
> Signed-off-by: Felipe Balbi <[email protected]>

For drivers/phy
Acked-by: Kishon Vijay Abraham I <[email protected]>
>
> diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
> index 8c84298..9f409359 100644
> --- a/drivers/phy/phy-omap-usb2.c
> +++ b/drivers/phy/phy-omap-usb2.c
> @@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)
>
> static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
> {
> - struct usb_phy *phy = otg->phy;
> -
> otg->host = host;
> if (!host)
> - phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
>
> return 0;
> }
> @@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
> static int omap_usb_set_peripheral(struct usb_otg *otg,
> struct usb_gadget *gadget)
> {
> - struct usb_phy *phy = otg->phy;
> -
> otg->gadget = gadget;
> if (!gadget)
> - phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
>
> return 0;
> }
> diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
> index 795d653..8878eea 100644
> --- a/drivers/usb/chipidea/debug.c
> +++ b/drivers/usb/chipidea/debug.c
> @@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)
>
> /* ------ State ----- */
> seq_printf(s, "OTG state: %s\n\n",
> - usb_otg_state_string(ci->transceiver->state));
> + usb_otg_state_string(ci->transceiver->otg.state));
>
> /* ------ State Machine Variables ----- */
> seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> index caaabc5..8cb2508 100644
> --- a/drivers/usb/chipidea/otg_fsm.c
> +++ b/drivers/usb/chipidea/otg_fsm.c
> @@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
> set_tmout(ci, indicator);
>
> /* only vbus fall below B_sess_vld in b_idle state */
> - if (ci->transceiver->state == OTG_STATE_B_IDLE)
> + if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
> ci_otg_queue_work(ci);
> }
>
> @@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
> * when there is no gadget class driver
> */
> if (ci->fsm.id && !(ci->driver) &&
> - ci->transceiver->state < OTG_STATE_A_IDLE)
> + ci->fsm.otg->state < OTG_STATE_A_IDLE)
> return 0;
>
> if (otg_statemachine(&ci->fsm)) {
> - if (ci->transceiver->state == OTG_STATE_A_IDLE) {
> + if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
> /*
> * Further state change for cases:
> * a_idle to b_idle; or
> @@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
> ci_otg_queue_work(ci);
> if (ci->id_event)
> ci->id_event = false;
> - } else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
> + } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
> if (ci->fsm.b_sess_vld) {
> ci->fsm.power_up = 0;
> /*
> @@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
> otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
> port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);
>
> - switch (ci->transceiver->state) {
> + switch (ci->fsm.otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> if (port_conn) {
> fsm->b_conn = 1;
> @@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
> ci->transceiver->otg = ci->fsm.otg;
> ci->fsm.power_up = 1;
> ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
> - ci->transceiver->state = OTG_STATE_UNDEFINED;
> + ci->fsm.otg->state = OTG_STATE_UNDEFINED;
> ci->fsm.ops = &ci_otg_ops;
>
> mutex_init(&ci->fsm.lock);
> diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
> index 98e8340..c6b35b7 100644
> --- a/drivers/usb/common/usb-otg-fsm.c
> +++ b/drivers/usb/common/usb-otg-fsm.c
> @@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
> static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
> {
> state_changed = 1;
> - if (fsm->otg->phy->state == new_state)
> + if (fsm->otg->state == new_state)
> return 0;
> VDBG("Set state: %s\n", usb_otg_state_string(new_state));
> - otg_leave_state(fsm, fsm->otg->phy->state);
> + otg_leave_state(fsm, fsm->otg->state);
> switch (new_state) {
> case OTG_STATE_B_IDLE:
> otg_drv_vbus(fsm, 0);
> @@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
> break;
> }
>
> - fsm->otg->phy->state = new_state;
> + fsm->otg->state = new_state;
> return 0;
> }
>
> @@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm)
>
> mutex_lock(&fsm->lock);
>
> - state = fsm->otg->phy->state;
> + state = fsm->otg->state;
> state_changed = 0;
> /* State machine state change judgement */
>
> diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
> index 0231606d..cf89b4b1 100644
> --- a/drivers/usb/host/ohci-omap.c
> +++ b/drivers/usb/host/ohci-omap.c
> @@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
> otg_start_hnp(hcd->usb_phy->otg);
>
> local_irq_save(flags);
> - hcd->usb_phy->state = OTG_STATE_A_SUSPEND;
> + hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
> writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
> l = omap_readl(OTG_CTRL);
> l &= ~OTG_A_BUSREQ;
> diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
> index a2735df..d836a3e 100644
> --- a/drivers/usb/musb/am35x.c
> +++ b/drivers/usb/musb/am35x.c
> @@ -149,25 +149,25 @@ static void otg_timer(unsigned long _musb)
> */
> devctl = musb_readb(mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> devctl &= ~MUSB_DEVCTL_SESSION;
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
>
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> } else {
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> }
> break;
> case OTG_STATE_A_WAIT_VFALL:
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
> MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
> break;
> @@ -176,7 +176,7 @@ static void otg_timer(unsigned long _musb)
> if (devctl & MUSB_DEVCTL_BDEVICE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> else
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> break;
> @@ -193,9 +193,9 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || (musb->a_wait_bcon == 0 &&
> - musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
> + musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&otg_workaround);
> last_timer = jiffies;
> return;
> @@ -208,7 +208,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
> last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> jiffies_to_msecs(timeout - jiffies));
> mod_timer(&otg_workaround, timeout);
> }
> @@ -278,27 +278,27 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
> * devctl.
> */
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> WARNING("VBUS error workaround (delay coming)\n");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> portstate(musb->port1_status |= USB_PORT_STAT_POWER);
> del_timer(&otg_workaround);
> } else {
> musb->is_active = 0;
> MUSB_DEV_MODE(musb);
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
> }
>
> /* NOTE: this must complete power-on within 100 ms. */
> dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
> drvvbus ? "on" : "off",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> err ? " ERROR" : "",
> devctl);
> ret = IRQ_HANDLED;
> @@ -324,7 +324,7 @@ eoi:
> }
>
> /* Poll for ID change */
> - if (musb->xceiv->state == OTG_STATE_B_IDLE)
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
>
> spin_unlock_irqrestore(&musb->lock, flags);
> diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
> index 8554c6f..f23ce40b 100644
> --- a/drivers/usb/musb/blackfin.c
> +++ b/drivers/usb/musb/blackfin.c
> @@ -185,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
> }
>
> /* Start sampling ID pin, when plug is removed from MUSB */
> - if ((musb->xceiv->state == OTG_STATE_B_IDLE
> - || musb->xceiv->state == OTG_STATE_A_WAIT_BCON) ||
> + if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE
> + || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) ||
> (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
> mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
> musb->a_wait_bcon = TIMER_DELAY;
> @@ -205,7 +205,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
> static u8 toggle;
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_IDLE:
> case OTG_STATE_A_WAIT_BCON:
> /* Start a new session */
> @@ -219,7 +219,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
>
> if (!(val & MUSB_DEVCTL_BDEVICE)) {
> gpio_set_value(musb->config->gpio_vrsel, 1);
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> } else {
> gpio_set_value(musb->config->gpio_vrsel, 0);
> /* Ignore VBUSERROR and SUSPEND IRQ */
> @@ -229,7 +229,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
>
> val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
> musb_writeb(musb->mregs, MUSB_INTRUSB, val);
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> }
> mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
> break;
> @@ -245,7 +245,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
>
> if (!(val & MUSB_DEVCTL_BDEVICE)) {
> gpio_set_value(musb->config->gpio_vrsel, 1);
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> } else {
> gpio_set_value(musb->config->gpio_vrsel, 0);
>
> @@ -280,13 +280,13 @@ static void musb_conn_timer_handler(unsigned long _musb)
> break;
> default:
> dev_dbg(musb->controller, "%s state not handled\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> break;
> }
> spin_unlock_irqrestore(&musb->lock, flags);
>
> dev_dbg(musb->controller, "state is %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
>
> static void bfin_musb_enable(struct musb *musb)
> @@ -307,7 +307,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)
>
> dev_dbg(musb->controller, "VBUS %s, devctl %02x "
> /* otg %3x conf %08x prcm %08x */ "\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> musb_readb(musb->mregs, MUSB_DEVCTL));
> }
>
> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> index 058775e..527c7fe 100644
> --- a/drivers/usb/musb/da8xx.c
> +++ b/drivers/usb/musb/da8xx.c
> @@ -198,20 +198,20 @@ static void otg_timer(unsigned long _musb)
> */
> devctl = musb_readb(mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> devctl &= ~MUSB_DEVCTL_SESSION;
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
>
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> } else {
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> }
> break;
> @@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> break;
> }
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
> MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
> break;
> @@ -248,7 +248,7 @@ static void otg_timer(unsigned long _musb)
> if (devctl & MUSB_DEVCTL_BDEVICE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> else
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> break;
> @@ -265,9 +265,9 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || (musb->a_wait_bcon == 0 &&
> - musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
> + musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&otg_workaround);
> last_timer = jiffies;
> return;
> @@ -280,7 +280,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
> last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> jiffies_to_msecs(timeout - jiffies));
> mod_timer(&otg_workaround, timeout);
> }
> @@ -341,26 +341,26 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
> * devctl.
> */
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> WARNING("VBUS error workaround (delay coming)\n");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> portstate(musb->port1_status |= USB_PORT_STAT_POWER);
> del_timer(&otg_workaround);
> } else {
> musb->is_active = 0;
> MUSB_DEV_MODE(musb);
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
> }
>
> dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
> drvvbus ? "on" : "off",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> err ? " ERROR" : "",
> devctl);
> ret = IRQ_HANDLED;
> @@ -375,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
> musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
>
> /* Poll for ID change */
> - if (musb->xceiv->state == OTG_STATE_B_IDLE)
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
>
> spin_unlock_irqrestore(&musb->lock, flags);
> diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
> index 04de3ac..3c1d9b2 100644
> --- a/drivers/usb/musb/davinci.c
> +++ b/drivers/usb/musb/davinci.c
> @@ -214,10 +214,10 @@ static void otg_timer(unsigned long _musb)
> */
> devctl = musb_readb(mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl,
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_VFALL:
> /* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL
> * seems to mis-handle session "start" otherwise (or in our
> @@ -228,7 +228,7 @@ static void otg_timer(unsigned long _musb)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> break;
> }
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
> MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
> break;
> @@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb)
> if (devctl & MUSB_DEVCTL_BDEVICE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> else
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> break;
> @@ -325,20 +325,20 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
> * to stop registering in devctl.
> */
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
> WARNING("VBUS error workaround (delay coming)\n");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> portstate(musb->port1_status |= USB_PORT_STAT_POWER);
> del_timer(&otg_workaround);
> } else {
> musb->is_active = 0;
> MUSB_DEV_MODE(musb);
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
> }
>
> @@ -348,7 +348,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
> davinci_musb_source_power(musb, drvvbus, 0);
> dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
> drvvbus ? "on" : "off",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> err ? " ERROR" : "",
> devctl);
> retval = IRQ_HANDLED;
> @@ -361,7 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
> musb_writel(tibase, DAVINCI_USB_EOI_REG, 0);
>
> /* poll for ID change */
> - if (musb->xceiv->state == OTG_STATE_B_IDLE)
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
> mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
>
> spin_unlock_irqrestore(&musb->lock, flags);
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index e46e295..df9c5fa 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -360,23 +360,23 @@ static void musb_otg_timer_func(unsigned long data)
> unsigned long flags;
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_WAIT_ACON:
> dev_dbg(musb->controller, "HNP: b_wait_acon timeout; back to b_peripheral\n");
> musb_g_disconnect(musb);
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->is_active = 0;
> break;
> case OTG_STATE_A_SUSPEND:
> case OTG_STATE_A_WAIT_BCON:
> dev_dbg(musb->controller, "HNP: %s timeout\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> musb_platform_set_vbus(musb, 0);
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> break;
> default:
> dev_dbg(musb->controller, "HNP: Unhandled mode %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> spin_unlock_irqrestore(&musb->lock, flags);
> }
> @@ -391,19 +391,19 @@ void musb_hnp_stop(struct musb *musb)
> u8 reg;
>
> dev_dbg(musb->controller, "HNP: stop from %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_PERIPHERAL:
> musb_g_disconnect(musb);
> dev_dbg(musb->controller, "HNP: back to %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> break;
> case OTG_STATE_B_HOST:
> dev_dbg(musb->controller, "HNP: Disabling HR\n");
> if (hcd)
> hcd->self.is_b_host = 0;
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> MUSB_DEV_MODE(musb);
> reg = musb_readb(mbase, MUSB_POWER);
> reg |= MUSB_POWER_SUSPENDM;
> @@ -412,7 +412,7 @@ void musb_hnp_stop(struct musb *musb)
> break;
> default:
> dev_dbg(musb->controller, "HNP: Stopping in unknown state %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
>
> /*
> @@ -449,13 +449,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> */
> if (int_usb & MUSB_INTR_RESUME) {
> handled = IRQ_HANDLED;
> - dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->state));
> + dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->otg->state));
>
> if (devctl & MUSB_DEVCTL_HM) {
> void __iomem *mbase = musb->mregs;
> u8 power;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> /* remote wakeup? later, GetPortStatus
> * will stop RESUME signaling
> @@ -482,25 +482,25 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> &musb->finish_resume_work,
> msecs_to_jiffies(20));
>
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
> musb->is_active = 1;
> musb_host_resume_root_hub(musb);
> break;
> case OTG_STATE_B_WAIT_ACON:
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->is_active = 1;
> MUSB_DEV_MODE(musb);
> break;
> default:
> WARNING("bogus %s RESUME (%s)\n",
> "host",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> } else {
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> /* possibly DISCONNECT is upcoming */
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
> musb_host_resume_root_hub(musb);
> break;
> case OTG_STATE_B_WAIT_ACON:
> @@ -523,7 +523,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> default:
> WARNING("bogus %s RESUME (%s)\n",
> "peripheral",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
> }
> @@ -539,7 +539,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> }
>
> dev_dbg(musb->controller, "SESSION_REQUEST (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> /* IRQ arrives from ID pin sense or (later, if VBUS power
> * is removed) SRP. responses are time critical:
> @@ -550,7 +550,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> */
> musb_writeb(mbase, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
> musb->ep0_stage = MUSB_EP0_START;
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> musb_platform_set_vbus(musb, 1);
>
> @@ -576,7 +576,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> * REVISIT: do delays from lots of DEBUG_KERNEL checks
> * make trouble here, keeping VBUS < 4.4V ?
> */
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_HOST:
> /* recovery is dicey once we've gotten past the
> * initial stages of enumeration, but if VBUS
> @@ -605,7 +605,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
>
> dev_printk(ignore ? KERN_DEBUG : KERN_ERR, musb->controller,
> "VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> devctl,
> ({ char *s;
> switch (devctl & MUSB_DEVCTL_VBUS) {
> @@ -630,10 +630,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
>
> if (int_usb & MUSB_INTR_SUSPEND) {
> dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n",
> - usb_otg_state_string(musb->xceiv->state), devctl);
> + usb_otg_state_string(musb->xceiv->otg->state), devctl);
> handled = IRQ_HANDLED;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_PERIPHERAL:
> /* We also come here if the cable is removed, since
> * this silicon doesn't report ID-no-longer-grounded.
> @@ -657,7 +657,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> musb_g_suspend(musb);
> musb->is_active = musb->g.b_hnp_enable;
> if (musb->is_active) {
> - musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
> + musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
> dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
> mod_timer(&musb->otg_timer, jiffies
> + msecs_to_jiffies(
> @@ -670,7 +670,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> + msecs_to_jiffies(musb->a_wait_bcon));
> break;
> case OTG_STATE_A_HOST:
> - musb->xceiv->state = OTG_STATE_A_SUSPEND;
> + musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
> musb->is_active = musb->hcd->self.b_hnp_enable;
> break;
> case OTG_STATE_B_HOST:
> @@ -713,7 +713,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> musb->port1_status |= USB_PORT_STAT_LOW_SPEED;
>
> /* indicate new connection to OTG machine */
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_PERIPHERAL:
> if (int_usb & MUSB_INTR_SUSPEND) {
> dev_dbg(musb->controller, "HNP: SUSPEND+CONNECT, now b_host\n");
> @@ -725,7 +725,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> case OTG_STATE_B_WAIT_ACON:
> dev_dbg(musb->controller, "HNP: CONNECT, now b_host\n");
> b_host:
> - musb->xceiv->state = OTG_STATE_B_HOST;
> + musb->xceiv->otg->state = OTG_STATE_B_HOST;
> if (musb->hcd)
> musb->hcd->self.is_b_host = 1;
> del_timer(&musb->otg_timer);
> @@ -733,7 +733,7 @@ b_host:
> default:
> if ((devctl & MUSB_DEVCTL_VBUS)
> == (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
> if (hcd)
> hcd->self.is_b_host = 0;
> }
> @@ -743,16 +743,16 @@ b_host:
> musb_host_poke_root_hub(musb);
>
> dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
> - usb_otg_state_string(musb->xceiv->state), devctl);
> + usb_otg_state_string(musb->xceiv->otg->state), devctl);
> }
>
> if (int_usb & MUSB_INTR_DISCONNECT) {
> dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> MUSB_MODE(musb), devctl);
> handled = IRQ_HANDLED;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_HOST:
> case OTG_STATE_A_SUSPEND:
> musb_host_resume_root_hub(musb);
> @@ -770,7 +770,7 @@ b_host:
> musb_root_disconnect(musb);
> if (musb->hcd)
> musb->hcd->self.is_b_host = 0;
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> MUSB_DEV_MODE(musb);
> musb_g_disconnect(musb);
> break;
> @@ -786,7 +786,7 @@ b_host:
> break;
> default:
> WARNING("unhandled DISCONNECT transition (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> break;
> }
> }
> @@ -812,15 +812,15 @@ b_host:
> }
> } else {
> dev_dbg(musb->controller, "BUS RESET as %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> - switch (musb->xceiv->state) {
> + usb_otg_state_string(musb->xceiv->otg->state));
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> musb_g_reset(musb);
> /* FALLTHROUGH */
> case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
> /* never use invalid T(a_wait_bcon) */
> dev_dbg(musb->controller, "HNP: in %s, %d msec timeout\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> TA_WAIT_BCON(musb));
> mod_timer(&musb->otg_timer, jiffies
> + msecs_to_jiffies(TA_WAIT_BCON(musb)));
> @@ -831,19 +831,19 @@ b_host:
> break;
> case OTG_STATE_B_WAIT_ACON:
> dev_dbg(musb->controller, "HNP: RESET (%s), to b_peripheral\n",
> - usb_otg_state_string(musb->xceiv->state));
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + usb_otg_state_string(musb->xceiv->otg->state));
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb_g_reset(musb);
> break;
> case OTG_STATE_B_IDLE:
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> /* FALLTHROUGH */
> case OTG_STATE_B_PERIPHERAL:
> musb_g_reset(musb);
> break;
> default:
> dev_dbg(musb->controller, "Unhandled BUS RESET as %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
> }
> @@ -1630,7 +1630,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
> int ret = -EINVAL;
>
> spin_lock_irqsave(&musb->lock, flags);
> - ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->state));
> + ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->otg->state));
> spin_unlock_irqrestore(&musb->lock, flags);
>
> return ret;
> @@ -1675,7 +1675,7 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
> spin_lock_irqsave(&musb->lock, flags);
> /* force T(a_wait_bcon) to be zero/unlimited *OR* valid */
> musb->a_wait_bcon = val ? max_t(int, val, OTG_TIME_A_WAIT_BCON) : 0 ;
> - if (musb->xceiv->state == OTG_STATE_A_WAIT_BCON)
> + if (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)
> musb->is_active = 0;
> musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(val));
> spin_unlock_irqrestore(&musb->lock, flags);
> @@ -1743,8 +1743,8 @@ static void musb_irq_work(struct work_struct *data)
> {
> struct musb *musb = container_of(data, struct musb, irq_work);
>
> - if (musb->xceiv->state != musb->xceiv_old_state) {
> - musb->xceiv_old_state = musb->xceiv->state;
> + if (musb->xceiv->otg->state != musb->xceiv_old_state) {
> + musb->xceiv_old_state = musb->xceiv->otg->state;
> sysfs_notify(&musb->controller->kobj, NULL, "mode");
> }
> }
> @@ -1983,10 +1983,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
>
> if (musb->xceiv->otg->default_a) {
> MUSB_HST_MODE(musb);
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> } else {
> MUSB_DEV_MODE(musb);
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> }
>
> switch (musb->port_mode) {
> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
> index 759ef1d..a44d9e3 100644
> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -179,9 +179,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || (musb->a_wait_bcon == 0 &&
> - musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
> + musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&glue->timer);
> glue->last_timer = jiffies;
> return;
> @@ -201,7 +201,7 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
> glue->last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> jiffies_to_msecs(timeout - jiffies));
> mod_timer(&glue->timer, timeout);
> }
> @@ -265,10 +265,10 @@ static void otg_timer(unsigned long _musb)
> */
> devctl = dsps_readb(mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> spin_lock_irqsave(&musb->lock, flags);
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
> skip_session = 1;
> @@ -277,10 +277,10 @@ static void otg_timer(unsigned long _musb)
> case OTG_STATE_A_IDLE:
> case OTG_STATE_B_IDLE:
> if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> } else {
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> }
> if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
> @@ -288,7 +288,7 @@ static void otg_timer(unsigned long _musb)
> mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
> break;
> case OTG_STATE_A_WAIT_VFALL:
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> dsps_writel(musb->ctrl_base, wrp->coreintr_set,
> MUSB_INTR_VBUSERROR << wrp->usb_shift);
> break;
> @@ -373,26 +373,26 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
> * devctl.
> */
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&glue->timer,
> jiffies + wrp->poll_seconds * HZ);
> WARNING("VBUS error workaround (delay coming)\n");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> musb->xceiv->otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> del_timer(&glue->timer);
> } else {
> musb->is_active = 0;
> MUSB_DEV_MODE(musb);
> musb->xceiv->otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> }
>
> /* NOTE: this must complete power-on within 100 ms. */
> dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
> drvvbus ? "on" : "off",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> err ? " ERROR" : "",
> devctl);
> ret = IRQ_HANDLED;
> @@ -402,7 +402,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
> ret |= musb_interrupt(musb);
>
> /* Poll for ID change in OTG port mode */
> - if (musb->xceiv->state == OTG_STATE_B_IDLE &&
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
> musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
> mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
> out:
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index 4ab1896..56c31b7 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -1546,7 +1546,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
>
> spin_lock_irqsave(&musb->lock, flags);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_PERIPHERAL:
> /* NOTE: OTG state machine doesn't include B_SUSPENDED;
> * that's part of the standard usb 1.1 state machine, and
> @@ -1587,7 +1587,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
> goto done;
> default:
> dev_dbg(musb->controller, "Unhandled wake: %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> goto done;
> }
>
> @@ -1791,7 +1791,7 @@ int musb_gadget_setup(struct musb *musb)
>
> MUSB_DEV_MODE(musb);
> musb->xceiv->otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
>
> /* this "gadget" abstracts/virtualizes the controller */
> musb->g.name = musb_driver_name;
> @@ -1857,7 +1857,7 @@ static int musb_gadget_start(struct usb_gadget *g,
> musb->is_active = 1;
>
> otg_set_peripheral(otg, &musb->g);
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> spin_unlock_irqrestore(&musb->lock, flags);
>
> musb_start(musb);
> @@ -1941,7 +1941,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
>
> (void) musb_gadget_vbus_draw(&musb->g, 0);
>
> - musb->xceiv->state = OTG_STATE_UNDEFINED;
> + musb->xceiv->otg->state = OTG_STATE_UNDEFINED;
> stop_activity(musb, NULL);
> otg_set_peripheral(musb->xceiv->otg, NULL);
>
> @@ -1968,7 +1968,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
> void musb_g_resume(struct musb *musb)
> {
> musb->is_suspended = 0;
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_IDLE:
> break;
> case OTG_STATE_B_WAIT_ACON:
> @@ -1982,7 +1982,7 @@ void musb_g_resume(struct musb *musb)
> break;
> default:
> WARNING("unhandled RESUME transition (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
>
> @@ -1994,10 +1994,10 @@ void musb_g_suspend(struct musb *musb)
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> dev_dbg(musb->controller, "devctl %02x\n", devctl);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_IDLE:
> if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> break;
> case OTG_STATE_B_PERIPHERAL:
> musb->is_suspended = 1;
> @@ -2012,7 +2012,7 @@ void musb_g_suspend(struct musb *musb)
> * A_PERIPHERAL may need care too
> */
> WARNING("unhandled SUSPEND transition (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
>
> @@ -2043,22 +2043,22 @@ void musb_g_disconnect(struct musb *musb)
> spin_lock(&musb->lock);
> }
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> default:
> dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n",
> - usb_otg_state_string(musb->xceiv->state));
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + usb_otg_state_string(musb->xceiv->otg->state));
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> break;
> case OTG_STATE_A_PERIPHERAL:
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> MUSB_HST_MODE(musb);
> break;
> case OTG_STATE_B_WAIT_ACON:
> case OTG_STATE_B_HOST:
> case OTG_STATE_B_PERIPHERAL:
> case OTG_STATE_B_IDLE:
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> break;
> case OTG_STATE_B_SRP_INIT:
> break;
> @@ -2118,13 +2118,13 @@ __acquires(musb->lock)
> * In that case, do not rely on devctl for setting
> * peripheral mode.
> */
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->g.is_a_peripheral = 0;
> } else if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->g.is_a_peripheral = 0;
> } else {
> - musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
> musb->g.is_a_peripheral = 1;
> }
>
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index 855793d..23d474d 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -2463,7 +2463,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
> if (!is_host_active(musb))
> return 0;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> return 0;
> case OTG_STATE_A_WAIT_VRISE:
> @@ -2473,7 +2473,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
> */
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> break;
> default:
> break;
> @@ -2481,7 +2481,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
>
> if (musb->is_active) {
> WARNING("trying to suspend as %s while active\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> return -EBUSY;
> } else
> return 0;
> @@ -2678,7 +2678,7 @@ int musb_host_setup(struct musb *musb, int power_budget)
>
> MUSB_HST_MODE(musb);
> musb->xceiv->otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
>
> otg_set_host(musb->xceiv->otg, &hcd->self);
> hcd->self.otg_port = 1;
> diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
> index e2d2d8c..a133bd8 100644
> --- a/drivers/usb/musb/musb_virthub.c
> +++ b/drivers/usb/musb/musb_virthub.c
> @@ -69,7 +69,7 @@ void musb_host_finish_resume(struct work_struct *work)
> musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
> usb_hcd_poll_rh_status(musb->hcd);
> /* NOTE: it might really be A_WAIT_BCON ... */
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
>
> spin_unlock_irqrestore(&musb->lock, flags);
> }
> @@ -107,9 +107,9 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
> dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);
>
> musb->port1_status |= USB_PORT_STAT_SUSPEND;
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_HOST:
> - musb->xceiv->state = OTG_STATE_A_SUSPEND;
> + musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
> musb->is_active = otg->host->b_hnp_enable;
> if (musb->is_active)
> mod_timer(&musb->otg_timer, jiffies
> @@ -118,13 +118,13 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
> musb_platform_try_idle(musb, 0);
> break;
> case OTG_STATE_B_HOST:
> - musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
> + musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
> musb->is_active = otg->host->b_hnp_enable;
> musb_platform_try_idle(musb, 0);
> break;
> default:
> dev_dbg(musb->controller, "bogus rh suspend? %s\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> } else if (power & MUSB_POWER_SUSPENDM) {
> power &= ~MUSB_POWER_SUSPENDM;
> @@ -145,7 +145,7 @@ void musb_port_reset(struct musb *musb, bool do_reset)
> u8 power;
> void __iomem *mbase = musb->mregs;
>
> - if (musb->xceiv->state == OTG_STATE_B_IDLE) {
> + if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) {
> dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n");
> musb->port1_status &= ~USB_PORT_STAT_RESET;
> return;
> @@ -224,24 +224,24 @@ void musb_root_disconnect(struct musb *musb)
> usb_hcd_poll_rh_status(musb->hcd);
> musb->is_active = 0;
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> if (otg->host->b_hnp_enable) {
> - musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
> + musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
> musb->g.is_a_peripheral = 1;
> break;
> }
> /* FALLTHROUGH */
> case OTG_STATE_A_HOST:
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> musb->is_active = 0;
> break;
> case OTG_STATE_A_WAIT_VFALL:
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> break;
> default:
> dev_dbg(musb->controller, "host disconnect (%s)\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
>
> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> index 20fc2a5..763649e 100644
> --- a/drivers/usb/musb/omap2430.c
> +++ b/drivers/usb/musb/omap2430.c
> @@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb)
>
> spin_lock_irqsave(&musb->lock, flags);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
>
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if (devctl & MUSB_DEVCTL_BDEVICE) {
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> } else {
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> }
> break;
> @@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb)
> musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
> usb_hcd_poll_rh_status(musb->hcd);
> /* NOTE: it might really be A_WAIT_BCON ... */
> - musb->xceiv->state = OTG_STATE_A_HOST;
> + musb->xceiv->otg->state = OTG_STATE_A_HOST;
> }
> break;
> case OTG_STATE_A_HOST:
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
> if (devctl & MUSB_DEVCTL_BDEVICE)
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> else
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> default:
> break;
> }
> @@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || ((musb->a_wait_bcon == 0)
> - && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
> + && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&musb_idle_timer);
> last_timer = jiffies;
> return;
> @@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
> last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> (unsigned long)jiffies_to_msecs(timeout - jiffies));
> mod_timer(&musb_idle_timer, timeout);
> }
> @@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
>
> if (is_on) {
> - if (musb->xceiv->state == OTG_STATE_A_IDLE) {
> + if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
> int loops = 100;
> /* start the session */
> devctl |= MUSB_DEVCTL_SESSION;
> @@ -180,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
> } else {
> musb->is_active = 1;
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> devctl |= MUSB_DEVCTL_SESSION;
> MUSB_HST_MODE(musb);
> }
> @@ -192,7 +192,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
> */
>
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> devctl &= ~MUSB_DEVCTL_SESSION;
>
> MUSB_DEV_MODE(musb);
> @@ -201,7 +201,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
>
> dev_dbg(musb->controller, "VBUS %s, devctl %02x "
> /* otg %3x conf %08x prcm %08x */ "\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> musb_readb(musb->mregs, MUSB_DEVCTL));
> }
>
> @@ -266,7 +266,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
> dev_dbg(dev, "ID GND\n");
>
> otg->default_a = true;
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> musb->xceiv->last_event = USB_EVENT_ID;
> if (musb->gadget_driver) {
> pm_runtime_get_sync(dev);
> @@ -280,7 +280,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
> dev_dbg(dev, "VBUS Connect\n");
>
> otg->default_a = false;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> musb->xceiv->last_event = USB_EVENT_VBUS;
> if (musb->gadget_driver)
> pm_runtime_get_sync(dev);
> diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
> index 25f02df..69ca92d6 100644
> --- a/drivers/usb/musb/tusb6010.c
> +++ b/drivers/usb/musb/tusb6010.c
> @@ -415,13 +415,13 @@ static void musb_do_idle(unsigned long _musb)
>
> spin_lock_irqsave(&musb->lock, flags);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_BCON:
> if ((musb->a_wait_bcon != 0)
> && (musb->idle_timeout == 0
> || time_after(jiffies, musb->idle_timeout))) {
> dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> /* FALLTHROUGH */
> case OTG_STATE_A_IDLE:
> @@ -474,9 +474,9 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
>
> /* Never idle if active, or when VBUS timeout is not set as host */
> if (musb->is_active || ((musb->a_wait_bcon == 0)
> - && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
> + && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
> dev_dbg(musb->controller, "%s active, deleting timer\n",
> - usb_otg_state_string(musb->xceiv->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> del_timer(&musb_idle_timer);
> last_timer = jiffies;
> return;
> @@ -493,7 +493,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
> last_timer = timeout;
>
> dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> (unsigned long)jiffies_to_msecs(timeout - jiffies));
> mod_timer(&musb_idle_timer, timeout);
> }
> @@ -524,7 +524,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
> if (is_on) {
> timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
> otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> devctl |= MUSB_DEVCTL_SESSION;
>
> conf |= TUSB_DEV_CONF_USB_HOST_MODE;
> @@ -537,16 +537,16 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
> /* If ID pin is grounded, we want to be a_idle */
> otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
> if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_VRISE:
> case OTG_STATE_A_WAIT_BCON:
> - musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> break;
> case OTG_STATE_A_WAIT_VFALL:
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> - musb->xceiv->state = OTG_STATE_A_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> }
> musb->is_active = 0;
> otg->default_a = 1;
> @@ -554,7 +554,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
> } else {
> musb->is_active = 0;
> otg->default_a = 0;
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> MUSB_DEV_MODE(musb);
> }
>
> @@ -569,7 +569,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
>
> dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> musb_readb(musb->mregs, MUSB_DEVCTL),
> musb_readl(tbase, TUSB_DEV_OTG_STAT),
> conf, prcm);
> @@ -668,23 +668,23 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
>
> if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
> dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n");
> - if (musb->xceiv->state != OTG_STATE_B_IDLE) {
> + if (musb->xceiv->otg->state != OTG_STATE_B_IDLE) {
> /* INTR_DISCONNECT can hide... */
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> musb->int_usb |= MUSB_INTR_DISCONNECT;
> }
> musb->is_active = 0;
> }
> dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
> - usb_otg_state_string(musb->xceiv->state), otg_stat);
> + usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
> idle_timeout = jiffies + (1 * HZ);
> schedule_work(&musb->irq_work);
>
> } else /* A-dev state machine */ {
> dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
> - usb_otg_state_string(musb->xceiv->state), otg_stat);
> + usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_IDLE:
> dev_dbg(musb->controller, "Got SRP, turning on VBUS\n");
> musb_platform_set_vbus(musb, 1);
> @@ -731,9 +731,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
> u8 devctl;
>
> dev_dbg(musb->controller, "%s timer, %03x\n",
> - usb_otg_state_string(musb->xceiv->state), otg_stat);
> + usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
>
> - switch (musb->xceiv->state) {
> + switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_WAIT_VRISE:
> /* VBUS has probably been valid for a while now,
> * but may well have bounced out of range a bit
> @@ -745,7 +745,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
> dev_dbg(musb->controller, "devctl %02x\n", devctl);
> break;
> }
> - musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
> musb->is_active = 0;
> idle_timeout = jiffies
> + msecs_to_jiffies(musb->a_wait_bcon);
> diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
> index d0180a7..1d631d5 100644
> --- a/drivers/usb/musb/ux500.c
> +++ b/drivers/usb/musb/ux500.c
> @@ -56,7 +56,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
> devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
>
> if (is_on) {
> - if (musb->xceiv->state == OTG_STATE_A_IDLE) {
> + if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
> /* start the session */
> devctl |= MUSB_DEVCTL_SESSION;
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
> @@ -76,7 +76,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
> } else {
> musb->is_active = 1;
> musb->xceiv->otg->default_a = 1;
> - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
> + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> devctl |= MUSB_DEVCTL_SESSION;
> MUSB_HST_MODE(musb);
> }
> @@ -102,7 +102,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
> mdelay(200);
>
> dev_dbg(musb->controller, "VBUS %s, devctl %02x\n",
> - usb_otg_state_string(musb->xceiv->state),
> + usb_otg_state_string(musb->xceiv->otg->state),
> musb_readb(musb->mregs, MUSB_DEVCTL));
> }
>
> @@ -112,7 +112,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
> struct musb *musb = container_of(nb, struct musb, nb);
>
> dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n",
> - event, usb_otg_state_string(musb->xceiv->state));
> + event, usb_otg_state_string(musb->xceiv->otg->state));
>
> switch (event) {
> case UX500_MUSB_ID:
> @@ -127,7 +127,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
> if (is_host_active(musb))
> ux500_musb_set_vbus(musb, 0);
> else
> - musb->xceiv->state = OTG_STATE_B_IDLE;
> + musb->xceiv->otg->state = OTG_STATE_B_IDLE;
> break;
> default:
> dev_dbg(musb->controller, "ID float\n");
> diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
> index 11ab2c4..2d52501 100644
> --- a/drivers/usb/phy/phy-ab8500-usb.c
> +++ b/drivers/usb/phy/phy-ab8500-usb.c
> @@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
> if (event != UX500_MUSB_RIDB)
> event = UX500_MUSB_NONE;
> /* Fallback to default B_IDLE as nothing is connected. */
> - ab->phy.state = OTG_STATE_B_IDLE;
> + ab->phy.otg->state = OTG_STATE_B_IDLE;
> break;
>
> case USB_LINK_ACA_RID_C_NM_9540:
> @@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
> * Fallback to default B_IDLE as nothing
> * is connected
> */
> - ab->phy.state = OTG_STATE_B_IDLE;
> + ab->phy.otg->state = OTG_STATE_B_IDLE;
> break;
>
> case USB_LINK_ACA_RID_C_NM_8540:
> @@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
> * Fallback to default B_IDLE as nothing
> * is connected
> */
> - ab->phy.state = OTG_STATE_B_IDLE;
> + ab->phy.otg->state = OTG_STATE_B_IDLE;
> break;
>
> case USB_LINK_ACA_RID_C_NM_8505:
> @@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,
> if (event != UX500_MUSB_RIDB)
> event = UX500_MUSB_NONE;
> /* Fallback to default B_IDLE as nothing is connected */
> - ab->phy.state = OTG_STATE_B_IDLE;
> + ab->phy.otg->state = OTG_STATE_B_IDLE;
> break;
>
> case USB_LINK_ACA_RID_C_NM_8500:
> @@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
> ab->phy.label = "ab8500";
> ab->phy.set_suspend = ab8500_usb_set_suspend;
> ab->phy.set_power = ab8500_usb_set_power;
> - ab->phy.state = OTG_STATE_UNDEFINED;
> + ab->phy.otg->state = OTG_STATE_UNDEFINED;
>
> otg->phy = &ab->phy;
> otg->set_host = ab8500_usb_set_host;
> diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
> index f1ea599..15d7a81 100644
> --- a/drivers/usb/phy/phy-fsl-usb.c
> +++ b/drivers/usb/phy/phy-fsl-usb.c
> @@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
> /* Mini-A cable connected */
> struct otg_fsm *fsm = &otg_dev->fsm;
>
> - otg->phy->state = OTG_STATE_UNDEFINED;
> + otg.state = OTG_STATE_UNDEFINED;
> fsm->protocol = PROTO_UNDEF;
> }
> }
> @@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
> {
> if (!fsl_otg_dev)
> return -ENODEV;
> - if (phy->state == OTG_STATE_B_PERIPHERAL)
> + if (phy->otg.state == OTG_STATE_B_PERIPHERAL)
> pr_info("FSL OTG: Draw %d mA\n", mA);
>
> return 0;
> @@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
> {
> struct fsl_otg *otg_dev;
>
> - if (!otg || otg->phy->state != OTG_STATE_B_IDLE)
> + if (!otg || otg.state != OTG_STATE_B_IDLE)
> return -ENODEV;
>
> otg_dev = container_of(otg->phy, struct fsl_otg, phy);
> @@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev)
> * Also: record initial state of ID pin
> */
> if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
> - p_otg->phy.state = OTG_STATE_UNDEFINED;
> + p_otg->phy->otg.state = OTG_STATE_UNDEFINED;
> p_otg->fsm.id = 1;
> } else {
> - p_otg->phy.state = OTG_STATE_A_IDLE;
> + p_otg->phy->otg.state = OTG_STATE_A_IDLE;
> p_otg->fsm.id = 0;
> }
>
> diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
> index 7594e50..280a345 100644
> --- a/drivers/usb/phy/phy-generic.c
> +++ b/drivers/usb/phy/phy-generic.c
> @@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
> }
>
> otg->gadget = gadget;
> - otg->phy->state = OTG_STATE_B_IDLE;
> + otg->state = OTG_STATE_B_IDLE;
> return 0;
> }
>
> @@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
> nop->phy.dev = nop->dev;
> nop->phy.label = "nop-xceiv";
> nop->phy.set_suspend = nop_set_suspend;
> - nop->phy.state = OTG_STATE_UNDEFINED;
> nop->phy.type = type;
>
> + nop->phy.otg->state = OTG_STATE_UNDEFINED;
> nop->phy.otg->phy = &nop->phy;
> nop->phy.otg->set_host = nop_set_host;
> nop->phy.otg->set_peripheral = nop_set_peripheral;
> diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
> index f4b14bd..7a6be3e 100644
> --- a/drivers/usb/phy/phy-gpio-vbus-usb.c
> +++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
> @@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work)
>
> if (vbus) {
> status = USB_EVENT_VBUS;
> - gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
> + gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL;
> gpio_vbus->phy.last_event = status;
> usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);
>
> @@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work)
>
> usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
> status = USB_EVENT_NONE;
> - gpio_vbus->phy.state = OTG_STATE_B_IDLE;
> + gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE;
> gpio_vbus->phy.last_event = status;
>
> atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
> @@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
> set_vbus_draw(gpio_vbus, 0);
>
> usb_gadget_vbus_disconnect(otg->gadget);
> - otg->phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
>
> otg->gadget = NULL;
> return 0;
> @@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)
>
> gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);
>
> - if (phy->state == OTG_STATE_B_PERIPHERAL)
> + if (phy->otg->state == OTG_STATE_B_PERIPHERAL)
> set_vbus_draw(gpio_vbus, mA);
> return 0;
> }
> @@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
> gpio_vbus->phy.dev = gpio_vbus->dev;
> gpio_vbus->phy.set_power = gpio_vbus_set_power;
> gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
> - gpio_vbus->phy.state = OTG_STATE_UNDEFINED;
>
> + gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
> gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
> gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
>
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index 471e69d..18015b7 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
> }
>
> if (!host) {
> - if (otg->phy->state == OTG_STATE_A_HOST) {
> + if (otg->state == OTG_STATE_A_HOST) {
> pm_runtime_get_sync(otg->phy->dev);
> msm_otg_start_host(otg->phy, 0);
> otg->host = NULL;
> - otg->phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
> schedule_work(&motg->sm_work);
> } else {
> otg->host = NULL;
> @@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
> }
>
> if (!gadget) {
> - if (otg->phy->state == OTG_STATE_B_PERIPHERAL) {
> + if (otg->state == OTG_STATE_B_PERIPHERAL) {
> pm_runtime_get_sync(otg->phy->dev);
> msm_otg_start_peripheral(otg->phy, 0);
> otg->gadget = NULL;
> - otg->phy->state = OTG_STATE_UNDEFINED;
> + otg->state = OTG_STATE_UNDEFINED;
> schedule_work(&motg->sm_work);
> } else {
> otg->gadget = NULL;
> @@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w)
> struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
> struct usb_otg *otg = motg->phy.otg;
>
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_UNDEFINED:
> dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
> msm_otg_reset(otg->phy);
> msm_otg_init_sm(motg);
> - otg->phy->state = OTG_STATE_B_IDLE;
> + otg->state = OTG_STATE_B_IDLE;
> /* FALL THROUGH */
> case OTG_STATE_B_IDLE:
> dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
> @@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w)
> /* disable BSV bit */
> writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
> msm_otg_start_host(otg->phy, 1);
> - otg->phy->state = OTG_STATE_A_HOST;
> + otg->state = OTG_STATE_A_HOST;
> } else if (test_bit(B_SESS_VLD, &motg->inputs)) {
> switch (motg->chg_state) {
> case USB_CHG_STATE_UNDEFINED:
> @@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w)
> msm_otg_notify_charger(motg,
> IDEV_CHG_MAX);
> msm_otg_start_peripheral(otg->phy, 1);
> - otg->phy->state
> + otg->state
> = OTG_STATE_B_PERIPHERAL;
> break;
> case USB_SDP_CHARGER:
> msm_otg_notify_charger(motg, IUNIT);
> msm_otg_start_peripheral(otg->phy, 1);
> - otg->phy->state
> + otg->state
> = OTG_STATE_B_PERIPHERAL;
> break;
> default:
> @@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w)
> motg->chg_type = USB_INVALID_CHARGER;
> }
>
> - if (otg->phy->state == OTG_STATE_B_IDLE)
> + if (otg->state == OTG_STATE_B_IDLE)
> pm_runtime_put_sync(otg->phy->dev);
> break;
> case OTG_STATE_B_PERIPHERAL:
> @@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w)
> msm_otg_start_peripheral(otg->phy, 0);
> motg->chg_state = USB_CHG_STATE_UNDEFINED;
> motg->chg_type = USB_INVALID_CHARGER;
> - otg->phy->state = OTG_STATE_B_IDLE;
> + otg->state = OTG_STATE_B_IDLE;
> msm_otg_reset(otg->phy);
> schedule_work(w);
> }
> @@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w)
> dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
> if (test_bit(ID, &motg->inputs)) {
> msm_otg_start_host(otg->phy, 0);
> - otg->phy->state = OTG_STATE_B_IDLE;
> + otg->state = OTG_STATE_B_IDLE;
> msm_otg_reset(otg->phy);
> schedule_work(w);
> }
> @@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
> struct msm_otg *motg = s->private;
> struct usb_otg *otg = motg->phy.otg;
>
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_A_HOST:
> seq_puts(s, "host\n");
> break;
> @@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
>
> switch (req_mode) {
> case USB_DR_MODE_UNKNOWN:
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_A_HOST:
> case OTG_STATE_B_PERIPHERAL:
> set_bit(ID, &motg->inputs);
> @@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
> }
> break;
> case USB_DR_MODE_PERIPHERAL:
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_B_IDLE:
> case OTG_STATE_A_HOST:
> set_bit(ID, &motg->inputs);
> @@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
> }
> break;
> case USB_DR_MODE_HOST:
> - switch (otg->phy->state) {
> + switch (otg->state) {
> case OTG_STATE_B_IDLE:
> case OTG_STATE_B_PERIPHERAL:
> clear_bit(ID, &motg->inputs);
> @@ -1769,7 +1769,7 @@ static int msm_otg_runtime_idle(struct device *dev)
> * This 1 sec delay also prevents entering into LPM immediately
> * after asynchronous interrupt.
> */
> - if (otg->phy->state != OTG_STATE_UNDEFINED)
> + if (otg->state != OTG_STATE_UNDEFINED)
> pm_schedule_suspend(dev, 1000);
>
> return -EAGAIN;
> diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
> index c9517d8..ee87aa7 100644
> --- a/drivers/usb/phy/phy-mv-usb.c
> +++ b/drivers/usb/phy/phy-mv-usb.c
> @@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
> {
> struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
> struct usb_phy *phy = &mvotg->phy;
> - int old_state = phy->state;
> + int old_state = mvotg->phy.otg->state;
>
> switch (old_state) {
> case OTG_STATE_UNDEFINED:
> - phy->state = OTG_STATE_B_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_B_IDLE;
> /* FALL THROUGH */
> case OTG_STATE_B_IDLE:
> if (otg_ctrl->id == 0)
> - phy->state = OTG_STATE_A_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_A_IDLE;
> else if (otg_ctrl->b_sess_vld)
> - phy->state = OTG_STATE_B_PERIPHERAL;
> + mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
> break;
> case OTG_STATE_B_PERIPHERAL:
> if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
> - phy->state = OTG_STATE_B_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_B_IDLE;
> break;
> case OTG_STATE_A_IDLE:
> if (otg_ctrl->id)
> - phy->state = OTG_STATE_B_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_B_IDLE;
> else if (!(otg_ctrl->a_bus_drop) &&
> (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
> - phy->state = OTG_STATE_A_WAIT_VRISE;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
> break;
> case OTG_STATE_A_WAIT_VRISE:
> if (otg_ctrl->a_vbus_vld)
> - phy->state = OTG_STATE_A_WAIT_BCON;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
> break;
> case OTG_STATE_A_WAIT_BCON:
> if (otg_ctrl->id || otg_ctrl->a_bus_drop
> || otg_ctrl->a_wait_bcon_timeout) {
> mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
> mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
> - phy->state = OTG_STATE_A_WAIT_VFALL;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
> otg_ctrl->a_bus_req = 0;
> } else if (!otg_ctrl->a_vbus_vld) {
> mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
> mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
> - phy->state = OTG_STATE_A_VBUS_ERR;
> + mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
> } else if (otg_ctrl->b_conn) {
> mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
> mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
> - phy->state = OTG_STATE_A_HOST;
> + mvotg->phy.otg->state = OTG_STATE_A_HOST;
> }
> break;
> case OTG_STATE_A_HOST:
> if (otg_ctrl->id || !otg_ctrl->b_conn
> || otg_ctrl->a_bus_drop)
> - phy->state = OTG_STATE_A_WAIT_BCON;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
> else if (!otg_ctrl->a_vbus_vld)
> - phy->state = OTG_STATE_A_VBUS_ERR;
> + mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
> break;
> case OTG_STATE_A_WAIT_VFALL:
> if (otg_ctrl->id
> || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
> || otg_ctrl->a_bus_req)
> - phy->state = OTG_STATE_A_IDLE;
> + mvotg->phy.otg->state = OTG_STATE_A_IDLE;
> break;
> case OTG_STATE_A_VBUS_ERR:
> if (otg_ctrl->id || otg_ctrl->a_clr_err
> || otg_ctrl->a_bus_drop) {
> otg_ctrl->a_clr_err = 0;
> - phy->state = OTG_STATE_A_WAIT_VFALL;
> + mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
> }
> break;
> default:
> @@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work)
> run:
> /* work queue is single thread, or we need spin_lock to protect */
> phy = &mvotg->phy;
> - otg = phy->otg;
> - old_state = phy->state;
> + otg = mvotg->phy.otg;
> + old_state = otg->state;
>
> if (!mvotg->active)
> return;
> @@ -429,12 +429,12 @@ run:
> mv_otg_update_inputs(mvotg);
> mv_otg_update_state(mvotg);
>
> - if (old_state != phy->state) {
> + if (old_state != mvotg->phy.otg->state) {
> dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
> state_string[old_state],
> - state_string[phy->state]);
> + state_string[mvotg->phy.otg->state]);
>
> - switch (phy->state) {
> + switch (mvotg->phy.otg->state) {
> case OTG_STATE_B_IDLE:
> otg->default_a = 0;
> if (old_state == OTG_STATE_B_PERIPHERAL)
> @@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
> return -1;
>
> /* We will use this interface to change to A device */
> - if (mvotg->phy.state != OTG_STATE_B_IDLE
> - && mvotg->phy.state != OTG_STATE_A_IDLE)
> + if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
> + && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
> return -1;
>
> /* The clock may disabled and we need to set irq for ID detected */
> @@ -715,9 +715,9 @@ static int mv_otg_probe(struct platform_device *pdev)
> mvotg->phy.dev = &pdev->dev;
> mvotg->phy.otg = otg;
> mvotg->phy.label = driver_name;
> - mvotg->phy.state = OTG_STATE_UNDEFINED;
>
> otg->phy = &mvotg->phy;
> + otg->state = OTG_STATE_UNDEFINED;
> otg->set_host = mv_otg_set_host;
> otg->set_peripheral = mv_otg_set_peripheral;
> otg->set_vbus = mv_otg_set_vbus;
> diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
> index cc61ee4..04ece53 100644
> --- a/drivers/usb/phy/phy-tahvo.c
> +++ b/drivers/usb/phy/phy-tahvo.c
> @@ -81,33 +81,33 @@ static void check_vbus_state(struct tahvo_usb *tu)
>
> reg = retu_read(rdev, TAHVO_REG_IDSR);
> if (reg & TAHVO_STAT_VBUS) {
> - switch (tu->phy.state) {
> + switch (tu->phy.otg->state) {
> case OTG_STATE_B_IDLE:
> /* Enable the gadget driver */
> if (tu->phy.otg->gadget)
> usb_gadget_vbus_connect(tu->phy.otg->gadget);
> - tu->phy.state = OTG_STATE_B_PERIPHERAL;
> + tu->phy.otg->state = OTG_STATE_B_PERIPHERAL;
> break;
> case OTG_STATE_A_IDLE:
> /*
> * Session is now valid assuming the USB hub is driving
> * Vbus.
> */
> - tu->phy.state = OTG_STATE_A_HOST;
> + tu->phy.otg->state = OTG_STATE_A_HOST;
> break;
> default:
> break;
> }
> dev_info(&tu->pt_dev->dev, "USB cable connected\n");
> } else {
> - switch (tu->phy.state) {
> + switch (tu->phy.otg->state) {
> case OTG_STATE_B_PERIPHERAL:
> if (tu->phy.otg->gadget)
> usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
> - tu->phy.state = OTG_STATE_B_IDLE;
> + tu->phy.otg->state = OTG_STATE_B_IDLE;
> break;
> case OTG_STATE_A_HOST:
> - tu->phy.state = OTG_STATE_A_IDLE;
> + tu->phy.otg->state = OTG_STATE_A_IDLE;
> break;
> default:
> break;
> @@ -132,14 +132,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu)
> /* Power up the transceiver in USB host mode */
> retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
> USBR_MASTER_SW2 | USBR_MASTER_SW1);
> - tu->phy.state = OTG_STATE_A_IDLE;
> + tu->phy.otg->state = OTG_STATE_A_IDLE;
>
> check_vbus_state(tu);
> }
>
> static void tahvo_usb_stop_host(struct tahvo_usb *tu)
> {
> - tu->phy.state = OTG_STATE_A_IDLE;
> + tu->phy.otg->state = OTG_STATE_A_IDLE;
> }
>
> static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
> @@ -151,7 +151,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
> /* Power up transceiver and set it in USB peripheral mode */
> retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT |
> USBR_NSUSPEND | USBR_SLAVE_SW);
> - tu->phy.state = OTG_STATE_B_IDLE;
> + tu->phy.otg->state = OTG_STATE_B_IDLE;
>
> check_vbus_state(tu);
> }
> @@ -160,7 +160,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu)
> {
> if (tu->phy.otg->gadget)
> usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
> - tu->phy.state = OTG_STATE_B_IDLE;
> + tu->phy.otg->state = OTG_STATE_B_IDLE;
> }
>
> static void tahvo_usb_power_off(struct tahvo_usb *tu)
> @@ -173,7 +173,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu)
>
> /* Power off transceiver */
> retu_write(rdev, TAHVO_REG_USBR, 0);
> - tu->phy.state = OTG_STATE_UNDEFINED;
> + tu->phy.otg->state = OTG_STATE_UNDEFINED;
> }
>
> static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend)
> @@ -379,7 +379,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
> /* Create OTG interface */
> tahvo_usb_power_off(tu);
> tu->phy.dev = &pdev->dev;
> - tu->phy.state = OTG_STATE_UNDEFINED;
> + tu->phy.otg->state = OTG_STATE_UNDEFINED;
> tu->phy.label = DRIVER_NAME;
> tu->phy.set_suspend = tahvo_usb_set_suspend;
>
> diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
> index 154332b..33d3480 100644
> --- a/include/linux/usb/otg.h
> +++ b/include/linux/usb/otg.h
> @@ -18,6 +18,8 @@ struct usb_otg {
> struct usb_bus *host;
> struct usb_gadget *gadget;
>
> + enum usb_otg_state state;
> +
> /* bind/unbind the host controller */
> int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
>
> diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
> index 353053a..ac7d791 100644
> --- a/include/linux/usb/phy.h
> +++ b/include/linux/usb/phy.h
> @@ -77,7 +77,6 @@ struct usb_phy {
> unsigned int flags;
>
> enum usb_phy_type type;
> - enum usb_otg_state state;
> enum usb_phy_events last_event;
>
> struct usb_otg *otg;
>
>
>

2014-10-31 13:34:14

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

Hi,

On Thu, Oct 30, 2014 at 07:47:10PM -0500, Felipe Balbi wrote:
> Hi,
>
> On Fri, Oct 31, 2014 at 08:38:14AM +0800, Peter Chen wrote:
> > On Thu, Oct 30, 2014 at 12:47:34PM -0500, Felipe Balbi wrote:
> > > On Thu, Oct 30, 2014 at 06:42:54PM +0100, Antoine Tenart wrote:
> > > > Hi Felipe,
> > > >
> > > > On Thu, Oct 30, 2014 at 11:35:13AM -0500, Felipe Balbi wrote:
> > > > > On Thu, Oct 30, 2014 at 11:31:48AM -0500, Felipe Balbi wrote:
> > > > > > On Tue, Oct 28, 2014 at 05:35:35PM +0100, Antoine Tenart wrote:
> > > > > > > Before using the PHY framework instead of the USB PHY one, we need to
> > > > > > > move the OTG state into another place, since it won't be available when
> > > > > > > USB PHY isn't used. This patch moves the OTG state into the OTG
> > > > > > > structure, and makes all the needed modifications in the drivers
> > > > > > > using the OTG state.
> > > > > > >
> > > > > > > Signed-off-by: Antoine Tenart <[email protected]>
> > > > > > > Acked-by: Peter Chen <[email protected]>
> > > > > >
> > > > > > Acked-by: Felipe Balbi <[email protected]>
> > > > >
> > > > > Please rebase on my testing/next and I'll take the series. When
> > > > > rebasing, then add Peter's Tested-by/Acked-by where they're missing.
> > > >
> > > > I just re-sent the series, rebased on your testing/next branch.
> > >
> > > Thanks, I put them on my testing/next and I'm running build tests.
> > >
> >
> > I see them, I will rebase your testing/next tree for coming chipidea dev, thanks.
>
> I fixed a build breakage caused by $subject which I fixed, updated patch
> below: (Aaro, can I get a tested-by by any chance ?)

two more build regressions found (did you build test your patches ??)

8<----------------------------------------------------------------------

commit 63e3b7dd13426d4452f5b26ceae2af4a4e5de5b3
Author: Antoine Tenart <[email protected]>
Date: Thu Oct 30 18:41:13 2014 +0100

usb: move the OTG state from the USB PHY to the OTG structure

Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.

[ [email protected] : fix build regressions with phy-tahvo.c, musb_dsps.c
and chipidea's debug.c ]

Signed-off-by: Antoine Tenart <[email protected]>
Acked-by: Peter Chen <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 8c84298..9f409359 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)

static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct usb_phy *phy = otg->phy;
-
otg->host = host;
if (!host)
- phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

return 0;
}
@@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
static int omap_usb_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
{
- struct usb_phy *phy = otg->phy;
-
otg->gadget = gadget;
if (!gadget)
- phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

return 0;
}
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 795d653..f038804 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)

/* ------ State ----- */
seq_printf(s, "OTG state: %s\n\n",
- usb_otg_state_string(ci->transceiver->state));
+ usb_otg_state_string(ci->transceiver->otg->state));

/* ------ State Machine Variables ----- */
seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index caaabc5..8cb2508 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
set_tmout(ci, indicator);

/* only vbus fall below B_sess_vld in b_idle state */
- if (ci->transceiver->state == OTG_STATE_B_IDLE)
+ if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
ci_otg_queue_work(ci);
}

@@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
* when there is no gadget class driver
*/
if (ci->fsm.id && !(ci->driver) &&
- ci->transceiver->state < OTG_STATE_A_IDLE)
+ ci->fsm.otg->state < OTG_STATE_A_IDLE)
return 0;

if (otg_statemachine(&ci->fsm)) {
- if (ci->transceiver->state == OTG_STATE_A_IDLE) {
+ if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
/*
* Further state change for cases:
* a_idle to b_idle; or
@@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
ci_otg_queue_work(ci);
if (ci->id_event)
ci->id_event = false;
- } else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
+ } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
if (ci->fsm.b_sess_vld) {
ci->fsm.power_up = 0;
/*
@@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);

- switch (ci->transceiver->state) {
+ switch (ci->fsm.otg->state) {
case OTG_STATE_A_WAIT_BCON:
if (port_conn) {
fsm->b_conn = 1;
@@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
ci->transceiver->otg = ci->fsm.otg;
ci->fsm.power_up = 1;
ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
- ci->transceiver->state = OTG_STATE_UNDEFINED;
+ ci->fsm.otg->state = OTG_STATE_UNDEFINED;
ci->fsm.ops = &ci_otg_ops;

mutex_init(&ci->fsm.lock);
diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
index 98e8340..c6b35b7 100644
--- a/drivers/usb/common/usb-otg-fsm.c
+++ b/drivers/usb/common/usb-otg-fsm.c
@@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{
state_changed = 1;
- if (fsm->otg->phy->state == new_state)
+ if (fsm->otg->state == new_state)
return 0;
VDBG("Set state: %s\n", usb_otg_state_string(new_state));
- otg_leave_state(fsm, fsm->otg->phy->state);
+ otg_leave_state(fsm, fsm->otg->state);
switch (new_state) {
case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0);
@@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
break;
}

- fsm->otg->phy->state = new_state;
+ fsm->otg->state = new_state;
return 0;
}

@@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm)

mutex_lock(&fsm->lock);

- state = fsm->otg->phy->state;
+ state = fsm->otg->state;
state_changed = 0;
/* State machine state change judgement */

diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 0231606d..cf89b4b1 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
otg_start_hnp(hcd->usb_phy->otg);

local_irq_save(flags);
- hcd->usb_phy->state = OTG_STATE_A_SUSPEND;
+ hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
l = omap_readl(OTG_CTRL);
l &= ~OTG_A_BUSREQ;
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index a2735df..d836a3e 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -149,25 +149,25 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
break;
@@ -176,7 +176,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -193,9 +193,9 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround);
last_timer = jiffies;
return;
@@ -208,7 +208,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout);
}
@@ -278,27 +278,27 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

/* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -324,7 +324,7 @@ eoi:
}

/* Poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 8554c6f..f23ce40b 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -185,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
}

/* Start sampling ID pin, when plug is removed from MUSB */
- if ((musb->xceiv->state == OTG_STATE_B_IDLE
- || musb->xceiv->state == OTG_STATE_A_WAIT_BCON) ||
+ if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE
+ || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) ||
(musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
musb->a_wait_bcon = TIMER_DELAY;
@@ -205,7 +205,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
static u8 toggle;

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE:
case OTG_STATE_A_WAIT_BCON:
/* Start a new session */
@@ -219,7 +219,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);
/* Ignore VBUSERROR and SUSPEND IRQ */
@@ -229,7 +229,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
musb_writeb(musb->mregs, MUSB_INTRUSB, val);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
break;
@@ -245,7 +245,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);

@@ -280,13 +280,13 @@ static void musb_conn_timer_handler(unsigned long _musb)
break;
default:
dev_dbg(musb->controller, "%s state not handled\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
spin_unlock_irqrestore(&musb->lock, flags);

dev_dbg(musb->controller, "state is %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}

static void bfin_musb_enable(struct musb *musb)
@@ -307,7 +307,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)

dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 058775e..527c7fe 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -198,20 +198,20 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
break;
@@ -248,7 +248,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -265,9 +265,9 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround);
last_timer = jiffies;
return;
@@ -280,7 +280,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout);
}
@@ -341,26 +341,26 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -375,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);

/* Poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 04de3ac..3c1d9b2 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -214,10 +214,10 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VFALL:
/* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL
* seems to mis-handle session "start" otherwise (or in our
@@ -228,7 +228,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
break;
@@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -325,20 +325,20 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
* to stop registering in devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

@@ -348,7 +348,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
davinci_musb_source_power(musb, drvvbus, 0);
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
retval = IRQ_HANDLED;
@@ -361,7 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
musb_writel(tibase, DAVINCI_USB_EOI_REG, 0);

/* poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index e46e295..df9c5fa 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -360,23 +360,23 @@ static void musb_otg_timer_func(unsigned long data)
unsigned long flags;

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: b_wait_acon timeout; back to b_peripheral\n");
musb_g_disconnect(musb);
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 0;
break;
case OTG_STATE_A_SUSPEND:
case OTG_STATE_A_WAIT_BCON:
dev_dbg(musb->controller, "HNP: %s timeout\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
musb_platform_set_vbus(musb, 0);
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
default:
dev_dbg(musb->controller, "HNP: Unhandled mode %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -391,19 +391,19 @@ void musb_hnp_stop(struct musb *musb)
u8 reg;

dev_dbg(musb->controller, "HNP: stop from %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
musb_g_disconnect(musb);
dev_dbg(musb->controller, "HNP: back to %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
case OTG_STATE_B_HOST:
dev_dbg(musb->controller, "HNP: Disabling HR\n");
if (hcd)
hcd->self.is_b_host = 0;
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
reg = musb_readb(mbase, MUSB_POWER);
reg |= MUSB_POWER_SUSPENDM;
@@ -412,7 +412,7 @@ void musb_hnp_stop(struct musb *musb)
break;
default:
dev_dbg(musb->controller, "HNP: Stopping in unknown state %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}

/*
@@ -449,13 +449,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
if (int_usb & MUSB_INTR_RESUME) {
handled = IRQ_HANDLED;
- dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->state));
+ dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->otg->state));

if (devctl & MUSB_DEVCTL_HM) {
void __iomem *mbase = musb->mregs;
u8 power;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
/* remote wakeup? later, GetPortStatus
* will stop RESUME signaling
@@ -482,25 +482,25 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
&musb->finish_resume_work,
msecs_to_jiffies(20));

- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
musb->is_active = 1;
musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 1;
MUSB_DEV_MODE(musb);
break;
default:
WARNING("bogus %s RESUME (%s)\n",
"host",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else {
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
/* possibly DISCONNECT is upcoming */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
@@ -523,7 +523,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
default:
WARNING("bogus %s RESUME (%s)\n",
"peripheral",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -539,7 +539,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
}

dev_dbg(musb->controller, "SESSION_REQUEST (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

/* IRQ arrives from ID pin sense or (later, if VBUS power
* is removed) SRP. responses are time critical:
@@ -550,7 +550,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
musb_writeb(mbase, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
musb->ep0_stage = MUSB_EP0_START;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
musb_platform_set_vbus(musb, 1);

@@ -576,7 +576,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
* REVISIT: do delays from lots of DEBUG_KERNEL checks
* make trouble here, keeping VBUS < 4.4V ?
*/
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
/* recovery is dicey once we've gotten past the
* initial stages of enumeration, but if VBUS
@@ -605,7 +605,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

dev_printk(ignore ? KERN_DEBUG : KERN_ERR, musb->controller,
"VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
devctl,
({ char *s;
switch (devctl & MUSB_DEVCTL_VBUS) {
@@ -630,10 +630,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

if (int_usb & MUSB_INTR_SUSPEND) {
dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
handled = IRQ_HANDLED;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
/* We also come here if the cable is removed, since
* this silicon doesn't report ID-no-longer-grounded.
@@ -657,7 +657,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb_g_suspend(musb);
musb->is_active = musb->g.b_hnp_enable;
if (musb->is_active) {
- musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(
@@ -670,7 +670,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
+ msecs_to_jiffies(musb->a_wait_bcon));
break;
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = musb->hcd->self.b_hnp_enable;
break;
case OTG_STATE_B_HOST:
@@ -713,7 +713,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb->port1_status |= USB_PORT_STAT_LOW_SPEED;

/* indicate new connection to OTG machine */
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL:
if (int_usb & MUSB_INTR_SUSPEND) {
dev_dbg(musb->controller, "HNP: SUSPEND+CONNECT, now b_host\n");
@@ -725,7 +725,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: CONNECT, now b_host\n");
b_host:
- musb->xceiv->state = OTG_STATE_B_HOST;
+ musb->xceiv->otg->state = OTG_STATE_B_HOST;
if (musb->hcd)
musb->hcd->self.is_b_host = 1;
del_timer(&musb->otg_timer);
@@ -733,7 +733,7 @@ b_host:
default:
if ((devctl & MUSB_DEVCTL_VBUS)
== (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
if (hcd)
hcd->self.is_b_host = 0;
}
@@ -743,16 +743,16 @@ b_host:
musb_host_poke_root_hub(musb);

dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
}

if (int_usb & MUSB_INTR_DISCONNECT) {
dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
MUSB_MODE(musb), devctl);
handled = IRQ_HANDLED;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
musb_host_resume_root_hub(musb);
@@ -770,7 +770,7 @@ b_host:
musb_root_disconnect(musb);
if (musb->hcd)
musb->hcd->self.is_b_host = 0;
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
musb_g_disconnect(musb);
break;
@@ -786,7 +786,7 @@ b_host:
break;
default:
WARNING("unhandled DISCONNECT transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
}
@@ -812,15 +812,15 @@ b_host:
}
} else {
dev_dbg(musb->controller, "BUS RESET as %s\n",
- usb_otg_state_string(musb->xceiv->state));
- switch (musb->xceiv->state) {
+ usb_otg_state_string(musb->xceiv->otg->state));
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
musb_g_reset(musb);
/* FALLTHROUGH */
case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
/* never use invalid T(a_wait_bcon) */
dev_dbg(musb->controller, "HNP: in %s, %d msec timeout\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
TA_WAIT_BCON(musb));
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(TA_WAIT_BCON(musb)));
@@ -831,19 +831,19 @@ b_host:
break;
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: RESET (%s), to b_peripheral\n",
- usb_otg_state_string(musb->xceiv->state));
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ usb_otg_state_string(musb->xceiv->otg->state));
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb_g_reset(musb);
break;
case OTG_STATE_B_IDLE:
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
/* FALLTHROUGH */
case OTG_STATE_B_PERIPHERAL:
musb_g_reset(musb);
break;
default:
dev_dbg(musb->controller, "Unhandled BUS RESET as %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -1630,7 +1630,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
int ret = -EINVAL;

spin_lock_irqsave(&musb->lock, flags);
- ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->state));
+ ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->otg->state));
spin_unlock_irqrestore(&musb->lock, flags);

return ret;
@@ -1675,7 +1675,7 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
spin_lock_irqsave(&musb->lock, flags);
/* force T(a_wait_bcon) to be zero/unlimited *OR* valid */
musb->a_wait_bcon = val ? max_t(int, val, OTG_TIME_A_WAIT_BCON) : 0 ;
- if (musb->xceiv->state == OTG_STATE_A_WAIT_BCON)
+ if (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)
musb->is_active = 0;
musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(val));
spin_unlock_irqrestore(&musb->lock, flags);
@@ -1743,8 +1743,8 @@ static void musb_irq_work(struct work_struct *data)
{
struct musb *musb = container_of(data, struct musb, irq_work);

- if (musb->xceiv->state != musb->xceiv_old_state) {
- musb->xceiv_old_state = musb->xceiv->state;
+ if (musb->xceiv->otg->state != musb->xceiv_old_state) {
+ musb->xceiv_old_state = musb->xceiv->otg->state;
sysfs_notify(&musb->controller->kobj, NULL, "mode");
}
}
@@ -1983,10 +1983,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)

if (musb->xceiv->otg->default_a) {
MUSB_HST_MODE(musb);
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
} else {
MUSB_DEV_MODE(musb);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}

switch (musb->port_mode) {
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 759ef1d..440333f 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -179,9 +179,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&glue->timer);
glue->last_timer = jiffies;
return;
@@ -201,7 +201,7 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
glue->last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&glue->timer, timeout);
}
@@ -265,10 +265,10 @@ static void otg_timer(unsigned long _musb)
*/
devctl = dsps_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
skip_session = 1;
@@ -277,10 +277,10 @@ static void otg_timer(unsigned long _musb)
case OTG_STATE_A_IDLE:
case OTG_STATE_B_IDLE:
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
@@ -288,7 +288,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
dsps_writel(musb->ctrl_base, wrp->coreintr_set,
MUSB_INTR_VBUSERROR << wrp->usb_shift);
break;
@@ -373,26 +373,26 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&glue->timer,
jiffies + wrp->poll_seconds * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
del_timer(&glue->timer);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}

/* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -402,7 +402,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
ret |= musb_interrupt(musb);

/* Poll for ID change in OTG port mode */
- if (musb->xceiv->state == OTG_STATE_B_IDLE &&
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
out:
@@ -900,7 +900,7 @@ static int dsps_resume(struct device *dev)
dsps_writel(mbase, wrp->mode, glue->context.mode);
dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
- if (musb->xceiv->state == OTG_STATE_B_IDLE &&
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 4ab1896..56c31b7 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1546,7 +1546,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL:
/* NOTE: OTG state machine doesn't include B_SUSPENDED;
* that's part of the standard usb 1.1 state machine, and
@@ -1587,7 +1587,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
goto done;
default:
dev_dbg(musb->controller, "Unhandled wake: %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
goto done;
}

@@ -1791,7 +1791,7 @@ int musb_gadget_setup(struct musb *musb)

MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;

/* this "gadget" abstracts/virtualizes the controller */
musb->g.name = musb_driver_name;
@@ -1857,7 +1857,7 @@ static int musb_gadget_start(struct usb_gadget *g,
musb->is_active = 1;

otg_set_peripheral(otg, &musb->g);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
spin_unlock_irqrestore(&musb->lock, flags);

musb_start(musb);
@@ -1941,7 +1941,7 @@ static int musb_gadget_stop(struct usb_gadget *g)

(void) musb_gadget_vbus_draw(&musb->g, 0);

- musb->xceiv->state = OTG_STATE_UNDEFINED;
+ musb->xceiv->otg->state = OTG_STATE_UNDEFINED;
stop_activity(musb, NULL);
otg_set_peripheral(musb->xceiv->otg, NULL);

@@ -1968,7 +1968,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
void musb_g_resume(struct musb *musb)
{
musb->is_suspended = 0;
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE:
break;
case OTG_STATE_B_WAIT_ACON:
@@ -1982,7 +1982,7 @@ void musb_g_resume(struct musb *musb)
break;
default:
WARNING("unhandled RESUME transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

@@ -1994,10 +1994,10 @@ void musb_g_suspend(struct musb *musb)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "devctl %02x\n", devctl);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE:
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
musb->is_suspended = 1;
@@ -2012,7 +2012,7 @@ void musb_g_suspend(struct musb *musb)
* A_PERIPHERAL may need care too
*/
WARNING("unhandled SUSPEND transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

@@ -2043,22 +2043,22 @@ void musb_g_disconnect(struct musb *musb)
spin_lock(&musb->lock);
}

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
default:
dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n",
- usb_otg_state_string(musb->xceiv->state));
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ usb_otg_state_string(musb->xceiv->otg->state));
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
break;
case OTG_STATE_A_PERIPHERAL:
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
MUSB_HST_MODE(musb);
break;
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_HOST:
case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_IDLE:
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_B_SRP_INIT:
break;
@@ -2118,13 +2118,13 @@ __acquires(musb->lock)
* In that case, do not rely on devctl for setting
* peripheral mode.
*/
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else {
- musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
}

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 855793d..23d474d 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2463,7 +2463,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
if (!is_host_active(musb))
return 0;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
return 0;
case OTG_STATE_A_WAIT_VRISE:
@@ -2473,7 +2473,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
*/
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
break;
default:
break;
@@ -2481,7 +2481,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)

if (musb->is_active) {
WARNING("trying to suspend as %s while active\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
return -EBUSY;
} else
return 0;
@@ -2678,7 +2678,7 @@ int musb_host_setup(struct musb *musb, int power_budget)

MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;

otg_set_host(musb->xceiv->otg, &hcd->self);
hcd->self.otg_port = 1;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index e2d2d8c..a133bd8 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -69,7 +69,7 @@ void musb_host_finish_resume(struct work_struct *work)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;

spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -107,9 +107,9 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);

musb->port1_status |= USB_PORT_STAT_SUSPEND;
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = otg->host->b_hnp_enable;
if (musb->is_active)
mod_timer(&musb->otg_timer, jiffies
@@ -118,13 +118,13 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
musb_platform_try_idle(musb, 0);
break;
case OTG_STATE_B_HOST:
- musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
musb->is_active = otg->host->b_hnp_enable;
musb_platform_try_idle(musb, 0);
break;
default:
dev_dbg(musb->controller, "bogus rh suspend? %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else if (power & MUSB_POWER_SUSPENDM) {
power &= ~MUSB_POWER_SUSPENDM;
@@ -145,7 +145,7 @@ void musb_port_reset(struct musb *musb, bool do_reset)
u8 power;
void __iomem *mbase = musb->mregs;

- if (musb->xceiv->state == OTG_STATE_B_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) {
dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n");
musb->port1_status &= ~USB_PORT_STAT_RESET;
return;
@@ -224,24 +224,24 @@ void musb_root_disconnect(struct musb *musb)
usb_hcd_poll_rh_status(musb->hcd);
musb->is_active = 0;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
if (otg->host->b_hnp_enable) {
- musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
break;
}
/* FALLTHROUGH */
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "host disconnect (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 20fc2a5..763649e 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
}
break;
case OTG_STATE_A_HOST:
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE)
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
else
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
default:
break;
}
@@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer);
last_timer = jiffies;
return;
@@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout);
}
@@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);

if (is_on) {
- if (musb->xceiv->state == OTG_STATE_A_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
int loops = 100;
/* start the session */
devctl |= MUSB_DEVCTL_SESSION;
@@ -180,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 1;
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
}
@@ -192,7 +192,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
*/

otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
devctl &= ~MUSB_DEVCTL_SESSION;

MUSB_DEV_MODE(musb);
@@ -201,7 +201,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)

dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

@@ -266,7 +266,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "ID GND\n");

otg->default_a = true;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
musb->xceiv->last_event = USB_EVENT_ID;
if (musb->gadget_driver) {
pm_runtime_get_sync(dev);
@@ -280,7 +280,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "VBUS Connect\n");

otg->default_a = false;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->xceiv->last_event = USB_EVENT_VBUS;
if (musb->gadget_driver)
pm_runtime_get_sync(dev);
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 25f02df..69ca92d6 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -415,13 +415,13 @@ static void musb_do_idle(unsigned long _musb)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
if ((musb->a_wait_bcon != 0)
&& (musb->idle_timeout == 0
|| time_after(jiffies, musb->idle_timeout))) {
dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
/* FALLTHROUGH */
case OTG_STATE_A_IDLE:
@@ -474,9 +474,9 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer);
last_timer = jiffies;
return;
@@ -493,7 +493,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout);
}
@@ -524,7 +524,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
if (is_on) {
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;

conf |= TUSB_DEV_CONF_USB_HOST_MODE;
@@ -537,16 +537,16 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
/* If ID pin is grounded, we want to be a_idle */
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE:
case OTG_STATE_A_WAIT_BCON:
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
}
musb->is_active = 0;
otg->default_a = 1;
@@ -554,7 +554,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 0;
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
}

@@ -569,7 +569,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL),
musb_readl(tbase, TUSB_DEV_OTG_STAT),
conf, prcm);
@@ -668,23 +668,23 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)

if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n");
- if (musb->xceiv->state != OTG_STATE_B_IDLE) {
+ if (musb->xceiv->otg->state != OTG_STATE_B_IDLE) {
/* INTR_DISCONNECT can hide... */
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->int_usb |= MUSB_INTR_DISCONNECT;
}
musb->is_active = 0;
}
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
idle_timeout = jiffies + (1 * HZ);
schedule_work(&musb->irq_work);

} else /* A-dev state machine */ {
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE:
dev_dbg(musb->controller, "Got SRP, turning on VBUS\n");
musb_platform_set_vbus(musb, 1);
@@ -731,9 +731,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
u8 devctl;

dev_dbg(musb->controller, "%s timer, %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE:
/* VBUS has probably been valid for a while now,
* but may well have bounced out of range a bit
@@ -745,7 +745,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
dev_dbg(musb->controller, "devctl %02x\n", devctl);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
idle_timeout = jiffies
+ msecs_to_jiffies(musb->a_wait_bcon);
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index d0180a7..1d631d5 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -56,7 +56,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);

if (is_on) {
- if (musb->xceiv->state == OTG_STATE_A_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
/* start the session */
devctl |= MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
@@ -76,7 +76,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 1;
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
}
@@ -102,7 +102,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
mdelay(200);

dev_dbg(musb->controller, "VBUS %s, devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

@@ -112,7 +112,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
struct musb *musb = container_of(nb, struct musb, nb);

dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n",
- event, usb_otg_state_string(musb->xceiv->state));
+ event, usb_otg_state_string(musb->xceiv->otg->state));

switch (event) {
case UX500_MUSB_ID:
@@ -127,7 +127,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
if (is_host_active(musb))
ux500_musb_set_vbus(musb, 0);
else
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "ID float\n");
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 11ab2c4..2d52501 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected. */
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_9540:
@@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing
* is connected
*/
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8540:
@@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing
* is connected
*/
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8505:
@@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected */
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8500:
@@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
ab->phy.label = "ab8500";
ab->phy.set_suspend = ab8500_usb_set_suspend;
ab->phy.set_power = ab8500_usb_set_power;
- ab->phy.state = OTG_STATE_UNDEFINED;
+ ab->phy.otg->state = OTG_STATE_UNDEFINED;

otg->phy = &ab->phy;
otg->set_host = ab8500_usb_set_host;
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index f1ea599..15d7a81 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
/* Mini-A cable connected */
struct otg_fsm *fsm = &otg_dev->fsm;

- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg.state = OTG_STATE_UNDEFINED;
fsm->protocol = PROTO_UNDEF;
}
}
@@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
{
if (!fsl_otg_dev)
return -ENODEV;
- if (phy->state == OTG_STATE_B_PERIPHERAL)
+ if (phy->otg.state == OTG_STATE_B_PERIPHERAL)
pr_info("FSL OTG: Draw %d mA\n", mA);

return 0;
@@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
{
struct fsl_otg *otg_dev;

- if (!otg || otg->phy->state != OTG_STATE_B_IDLE)
+ if (!otg || otg.state != OTG_STATE_B_IDLE)
return -ENODEV;

otg_dev = container_of(otg->phy, struct fsl_otg, phy);
@@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev)
* Also: record initial state of ID pin
*/
if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
- p_otg->phy.state = OTG_STATE_UNDEFINED;
+ p_otg->phy->otg.state = OTG_STATE_UNDEFINED;
p_otg->fsm.id = 1;
} else {
- p_otg->phy.state = OTG_STATE_A_IDLE;
+ p_otg->phy->otg.state = OTG_STATE_A_IDLE;
p_otg->fsm.id = 0;
}

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 7594e50..280a345 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
}

otg->gadget = gadget;
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
return 0;
}

@@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv";
nop->phy.set_suspend = nop_set_suspend;
- nop->phy.state = OTG_STATE_UNDEFINED;
nop->phy.type = type;

+ nop->phy.otg->state = OTG_STATE_UNDEFINED;
nop->phy.otg->phy = &nop->phy;
nop->phy.otg->set_host = nop_set_host;
nop->phy.otg->set_peripheral = nop_set_peripheral;
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index f4b14bd..7a6be3e 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work)

if (vbus) {
status = USB_EVENT_VBUS;
- gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
+ gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL;
gpio_vbus->phy.last_event = status;
usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);

@@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work)

usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
status = USB_EVENT_NONE;
- gpio_vbus->phy.state = OTG_STATE_B_IDLE;
+ gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE;
gpio_vbus->phy.last_event = status;

atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
@@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
set_vbus_draw(gpio_vbus, 0);

usb_gadget_vbus_disconnect(otg->gadget);
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

otg->gadget = NULL;
return 0;
@@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)

gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);

- if (phy->state == OTG_STATE_B_PERIPHERAL)
+ if (phy->otg->state == OTG_STATE_B_PERIPHERAL)
set_vbus_draw(gpio_vbus, mA);
return 0;
}
@@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
gpio_vbus->phy.dev = gpio_vbus->dev;
gpio_vbus->phy.set_power = gpio_vbus_set_power;
gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
- gpio_vbus->phy.state = OTG_STATE_UNDEFINED;

+ gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 471e69d..18015b7 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
}

if (!host) {
- if (otg->phy->state == OTG_STATE_A_HOST) {
+ if (otg->state == OTG_STATE_A_HOST) {
pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_host(otg->phy, 0);
otg->host = NULL;
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
} else {
otg->host = NULL;
@@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
}

if (!gadget) {
- if (otg->phy->state == OTG_STATE_B_PERIPHERAL) {
+ if (otg->state == OTG_STATE_B_PERIPHERAL) {
pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_peripheral(otg->phy, 0);
otg->gadget = NULL;
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
} else {
otg->gadget = NULL;
@@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w)
struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
struct usb_otg *otg = motg->phy.otg;

- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_UNDEFINED:
dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
msm_otg_reset(otg->phy);
msm_otg_init_sm(motg);
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
@@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w)
/* disable BSV bit */
writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
msm_otg_start_host(otg->phy, 1);
- otg->phy->state = OTG_STATE_A_HOST;
+ otg->state = OTG_STATE_A_HOST;
} else if (test_bit(B_SESS_VLD, &motg->inputs)) {
switch (motg->chg_state) {
case USB_CHG_STATE_UNDEFINED:
@@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_notify_charger(motg,
IDEV_CHG_MAX);
msm_otg_start_peripheral(otg->phy, 1);
- otg->phy->state
+ otg->state
= OTG_STATE_B_PERIPHERAL;
break;
case USB_SDP_CHARGER:
msm_otg_notify_charger(motg, IUNIT);
msm_otg_start_peripheral(otg->phy, 1);
- otg->phy->state
+ otg->state
= OTG_STATE_B_PERIPHERAL;
break;
default:
@@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w)
motg->chg_type = USB_INVALID_CHARGER;
}

- if (otg->phy->state == OTG_STATE_B_IDLE)
+ if (otg->state == OTG_STATE_B_IDLE)
pm_runtime_put_sync(otg->phy->dev);
break;
case OTG_STATE_B_PERIPHERAL:
@@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_start_peripheral(otg->phy, 0);
motg->chg_state = USB_CHG_STATE_UNDEFINED;
motg->chg_type = USB_INVALID_CHARGER;
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy);
schedule_work(w);
}
@@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w)
dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
if (test_bit(ID, &motg->inputs)) {
msm_otg_start_host(otg->phy, 0);
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy);
schedule_work(w);
}
@@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
struct msm_otg *motg = s->private;
struct usb_otg *otg = motg->phy.otg;

- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_A_HOST:
seq_puts(s, "host\n");
break;
@@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,

switch (req_mode) {
case USB_DR_MODE_UNKNOWN:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_B_PERIPHERAL:
set_bit(ID, &motg->inputs);
@@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
}
break;
case USB_DR_MODE_PERIPHERAL:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_A_HOST:
set_bit(ID, &motg->inputs);
@@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
}
break;
case USB_DR_MODE_HOST:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_B_PERIPHERAL:
clear_bit(ID, &motg->inputs);
@@ -1769,7 +1769,7 @@ static int msm_otg_runtime_idle(struct device *dev)
* This 1 sec delay also prevents entering into LPM immediately
* after asynchronous interrupt.
*/
- if (otg->phy->state != OTG_STATE_UNDEFINED)
+ if (otg->state != OTG_STATE_UNDEFINED)
pm_schedule_suspend(dev, 1000);

return -EAGAIN;
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index c9517d8..ee87aa7 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
{
struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
struct usb_phy *phy = &mvotg->phy;
- int old_state = phy->state;
+ int old_state = mvotg->phy.otg->state;

switch (old_state) {
case OTG_STATE_UNDEFINED:
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
if (otg_ctrl->id == 0)
- phy->state = OTG_STATE_A_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_A_IDLE;
else if (otg_ctrl->b_sess_vld)
- phy->state = OTG_STATE_B_PERIPHERAL;
+ mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_A_IDLE:
if (otg_ctrl->id)
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
else if (!(otg_ctrl->a_bus_drop) &&
(otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
- phy->state = OTG_STATE_A_WAIT_VRISE;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
break;
case OTG_STATE_A_WAIT_VRISE:
if (otg_ctrl->a_vbus_vld)
- phy->state = OTG_STATE_A_WAIT_BCON;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
break;
case OTG_STATE_A_WAIT_BCON:
if (otg_ctrl->id || otg_ctrl->a_bus_drop
|| otg_ctrl->a_wait_bcon_timeout) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_WAIT_VFALL;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
otg_ctrl->a_bus_req = 0;
} else if (!otg_ctrl->a_vbus_vld) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_VBUS_ERR;
+ mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
} else if (otg_ctrl->b_conn) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_HOST;
+ mvotg->phy.otg->state = OTG_STATE_A_HOST;
}
break;
case OTG_STATE_A_HOST:
if (otg_ctrl->id || !otg_ctrl->b_conn
|| otg_ctrl->a_bus_drop)
- phy->state = OTG_STATE_A_WAIT_BCON;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
else if (!otg_ctrl->a_vbus_vld)
- phy->state = OTG_STATE_A_VBUS_ERR;
+ mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
break;
case OTG_STATE_A_WAIT_VFALL:
if (otg_ctrl->id
|| (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
|| otg_ctrl->a_bus_req)
- phy->state = OTG_STATE_A_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_A_IDLE;
break;
case OTG_STATE_A_VBUS_ERR:
if (otg_ctrl->id || otg_ctrl->a_clr_err
|| otg_ctrl->a_bus_drop) {
otg_ctrl->a_clr_err = 0;
- phy->state = OTG_STATE_A_WAIT_VFALL;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
}
break;
default:
@@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work)
run:
/* work queue is single thread, or we need spin_lock to protect */
phy = &mvotg->phy;
- otg = phy->otg;
- old_state = phy->state;
+ otg = mvotg->phy.otg;
+ old_state = otg->state;

if (!mvotg->active)
return;
@@ -429,12 +429,12 @@ run:
mv_otg_update_inputs(mvotg);
mv_otg_update_state(mvotg);

- if (old_state != phy->state) {
+ if (old_state != mvotg->phy.otg->state) {
dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
state_string[old_state],
- state_string[phy->state]);
+ state_string[mvotg->phy.otg->state]);

- switch (phy->state) {
+ switch (mvotg->phy.otg->state) {
case OTG_STATE_B_IDLE:
otg->default_a = 0;
if (old_state == OTG_STATE_B_PERIPHERAL)
@@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
return -1;

/* We will use this interface to change to A device */
- if (mvotg->phy.state != OTG_STATE_B_IDLE
- && mvotg->phy.state != OTG_STATE_A_IDLE)
+ if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
+ && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
return -1;

/* The clock may disabled and we need to set irq for ID detected */
@@ -715,9 +715,9 @@ static int mv_otg_probe(struct platform_device *pdev)
mvotg->phy.dev = &pdev->dev;
mvotg->phy.otg = otg;
mvotg->phy.label = driver_name;
- mvotg->phy.state = OTG_STATE_UNDEFINED;

otg->phy = &mvotg->phy;
+ otg->state = OTG_STATE_UNDEFINED;
otg->set_host = mv_otg_set_host;
otg->set_peripheral = mv_otg_set_peripheral;
otg->set_vbus = mv_otg_set_vbus;
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index cc61ee4..04ece53 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -81,33 +81,33 @@ static void check_vbus_state(struct tahvo_usb *tu)

reg = retu_read(rdev, TAHVO_REG_IDSR);
if (reg & TAHVO_STAT_VBUS) {
- switch (tu->phy.state) {
+ switch (tu->phy.otg->state) {
case OTG_STATE_B_IDLE:
/* Enable the gadget driver */
if (tu->phy.otg->gadget)
usb_gadget_vbus_connect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_PERIPHERAL;
+ tu->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_A_IDLE:
/*
* Session is now valid assuming the USB hub is driving
* Vbus.
*/
- tu->phy.state = OTG_STATE_A_HOST;
+ tu->phy.otg->state = OTG_STATE_A_HOST;
break;
default:
break;
}
dev_info(&tu->pt_dev->dev, "USB cable connected\n");
} else {
- switch (tu->phy.state) {
+ switch (tu->phy.otg->state) {
case OTG_STATE_B_PERIPHERAL:
if (tu->phy.otg->gadget)
usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_A_HOST:
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -132,14 +132,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu)
/* Power up the transceiver in USB host mode */
retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
USBR_MASTER_SW2 | USBR_MASTER_SW1);
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;

check_vbus_state(tu);
}

static void tahvo_usb_stop_host(struct tahvo_usb *tu)
{
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;
}

static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
@@ -151,7 +151,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
/* Power up transceiver and set it in USB peripheral mode */
retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT |
USBR_NSUSPEND | USBR_SLAVE_SW);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;

check_vbus_state(tu);
}
@@ -160,7 +160,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu)
{
if (tu->phy.otg->gadget)
usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;
}

static void tahvo_usb_power_off(struct tahvo_usb *tu)
@@ -173,7 +173,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu)

/* Power off transceiver */
retu_write(rdev, TAHVO_REG_USBR, 0);
- tu->phy.state = OTG_STATE_UNDEFINED;
+ tu->phy.otg->state = OTG_STATE_UNDEFINED;
}

static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend)
@@ -379,7 +379,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
/* Create OTG interface */
tahvo_usb_power_off(tu);
tu->phy.dev = &pdev->dev;
- tu->phy.state = OTG_STATE_UNDEFINED;
+ tu->phy.otg->state = OTG_STATE_UNDEFINED;
tu->phy.label = DRIVER_NAME;
tu->phy.set_suspend = tahvo_usb_set_suspend;

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 154332b..33d3480 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -18,6 +18,8 @@ struct usb_otg {
struct usb_bus *host;
struct usb_gadget *gadget;

+ enum usb_otg_state state;
+
/* bind/unbind the host controller */
int (*set_host)(struct usb_otg *otg, struct usb_bus *host);

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 353053a..ac7d791 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -77,7 +77,6 @@ struct usb_phy {
unsigned int flags;

enum usb_phy_type type;
- enum usb_otg_state state;
enum usb_phy_events last_event;

struct usb_otg *otg;

--
balbi


Attachments:
(No filename) (76.08 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-10-31 13:48:40

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

Hi,

On Fri, Oct 31, 2014 at 08:33:19AM -0500, Felipe Balbi wrote:
> > > > > > > > Before using the PHY framework instead of the USB PHY one, we need to
> > > > > > > > move the OTG state into another place, since it won't be available when
> > > > > > > > USB PHY isn't used. This patch moves the OTG state into the OTG
> > > > > > > > structure, and makes all the needed modifications in the drivers
> > > > > > > > using the OTG state.
> > > > > > > >
> > > > > > > > Signed-off-by: Antoine Tenart <[email protected]>
> > > > > > > > Acked-by: Peter Chen <[email protected]>
> > > > > > >
> > > > > > > Acked-by: Felipe Balbi <[email protected]>
> > > > > >
> > > > > > Please rebase on my testing/next and I'll take the series. When
> > > > > > rebasing, then add Peter's Tested-by/Acked-by where they're missing.
> > > > >
> > > > > I just re-sent the series, rebased on your testing/next branch.
> > > >
> > > > Thanks, I put them on my testing/next and I'm running build tests.
> > > >
> > >
> > > I see them, I will rebase your testing/next tree for coming chipidea dev, thanks.
> >
> > I fixed a build breakage caused by $subject which I fixed, updated patch
> > below: (Aaro, can I get a tested-by by any chance ?)
>
> two more build regressions found (did you build test your patches ??)

and yet another one on phy-isp1301-omap.c. Seriously, if I find another
build regression I'll drop your series from my queue and defer it to
3.20. This is ridiculous already.

8<------------------------------------------------------------------------

commit 5fd2f70ddea9102019cc9686d2b1eb88405ce235
Author: Antoine Tenart <[email protected]>
Date: Thu Oct 30 18:41:13 2014 +0100

usb: move the OTG state from the USB PHY to the OTG structure

Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.

[ [email protected] : fix build regressions with phy-tahvo.c, musb_dsps.c,
phy-isp1301-omap, and chipidea's debug.c ]

Acked-by: Kishon Vijay Abraham I <[email protected]>
Acked-by: Peter Chen <[email protected]>
Signed-off-by: Antoine Tenart <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 8c84298..9f409359 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)

static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct usb_phy *phy = otg->phy;
-
otg->host = host;
if (!host)
- phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

return 0;
}
@@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
static int omap_usb_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
{
- struct usb_phy *phy = otg->phy;
-
otg->gadget = gadget;
if (!gadget)
- phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

return 0;
}
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 795d653..f038804 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)

/* ------ State ----- */
seq_printf(s, "OTG state: %s\n\n",
- usb_otg_state_string(ci->transceiver->state));
+ usb_otg_state_string(ci->transceiver->otg->state));

/* ------ State Machine Variables ----- */
seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index caaabc5..8cb2508 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
set_tmout(ci, indicator);

/* only vbus fall below B_sess_vld in b_idle state */
- if (ci->transceiver->state == OTG_STATE_B_IDLE)
+ if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
ci_otg_queue_work(ci);
}

@@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
* when there is no gadget class driver
*/
if (ci->fsm.id && !(ci->driver) &&
- ci->transceiver->state < OTG_STATE_A_IDLE)
+ ci->fsm.otg->state < OTG_STATE_A_IDLE)
return 0;

if (otg_statemachine(&ci->fsm)) {
- if (ci->transceiver->state == OTG_STATE_A_IDLE) {
+ if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
/*
* Further state change for cases:
* a_idle to b_idle; or
@@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
ci_otg_queue_work(ci);
if (ci->id_event)
ci->id_event = false;
- } else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
+ } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
if (ci->fsm.b_sess_vld) {
ci->fsm.power_up = 0;
/*
@@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);

- switch (ci->transceiver->state) {
+ switch (ci->fsm.otg->state) {
case OTG_STATE_A_WAIT_BCON:
if (port_conn) {
fsm->b_conn = 1;
@@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
ci->transceiver->otg = ci->fsm.otg;
ci->fsm.power_up = 1;
ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
- ci->transceiver->state = OTG_STATE_UNDEFINED;
+ ci->fsm.otg->state = OTG_STATE_UNDEFINED;
ci->fsm.ops = &ci_otg_ops;

mutex_init(&ci->fsm.lock);
diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
index 98e8340..c6b35b7 100644
--- a/drivers/usb/common/usb-otg-fsm.c
+++ b/drivers/usb/common/usb-otg-fsm.c
@@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{
state_changed = 1;
- if (fsm->otg->phy->state == new_state)
+ if (fsm->otg->state == new_state)
return 0;
VDBG("Set state: %s\n", usb_otg_state_string(new_state));
- otg_leave_state(fsm, fsm->otg->phy->state);
+ otg_leave_state(fsm, fsm->otg->state);
switch (new_state) {
case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0);
@@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
break;
}

- fsm->otg->phy->state = new_state;
+ fsm->otg->state = new_state;
return 0;
}

@@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm)

mutex_lock(&fsm->lock);

- state = fsm->otg->phy->state;
+ state = fsm->otg->state;
state_changed = 0;
/* State machine state change judgement */

diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 0231606d..cf89b4b1 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
otg_start_hnp(hcd->usb_phy->otg);

local_irq_save(flags);
- hcd->usb_phy->state = OTG_STATE_A_SUSPEND;
+ hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
l = omap_readl(OTG_CTRL);
l &= ~OTG_A_BUSREQ;
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index a2735df..d836a3e 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -149,25 +149,25 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
break;
@@ -176,7 +176,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -193,9 +193,9 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround);
last_timer = jiffies;
return;
@@ -208,7 +208,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout);
}
@@ -278,27 +278,27 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

/* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -324,7 +324,7 @@ eoi:
}

/* Poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 8554c6f..f23ce40b 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -185,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
}

/* Start sampling ID pin, when plug is removed from MUSB */
- if ((musb->xceiv->state == OTG_STATE_B_IDLE
- || musb->xceiv->state == OTG_STATE_A_WAIT_BCON) ||
+ if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE
+ || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) ||
(musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
musb->a_wait_bcon = TIMER_DELAY;
@@ -205,7 +205,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
static u8 toggle;

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE:
case OTG_STATE_A_WAIT_BCON:
/* Start a new session */
@@ -219,7 +219,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);
/* Ignore VBUSERROR and SUSPEND IRQ */
@@ -229,7 +229,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
musb_writeb(musb->mregs, MUSB_INTRUSB, val);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
break;
@@ -245,7 +245,7 @@ static void musb_conn_timer_handler(unsigned long _musb)

if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1);
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else {
gpio_set_value(musb->config->gpio_vrsel, 0);

@@ -280,13 +280,13 @@ static void musb_conn_timer_handler(unsigned long _musb)
break;
default:
dev_dbg(musb->controller, "%s state not handled\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
spin_unlock_irqrestore(&musb->lock, flags);

dev_dbg(musb->controller, "state is %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}

static void bfin_musb_enable(struct musb *musb)
@@ -307,7 +307,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)

dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 058775e..527c7fe 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -198,20 +198,20 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
break;
@@ -248,7 +248,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -265,9 +265,9 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround);
last_timer = jiffies;
return;
@@ -280,7 +280,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout);
}
@@ -341,26 +341,26 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -375,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);

/* Poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 04de3ac..3c1d9b2 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -214,10 +214,10 @@ static void otg_timer(unsigned long _musb)
*/
devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VFALL:
/* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL
* seems to mis-handle session "start" otherwise (or in our
@@ -228,7 +228,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
break;
@@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -325,20 +325,20 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
* to stop registering in devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
}

@@ -348,7 +348,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
davinci_musb_source_power(musb, drvvbus, 0);
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
retval = IRQ_HANDLED;
@@ -361,7 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
musb_writel(tibase, DAVINCI_USB_EOI_REG, 0);

/* poll for ID change */
- if (musb->xceiv->state == OTG_STATE_B_IDLE)
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index e46e295..df9c5fa 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -360,23 +360,23 @@ static void musb_otg_timer_func(unsigned long data)
unsigned long flags;

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: b_wait_acon timeout; back to b_peripheral\n");
musb_g_disconnect(musb);
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 0;
break;
case OTG_STATE_A_SUSPEND:
case OTG_STATE_A_WAIT_BCON:
dev_dbg(musb->controller, "HNP: %s timeout\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
musb_platform_set_vbus(musb, 0);
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
default:
dev_dbg(musb->controller, "HNP: Unhandled mode %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -391,19 +391,19 @@ void musb_hnp_stop(struct musb *musb)
u8 reg;

dev_dbg(musb->controller, "HNP: stop from %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
musb_g_disconnect(musb);
dev_dbg(musb->controller, "HNP: back to %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
case OTG_STATE_B_HOST:
dev_dbg(musb->controller, "HNP: Disabling HR\n");
if (hcd)
hcd->self.is_b_host = 0;
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
reg = musb_readb(mbase, MUSB_POWER);
reg |= MUSB_POWER_SUSPENDM;
@@ -412,7 +412,7 @@ void musb_hnp_stop(struct musb *musb)
break;
default:
dev_dbg(musb->controller, "HNP: Stopping in unknown state %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}

/*
@@ -449,13 +449,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
if (int_usb & MUSB_INTR_RESUME) {
handled = IRQ_HANDLED;
- dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->state));
+ dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->otg->state));

if (devctl & MUSB_DEVCTL_HM) {
void __iomem *mbase = musb->mregs;
u8 power;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
/* remote wakeup? later, GetPortStatus
* will stop RESUME signaling
@@ -482,25 +482,25 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
&musb->finish_resume_work,
msecs_to_jiffies(20));

- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
musb->is_active = 1;
musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 1;
MUSB_DEV_MODE(musb);
break;
default:
WARNING("bogus %s RESUME (%s)\n",
"host",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else {
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
/* possibly DISCONNECT is upcoming */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
@@ -523,7 +523,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
default:
WARNING("bogus %s RESUME (%s)\n",
"peripheral",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -539,7 +539,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
}

dev_dbg(musb->controller, "SESSION_REQUEST (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

/* IRQ arrives from ID pin sense or (later, if VBUS power
* is removed) SRP. responses are time critical:
@@ -550,7 +550,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
*/
musb_writeb(mbase, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
musb->ep0_stage = MUSB_EP0_START;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
musb_platform_set_vbus(musb, 1);

@@ -576,7 +576,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
* REVISIT: do delays from lots of DEBUG_KERNEL checks
* make trouble here, keeping VBUS < 4.4V ?
*/
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
/* recovery is dicey once we've gotten past the
* initial stages of enumeration, but if VBUS
@@ -605,7 +605,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

dev_printk(ignore ? KERN_DEBUG : KERN_ERR, musb->controller,
"VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
devctl,
({ char *s;
switch (devctl & MUSB_DEVCTL_VBUS) {
@@ -630,10 +630,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,

if (int_usb & MUSB_INTR_SUSPEND) {
dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
handled = IRQ_HANDLED;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
/* We also come here if the cable is removed, since
* this silicon doesn't report ID-no-longer-grounded.
@@ -657,7 +657,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb_g_suspend(musb);
musb->is_active = musb->g.b_hnp_enable;
if (musb->is_active) {
- musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(
@@ -670,7 +670,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
+ msecs_to_jiffies(musb->a_wait_bcon));
break;
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = musb->hcd->self.b_hnp_enable;
break;
case OTG_STATE_B_HOST:
@@ -713,7 +713,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb->port1_status |= USB_PORT_STAT_LOW_SPEED;

/* indicate new connection to OTG machine */
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL:
if (int_usb & MUSB_INTR_SUSPEND) {
dev_dbg(musb->controller, "HNP: SUSPEND+CONNECT, now b_host\n");
@@ -725,7 +725,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: CONNECT, now b_host\n");
b_host:
- musb->xceiv->state = OTG_STATE_B_HOST;
+ musb->xceiv->otg->state = OTG_STATE_B_HOST;
if (musb->hcd)
musb->hcd->self.is_b_host = 1;
del_timer(&musb->otg_timer);
@@ -733,7 +733,7 @@ b_host:
default:
if ((devctl & MUSB_DEVCTL_VBUS)
== (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
if (hcd)
hcd->self.is_b_host = 0;
}
@@ -743,16 +743,16 @@ b_host:
musb_host_poke_root_hub(musb);

dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
}

if (int_usb & MUSB_INTR_DISCONNECT) {
dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
MUSB_MODE(musb), devctl);
handled = IRQ_HANDLED;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
musb_host_resume_root_hub(musb);
@@ -770,7 +770,7 @@ b_host:
musb_root_disconnect(musb);
if (musb->hcd)
musb->hcd->self.is_b_host = 0;
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
musb_g_disconnect(musb);
break;
@@ -786,7 +786,7 @@ b_host:
break;
default:
WARNING("unhandled DISCONNECT transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
}
@@ -812,15 +812,15 @@ b_host:
}
} else {
dev_dbg(musb->controller, "BUS RESET as %s\n",
- usb_otg_state_string(musb->xceiv->state));
- switch (musb->xceiv->state) {
+ usb_otg_state_string(musb->xceiv->otg->state));
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
musb_g_reset(musb);
/* FALLTHROUGH */
case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
/* never use invalid T(a_wait_bcon) */
dev_dbg(musb->controller, "HNP: in %s, %d msec timeout\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
TA_WAIT_BCON(musb));
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(TA_WAIT_BCON(musb)));
@@ -831,19 +831,19 @@ b_host:
break;
case OTG_STATE_B_WAIT_ACON:
dev_dbg(musb->controller, "HNP: RESET (%s), to b_peripheral\n",
- usb_otg_state_string(musb->xceiv->state));
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ usb_otg_state_string(musb->xceiv->otg->state));
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb_g_reset(musb);
break;
case OTG_STATE_B_IDLE:
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
/* FALLTHROUGH */
case OTG_STATE_B_PERIPHERAL:
musb_g_reset(musb);
break;
default:
dev_dbg(musb->controller, "Unhandled BUS RESET as %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -1630,7 +1630,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
int ret = -EINVAL;

spin_lock_irqsave(&musb->lock, flags);
- ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->state));
+ ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->otg->state));
spin_unlock_irqrestore(&musb->lock, flags);

return ret;
@@ -1675,7 +1675,7 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
spin_lock_irqsave(&musb->lock, flags);
/* force T(a_wait_bcon) to be zero/unlimited *OR* valid */
musb->a_wait_bcon = val ? max_t(int, val, OTG_TIME_A_WAIT_BCON) : 0 ;
- if (musb->xceiv->state == OTG_STATE_A_WAIT_BCON)
+ if (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)
musb->is_active = 0;
musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(val));
spin_unlock_irqrestore(&musb->lock, flags);
@@ -1743,8 +1743,8 @@ static void musb_irq_work(struct work_struct *data)
{
struct musb *musb = container_of(data, struct musb, irq_work);

- if (musb->xceiv->state != musb->xceiv_old_state) {
- musb->xceiv_old_state = musb->xceiv->state;
+ if (musb->xceiv->otg->state != musb->xceiv_old_state) {
+ musb->xceiv_old_state = musb->xceiv->otg->state;
sysfs_notify(&musb->controller->kobj, NULL, "mode");
}
}
@@ -1983,10 +1983,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)

if (musb->xceiv->otg->default_a) {
MUSB_HST_MODE(musb);
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
} else {
MUSB_DEV_MODE(musb);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}

switch (musb->port_mode) {
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 759ef1d..440333f 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -179,9 +179,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 &&
- musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&glue->timer);
glue->last_timer = jiffies;
return;
@@ -201,7 +201,7 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
glue->last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies));
mod_timer(&glue->timer, timeout);
}
@@ -265,10 +265,10 @@ static void otg_timer(unsigned long _musb)
*/
devctl = dsps_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));

spin_lock_irqsave(&musb->lock, flags);
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
skip_session = 1;
@@ -277,10 +277,10 @@ static void otg_timer(unsigned long _musb)
case OTG_STATE_A_IDLE:
case OTG_STATE_B_IDLE:
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
@@ -288,7 +288,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
dsps_writel(musb->ctrl_base, wrp->coreintr_set,
MUSB_INTR_VBUSERROR << wrp->usb_shift);
break;
@@ -373,26 +373,26 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
* devctl.
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&glue->timer,
jiffies + wrp->poll_seconds * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
del_timer(&glue->timer);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
}

/* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "",
devctl);
ret = IRQ_HANDLED;
@@ -402,7 +402,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
ret |= musb_interrupt(musb);

/* Poll for ID change in OTG port mode */
- if (musb->xceiv->state == OTG_STATE_B_IDLE &&
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
out:
@@ -900,7 +900,7 @@ static int dsps_resume(struct device *dev)
dsps_writel(mbase, wrp->mode, glue->context.mode);
dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
- if (musb->xceiv->state == OTG_STATE_B_IDLE &&
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 4ab1896..56c31b7 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1546,7 +1546,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL:
/* NOTE: OTG state machine doesn't include B_SUSPENDED;
* that's part of the standard usb 1.1 state machine, and
@@ -1587,7 +1587,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
goto done;
default:
dev_dbg(musb->controller, "Unhandled wake: %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
goto done;
}

@@ -1791,7 +1791,7 @@ int musb_gadget_setup(struct musb *musb)

MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;

/* this "gadget" abstracts/virtualizes the controller */
musb->g.name = musb_driver_name;
@@ -1857,7 +1857,7 @@ static int musb_gadget_start(struct usb_gadget *g,
musb->is_active = 1;

otg_set_peripheral(otg, &musb->g);
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
spin_unlock_irqrestore(&musb->lock, flags);

musb_start(musb);
@@ -1941,7 +1941,7 @@ static int musb_gadget_stop(struct usb_gadget *g)

(void) musb_gadget_vbus_draw(&musb->g, 0);

- musb->xceiv->state = OTG_STATE_UNDEFINED;
+ musb->xceiv->otg->state = OTG_STATE_UNDEFINED;
stop_activity(musb, NULL);
otg_set_peripheral(musb->xceiv->otg, NULL);

@@ -1968,7 +1968,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
void musb_g_resume(struct musb *musb)
{
musb->is_suspended = 0;
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE:
break;
case OTG_STATE_B_WAIT_ACON:
@@ -1982,7 +1982,7 @@ void musb_g_resume(struct musb *musb)
break;
default:
WARNING("unhandled RESUME transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

@@ -1994,10 +1994,10 @@ void musb_g_suspend(struct musb *musb)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "devctl %02x\n", devctl);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE:
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
musb->is_suspended = 1;
@@ -2012,7 +2012,7 @@ void musb_g_suspend(struct musb *musb)
* A_PERIPHERAL may need care too
*/
WARNING("unhandled SUSPEND transition (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

@@ -2043,22 +2043,22 @@ void musb_g_disconnect(struct musb *musb)
spin_lock(&musb->lock);
}

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
default:
dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n",
- usb_otg_state_string(musb->xceiv->state));
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ usb_otg_state_string(musb->xceiv->otg->state));
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
break;
case OTG_STATE_A_PERIPHERAL:
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
MUSB_HST_MODE(musb);
break;
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_HOST:
case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_IDLE:
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_B_SRP_INIT:
break;
@@ -2118,13 +2118,13 @@ __acquires(musb->lock)
* In that case, do not rely on devctl for setting
* peripheral mode.
*/
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0;
} else {
- musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
}

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 855793d..23d474d 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2463,7 +2463,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
if (!is_host_active(musb))
return 0;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
return 0;
case OTG_STATE_A_WAIT_VRISE:
@@ -2473,7 +2473,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
*/
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
break;
default:
break;
@@ -2481,7 +2481,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)

if (musb->is_active) {
WARNING("trying to suspend as %s while active\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
return -EBUSY;
} else
return 0;
@@ -2678,7 +2678,7 @@ int musb_host_setup(struct musb *musb, int power_budget)

MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;

otg_set_host(musb->xceiv->otg, &hcd->self);
hcd->self.otg_port = 1;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index e2d2d8c..a133bd8 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -69,7 +69,7 @@ void musb_host_finish_resume(struct work_struct *work)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;

spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -107,9 +107,9 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);

musb->port1_status |= USB_PORT_STAT_SUSPEND;
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_SUSPEND;
+ musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = otg->host->b_hnp_enable;
if (musb->is_active)
mod_timer(&musb->otg_timer, jiffies
@@ -118,13 +118,13 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
musb_platform_try_idle(musb, 0);
break;
case OTG_STATE_B_HOST:
- musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+ musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
musb->is_active = otg->host->b_hnp_enable;
musb_platform_try_idle(musb, 0);
break;
default:
dev_dbg(musb->controller, "bogus rh suspend? %s\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else if (power & MUSB_POWER_SUSPENDM) {
power &= ~MUSB_POWER_SUSPENDM;
@@ -145,7 +145,7 @@ void musb_port_reset(struct musb *musb, bool do_reset)
u8 power;
void __iomem *mbase = musb->mregs;

- if (musb->xceiv->state == OTG_STATE_B_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) {
dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n");
musb->port1_status &= ~USB_PORT_STAT_RESET;
return;
@@ -224,24 +224,24 @@ void musb_root_disconnect(struct musb *musb)
usb_hcd_poll_rh_status(musb->hcd);
musb->is_active = 0;

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
if (otg->host->b_hnp_enable) {
- musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
+ musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1;
break;
}
/* FALLTHROUGH */
case OTG_STATE_A_HOST:
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "host disconnect (%s)\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 20fc2a5..763649e 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:

devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) {
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
} else {
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
}
break;
@@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
- musb->xceiv->state = OTG_STATE_A_HOST;
+ musb->xceiv->otg->state = OTG_STATE_A_HOST;
}
break;
case OTG_STATE_A_HOST:
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE)
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
else
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
default:
break;
}
@@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer);
last_timer = jiffies;
return;
@@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout);
}
@@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);

if (is_on) {
- if (musb->xceiv->state == OTG_STATE_A_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
int loops = 100;
/* start the session */
devctl |= MUSB_DEVCTL_SESSION;
@@ -180,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 1;
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
}
@@ -192,7 +192,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
*/

otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
devctl &= ~MUSB_DEVCTL_SESSION;

MUSB_DEV_MODE(musb);
@@ -201,7 +201,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)

dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

@@ -266,7 +266,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "ID GND\n");

otg->default_a = true;
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
musb->xceiv->last_event = USB_EVENT_ID;
if (musb->gadget_driver) {
pm_runtime_get_sync(dev);
@@ -280,7 +280,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "VBUS Connect\n");

otg->default_a = false;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->xceiv->last_event = USB_EVENT_VBUS;
if (musb->gadget_driver)
pm_runtime_get_sync(dev);
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 25f02df..69ca92d6 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -415,13 +415,13 @@ static void musb_do_idle(unsigned long _musb)

spin_lock_irqsave(&musb->lock, flags);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON:
if ((musb->a_wait_bcon != 0)
&& (musb->idle_timeout == 0
|| time_after(jiffies, musb->idle_timeout))) {
dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
/* FALLTHROUGH */
case OTG_STATE_A_IDLE:
@@ -474,9 +474,9 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)

/* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0)
- && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) {
+ && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
- usb_otg_state_string(musb->xceiv->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer);
last_timer = jiffies;
return;
@@ -493,7 +493,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout;

dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout);
}
@@ -524,7 +524,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
if (is_on) {
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;

conf |= TUSB_DEV_CONF_USB_HOST_MODE;
@@ -537,16 +537,16 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
/* If ID pin is grounded, we want to be a_idle */
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE:
case OTG_STATE_A_WAIT_BCON:
- musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
case OTG_STATE_A_WAIT_VFALL:
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break;
default:
- musb->xceiv->state = OTG_STATE_A_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_A_IDLE;
}
musb->is_active = 0;
otg->default_a = 1;
@@ -554,7 +554,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 0;
otg->default_a = 0;
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb);
}

@@ -569,7 +569,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);

dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL),
musb_readl(tbase, TUSB_DEV_OTG_STAT),
conf, prcm);
@@ -668,23 +668,23 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)

if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n");
- if (musb->xceiv->state != OTG_STATE_B_IDLE) {
+ if (musb->xceiv->otg->state != OTG_STATE_B_IDLE) {
/* INTR_DISCONNECT can hide... */
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->int_usb |= MUSB_INTR_DISCONNECT;
}
musb->is_active = 0;
}
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
idle_timeout = jiffies + (1 * HZ);
schedule_work(&musb->irq_work);

} else /* A-dev state machine */ {
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE:
dev_dbg(musb->controller, "Got SRP, turning on VBUS\n");
musb_platform_set_vbus(musb, 1);
@@ -731,9 +731,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
u8 devctl;

dev_dbg(musb->controller, "%s timer, %03x\n",
- usb_otg_state_string(musb->xceiv->state), otg_stat);
+ usb_otg_state_string(musb->xceiv->otg->state), otg_stat);

- switch (musb->xceiv->state) {
+ switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE:
/* VBUS has probably been valid for a while now,
* but may well have bounced out of range a bit
@@ -745,7 +745,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
dev_dbg(musb->controller, "devctl %02x\n", devctl);
break;
}
- musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0;
idle_timeout = jiffies
+ msecs_to_jiffies(musb->a_wait_bcon);
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index d0180a7..1d631d5 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -56,7 +56,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);

if (is_on) {
- if (musb->xceiv->state == OTG_STATE_A_IDLE) {
+ if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
/* start the session */
devctl |= MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
@@ -76,7 +76,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
} else {
musb->is_active = 1;
musb->xceiv->otg->default_a = 1;
- musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb);
}
@@ -102,7 +102,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
mdelay(200);

dev_dbg(musb->controller, "VBUS %s, devctl %02x\n",
- usb_otg_state_string(musb->xceiv->state),
+ usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL));
}

@@ -112,7 +112,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
struct musb *musb = container_of(nb, struct musb, nb);

dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n",
- event, usb_otg_state_string(musb->xceiv->state));
+ event, usb_otg_state_string(musb->xceiv->otg->state));

switch (event) {
case UX500_MUSB_ID:
@@ -127,7 +127,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
if (is_host_active(musb))
ux500_musb_set_vbus(musb, 0);
else
- musb->xceiv->state = OTG_STATE_B_IDLE;
+ musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "ID float\n");
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 11ab2c4..2d52501 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected. */
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_9540:
@@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing
* is connected
*/
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8540:
@@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing
* is connected
*/
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8505:
@@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected */
- ab->phy.state = OTG_STATE_B_IDLE;
+ ab->phy.otg->state = OTG_STATE_B_IDLE;
break;

case USB_LINK_ACA_RID_C_NM_8500:
@@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
ab->phy.label = "ab8500";
ab->phy.set_suspend = ab8500_usb_set_suspend;
ab->phy.set_power = ab8500_usb_set_power;
- ab->phy.state = OTG_STATE_UNDEFINED;
+ ab->phy.otg->state = OTG_STATE_UNDEFINED;

otg->phy = &ab->phy;
otg->set_host = ab8500_usb_set_host;
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index f1ea599..15d7a81 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
/* Mini-A cable connected */
struct otg_fsm *fsm = &otg_dev->fsm;

- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg.state = OTG_STATE_UNDEFINED;
fsm->protocol = PROTO_UNDEF;
}
}
@@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
{
if (!fsl_otg_dev)
return -ENODEV;
- if (phy->state == OTG_STATE_B_PERIPHERAL)
+ if (phy->otg.state == OTG_STATE_B_PERIPHERAL)
pr_info("FSL OTG: Draw %d mA\n", mA);

return 0;
@@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
{
struct fsl_otg *otg_dev;

- if (!otg || otg->phy->state != OTG_STATE_B_IDLE)
+ if (!otg || otg.state != OTG_STATE_B_IDLE)
return -ENODEV;

otg_dev = container_of(otg->phy, struct fsl_otg, phy);
@@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev)
* Also: record initial state of ID pin
*/
if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
- p_otg->phy.state = OTG_STATE_UNDEFINED;
+ p_otg->phy->otg.state = OTG_STATE_UNDEFINED;
p_otg->fsm.id = 1;
} else {
- p_otg->phy.state = OTG_STATE_A_IDLE;
+ p_otg->phy->otg.state = OTG_STATE_A_IDLE;
p_otg->fsm.id = 0;
}

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 7594e50..280a345 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
}

otg->gadget = gadget;
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
return 0;
}

@@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv";
nop->phy.set_suspend = nop_set_suspend;
- nop->phy.state = OTG_STATE_UNDEFINED;
nop->phy.type = type;

+ nop->phy.otg->state = OTG_STATE_UNDEFINED;
nop->phy.otg->phy = &nop->phy;
nop->phy.otg->set_host = nop_set_host;
nop->phy.otg->set_peripheral = nop_set_peripheral;
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index f4b14bd..7a6be3e 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work)

if (vbus) {
status = USB_EVENT_VBUS;
- gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
+ gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL;
gpio_vbus->phy.last_event = status;
usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);

@@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work)

usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
status = USB_EVENT_NONE;
- gpio_vbus->phy.state = OTG_STATE_B_IDLE;
+ gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE;
gpio_vbus->phy.last_event = status;

atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
@@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
set_vbus_draw(gpio_vbus, 0);

usb_gadget_vbus_disconnect(otg->gadget);
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;

otg->gadget = NULL;
return 0;
@@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)

gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);

- if (phy->state == OTG_STATE_B_PERIPHERAL)
+ if (phy->otg->state == OTG_STATE_B_PERIPHERAL)
set_vbus_draw(gpio_vbus, mA);
return 0;
}
@@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
gpio_vbus->phy.dev = gpio_vbus->dev;
gpio_vbus->phy.set_power = gpio_vbus_set_power;
gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
- gpio_vbus->phy.state = OTG_STATE_UNDEFINED;

+ gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;

diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c
index 8eea56d..24f84cb 100644
--- a/drivers/usb/phy/phy-isp1301-omap.c
+++ b/drivers/usb/phy/phy-isp1301-omap.c
@@ -234,7 +234,7 @@ isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits)

static inline const char *state_name(struct isp1301 *isp)
{
- return usb_otg_state_string(isp->phy.state);
+ return usb_otg_state_string(isp->phy.otg->state);
}

/*-------------------------------------------------------------------------*/
@@ -249,7 +249,7 @@ static inline const char *state_name(struct isp1301 *isp)

static void power_down(struct isp1301 *isp)
{
- isp->phy.state = OTG_STATE_UNDEFINED;
+ isp->phy.otg->state = OTG_STATE_UNDEFINED;

// isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN);
isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND);
@@ -339,7 +339,7 @@ static void a_idle(struct isp1301 *isp, const char *tag)
{
u32 l;

- if (isp->phy.state == OTG_STATE_A_IDLE)
+ if (isp->phy.otg->state == OTG_STATE_A_IDLE)
return;

isp->phy.otg->default_a = 1;
@@ -351,7 +351,7 @@ static void a_idle(struct isp1301 *isp, const char *tag)
isp->phy.otg->gadget->is_a_peripheral = 1;
gadget_suspend(isp);
}
- isp->phy.state = OTG_STATE_A_IDLE;
+ isp->phy.otg->state = OTG_STATE_A_IDLE;
l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS;
omap_writel(l, OTG_CTRL);
isp->last_otg_ctrl = l;
@@ -363,7 +363,7 @@ static void b_idle(struct isp1301 *isp, const char *tag)
{
u32 l;

- if (isp->phy.state == OTG_STATE_B_IDLE)
+ if (isp->phy.otg->state == OTG_STATE_B_IDLE)
return;

isp->phy.otg->default_a = 0;
@@ -375,7 +375,7 @@ static void b_idle(struct isp1301 *isp, const char *tag)
isp->phy.otg->gadget->is_a_peripheral = 0;
gadget_suspend(isp);
}
- isp->phy.state = OTG_STATE_B_IDLE;
+ isp->phy.otg->state = OTG_STATE_B_IDLE;
l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS;
omap_writel(l, OTG_CTRL);
isp->last_otg_ctrl = l;
@@ -474,7 +474,7 @@ static void check_state(struct isp1301 *isp, const char *tag)
default:
break;
}
- if (isp->phy.state == state && !extra)
+ if (isp->phy.otg->state == state && !extra)
return;
pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag,
usb_otg_state_string(state), fsm, state_name(isp),
@@ -498,23 +498,23 @@ static void update_otg1(struct isp1301 *isp, u8 int_src)

if (int_src & INTR_SESS_VLD)
otg_ctrl |= OTG_ASESSVLD;
- else if (isp->phy.state == OTG_STATE_A_WAIT_VFALL) {
+ else if (isp->phy.otg->state == OTG_STATE_A_WAIT_VFALL) {
a_idle(isp, "vfall");
otg_ctrl &= ~OTG_CTRL_BITS;
}
if (int_src & INTR_VBUS_VLD)
otg_ctrl |= OTG_VBUSVLD;
if (int_src & INTR_ID_GND) { /* default-A */
- if (isp->phy.state == OTG_STATE_B_IDLE
- || isp->phy.state
+ if (isp->phy.otg->state == OTG_STATE_B_IDLE
+ || isp->phy.otg->state
== OTG_STATE_UNDEFINED) {
a_idle(isp, "init");
return;
}
} else { /* default-B */
otg_ctrl |= OTG_ID;
- if (isp->phy.state == OTG_STATE_A_IDLE
- || isp->phy.state == OTG_STATE_UNDEFINED) {
+ if (isp->phy.otg->state == OTG_STATE_A_IDLE
+ || isp->phy.otg->state == OTG_STATE_UNDEFINED) {
b_idle(isp, "init");
return;
}
@@ -548,14 +548,14 @@ static void otg_update_isp(struct isp1301 *isp)
isp->last_otg_ctrl = otg_ctrl;
otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS;

- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_SRP_INIT:
if (!(otg_ctrl & OTG_PULLUP)) {
// if (otg_ctrl & OTG_B_HNPEN) {
if (isp->phy.otg->gadget->b_hnp_enable) {
- isp->phy.state = OTG_STATE_B_WAIT_ACON;
+ isp->phy.otg->state = OTG_STATE_B_WAIT_ACON;
pr_debug(" --> b_wait_acon\n");
}
goto pulldown;
@@ -585,7 +585,7 @@ pulldown:
if (!(isp->phy.otg->host))
otg_ctrl &= ~OTG_DRV_VBUS;

- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_A_SUSPEND:
if (otg_ctrl & OTG_DRV_VBUS) {
set |= OTG1_VBUS_DRV;
@@ -596,7 +596,7 @@ pulldown:

/* FALLTHROUGH */
case OTG_STATE_A_VBUS_ERR:
- isp->phy.state = OTG_STATE_A_WAIT_VFALL;
+ isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
pr_debug(" --> a_wait_vfall\n");
/* FALLTHROUGH */
case OTG_STATE_A_WAIT_VFALL:
@@ -605,7 +605,7 @@ pulldown:
break;
case OTG_STATE_A_IDLE:
if (otg_ctrl & OTG_DRV_VBUS) {
- isp->phy.state = OTG_STATE_A_WAIT_VRISE;
+ isp->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
pr_debug(" --> a_wait_vrise\n");
}
/* FALLTHROUGH */
@@ -625,17 +625,17 @@ pulldown:
if (otg_change & OTG_PULLUP) {
u32 l;

- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_B_IDLE:
if (clr & OTG1_DP_PULLUP)
break;
- isp->phy.state = OTG_STATE_B_PERIPHERAL;
+ isp->phy.otg->state = OTG_STATE_B_PERIPHERAL;
pr_debug(" --> b_peripheral\n");
break;
case OTG_STATE_A_SUSPEND:
if (clr & OTG1_DP_PULLUP)
break;
- isp->phy.state = OTG_STATE_A_PERIPHERAL;
+ isp->phy.otg->state = OTG_STATE_A_PERIPHERAL;
pr_debug(" --> a_peripheral\n");
break;
default:
@@ -673,7 +673,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
* remote wakeup (SRP, normal) using their own timer
* to give "check cable and A-device" messages.
*/
- if (isp->phy.state == OTG_STATE_B_SRP_INIT)
+ if (isp->phy.otg->state == OTG_STATE_B_SRP_INIT)
b_idle(isp, "srp_timeout");

omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC);
@@ -691,7 +691,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
omap_writel(otg_ctrl, OTG_CTRL);

/* subset of b_peripheral()... */
- isp->phy.state = OTG_STATE_B_PERIPHERAL;
+ isp->phy.otg->state = OTG_STATE_B_PERIPHERAL;
pr_debug(" --> b_peripheral\n");

omap_writew(B_HNP_FAIL, OTG_IRQ_SRC);
@@ -703,7 +703,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
state_name(isp), omap_readl(OTG_CTRL));

isp1301_defer_work(isp, WORK_UPDATE_OTG);
- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_A_IDLE:
if (!otg->host)
break;
@@ -734,7 +734,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
otg_ctrl |= OTG_BUSDROP;
otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS;
omap_writel(otg_ctrl, OTG_CTRL);
- isp->phy.state = OTG_STATE_A_WAIT_VFALL;
+ isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL;

omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC);
ret = IRQ_HANDLED;
@@ -748,7 +748,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
otg_ctrl |= OTG_BUSDROP;
otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS;
omap_writel(otg_ctrl, OTG_CTRL);
- isp->phy.state = OTG_STATE_A_VBUS_ERR;
+ isp->phy.otg->state = OTG_STATE_A_VBUS_ERR;

omap_writew(A_VBUS_ERR, OTG_IRQ_SRC);
ret = IRQ_HANDLED;
@@ -769,7 +769,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)

/* role is peripheral */
if (otg_ctrl & OTG_DRIVER_SEL) {
- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_A_IDLE:
b_idle(isp, __func__);
break;
@@ -786,18 +786,18 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
}

if (otg->host) {
- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_B_WAIT_ACON:
- isp->phy.state = OTG_STATE_B_HOST;
+ isp->phy.otg->state = OTG_STATE_B_HOST;
pr_debug(" --> b_host\n");
kick = 1;
break;
case OTG_STATE_A_WAIT_BCON:
- isp->phy.state = OTG_STATE_A_HOST;
+ isp->phy.otg->state = OTG_STATE_A_HOST;
pr_debug(" --> a_host\n");
break;
case OTG_STATE_A_PERIPHERAL:
- isp->phy.state = OTG_STATE_A_WAIT_BCON;
+ isp->phy.otg->state = OTG_STATE_A_WAIT_BCON;
pr_debug(" --> a_wait_bcon\n");
break;
default:
@@ -937,7 +937,7 @@ static void b_peripheral(struct isp1301 *isp)
/* UDC driver just set OTG_BSESSVLD */
isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP);
isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN);
- isp->phy.state = OTG_STATE_B_PERIPHERAL;
+ isp->phy.otg->state = OTG_STATE_B_PERIPHERAL;
pr_debug(" --> b_peripheral\n");
dump_regs(isp, "2periph");
#endif
@@ -947,7 +947,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
{
struct usb_otg *otg = isp->phy.otg;
u8 isp_stat, isp_bstat;
- enum usb_otg_state state = isp->phy.state;
+ enum usb_otg_state state = isp->phy.otg->state;

if (stat & INTR_BDIS_ACON)
pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp));
@@ -970,7 +970,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
* when HNP is used.
*/
if (isp_stat & INTR_VBUS_VLD)
- isp->phy.state = OTG_STATE_A_HOST;
+ isp->phy.otg->state = OTG_STATE_A_HOST;
break;
case OTG_STATE_A_WAIT_VFALL:
if (!(isp_stat & INTR_SESS_VLD))
@@ -978,7 +978,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
break;
default:
if (!(isp_stat & INTR_VBUS_VLD))
- isp->phy.state = OTG_STATE_A_VBUS_ERR;
+ isp->phy.otg->state = OTG_STATE_A_VBUS_ERR;
break;
}
isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS);
@@ -1007,7 +1007,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
if (otg->default_a) {
switch (state) {
default:
- isp->phy.state = OTG_STATE_A_WAIT_VFALL;
+ isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
break;
case OTG_STATE_A_WAIT_VFALL:
state = OTG_STATE_A_IDLE;
@@ -1020,7 +1020,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
host_suspend(isp);
isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1,
MC1_BDIS_ACON_EN);
- isp->phy.state = OTG_STATE_B_IDLE;
+ isp->phy.otg->state = OTG_STATE_B_IDLE;
l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK;
l &= ~OTG_CTRL_BITS;
omap_writel(l, OTG_CTRL);
@@ -1031,7 +1031,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
}
isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS);

- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_HOST:
@@ -1071,7 +1071,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
}
}

- if (state != isp->phy.state)
+ if (state != isp->phy.otg->state)
pr_debug(" isp, %s -> %s\n",
usb_otg_state_string(state), state_name(isp));

@@ -1129,10 +1129,10 @@ isp1301_work(struct work_struct *work)
* skip A_WAIT_VRISE; hc transitions invisibly
* skip A_WAIT_BCON; same.
*/
- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_A_WAIT_BCON:
case OTG_STATE_A_WAIT_VRISE:
- isp->phy.state = OTG_STATE_A_HOST;
+ isp->phy.otg->state = OTG_STATE_A_HOST;
pr_debug(" --> a_host\n");
otg_ctrl = omap_readl(OTG_CTRL);
otg_ctrl |= OTG_A_BUSREQ;
@@ -1141,7 +1141,7 @@ isp1301_work(struct work_struct *work)
omap_writel(otg_ctrl, OTG_CTRL);
break;
case OTG_STATE_B_WAIT_ACON:
- isp->phy.state = OTG_STATE_B_HOST;
+ isp->phy.otg->state = OTG_STATE_B_HOST;
pr_debug(" --> b_host (acon)\n");
break;
case OTG_STATE_B_HOST:
@@ -1368,7 +1368,7 @@ isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
}

power_up(isp);
- isp->phy.state = OTG_STATE_B_IDLE;
+ isp->phy.otg->state = OTG_STATE_B_IDLE;

if (machine_is_omap_h2() || machine_is_omap_h3())
isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0);
@@ -1403,7 +1403,7 @@ isp1301_set_power(struct usb_phy *dev, unsigned mA)
{
if (!the_transceiver)
return -ENODEV;
- if (dev->state == OTG_STATE_B_PERIPHERAL)
+ if (dev->otg->state == OTG_STATE_B_PERIPHERAL)
enable_vbus_draw(the_transceiver, mA);
return 0;
}
@@ -1414,7 +1414,7 @@ isp1301_start_srp(struct usb_otg *otg)
struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
u32 otg_ctrl;

- if (isp != the_transceiver || isp->phy.state != OTG_STATE_B_IDLE)
+ if (isp != the_transceiver || isp->phy.otg->state != OTG_STATE_B_IDLE)
return -ENODEV;

otg_ctrl = omap_readl(OTG_CTRL);
@@ -1424,7 +1424,7 @@ isp1301_start_srp(struct usb_otg *otg)
otg_ctrl |= OTG_B_BUSREQ;
otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK;
omap_writel(otg_ctrl, OTG_CTRL);
- isp->phy.state = OTG_STATE_B_SRP_INIT;
+ isp->phy.otg->state = OTG_STATE_B_SRP_INIT;

pr_debug("otg: SRP, %s ... %06x\n", state_name(isp),
omap_readl(OTG_CTRL));
@@ -1452,9 +1452,9 @@ isp1301_start_hnp(struct usb_otg *otg)
/* We want hardware to manage most HNP protocol timings.
* So do this part as early as possible...
*/
- switch (isp->phy.state) {
+ switch (isp->phy.otg->state) {
case OTG_STATE_B_HOST:
- isp->phy.state = OTG_STATE_B_PERIPHERAL;
+ isp->phy.otg->state = OTG_STATE_B_PERIPHERAL;
/* caller will suspend next */
break;
case OTG_STATE_A_HOST:
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 471e69d..18015b7 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
}

if (!host) {
- if (otg->phy->state == OTG_STATE_A_HOST) {
+ if (otg->state == OTG_STATE_A_HOST) {
pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_host(otg->phy, 0);
otg->host = NULL;
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
} else {
otg->host = NULL;
@@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
}

if (!gadget) {
- if (otg->phy->state == OTG_STATE_B_PERIPHERAL) {
+ if (otg->state == OTG_STATE_B_PERIPHERAL) {
pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_peripheral(otg->phy, 0);
otg->gadget = NULL;
- otg->phy->state = OTG_STATE_UNDEFINED;
+ otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work);
} else {
otg->gadget = NULL;
@@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w)
struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
struct usb_otg *otg = motg->phy.otg;

- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_UNDEFINED:
dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
msm_otg_reset(otg->phy);
msm_otg_init_sm(motg);
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
@@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w)
/* disable BSV bit */
writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
msm_otg_start_host(otg->phy, 1);
- otg->phy->state = OTG_STATE_A_HOST;
+ otg->state = OTG_STATE_A_HOST;
} else if (test_bit(B_SESS_VLD, &motg->inputs)) {
switch (motg->chg_state) {
case USB_CHG_STATE_UNDEFINED:
@@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_notify_charger(motg,
IDEV_CHG_MAX);
msm_otg_start_peripheral(otg->phy, 1);
- otg->phy->state
+ otg->state
= OTG_STATE_B_PERIPHERAL;
break;
case USB_SDP_CHARGER:
msm_otg_notify_charger(motg, IUNIT);
msm_otg_start_peripheral(otg->phy, 1);
- otg->phy->state
+ otg->state
= OTG_STATE_B_PERIPHERAL;
break;
default:
@@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w)
motg->chg_type = USB_INVALID_CHARGER;
}

- if (otg->phy->state == OTG_STATE_B_IDLE)
+ if (otg->state == OTG_STATE_B_IDLE)
pm_runtime_put_sync(otg->phy->dev);
break;
case OTG_STATE_B_PERIPHERAL:
@@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_start_peripheral(otg->phy, 0);
motg->chg_state = USB_CHG_STATE_UNDEFINED;
motg->chg_type = USB_INVALID_CHARGER;
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy);
schedule_work(w);
}
@@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w)
dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
if (test_bit(ID, &motg->inputs)) {
msm_otg_start_host(otg->phy, 0);
- otg->phy->state = OTG_STATE_B_IDLE;
+ otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy);
schedule_work(w);
}
@@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
struct msm_otg *motg = s->private;
struct usb_otg *otg = motg->phy.otg;

- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_A_HOST:
seq_puts(s, "host\n");
break;
@@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,

switch (req_mode) {
case USB_DR_MODE_UNKNOWN:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_B_PERIPHERAL:
set_bit(ID, &motg->inputs);
@@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
}
break;
case USB_DR_MODE_PERIPHERAL:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_A_HOST:
set_bit(ID, &motg->inputs);
@@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
}
break;
case USB_DR_MODE_HOST:
- switch (otg->phy->state) {
+ switch (otg->state) {
case OTG_STATE_B_IDLE:
case OTG_STATE_B_PERIPHERAL:
clear_bit(ID, &motg->inputs);
@@ -1769,7 +1769,7 @@ static int msm_otg_runtime_idle(struct device *dev)
* This 1 sec delay also prevents entering into LPM immediately
* after asynchronous interrupt.
*/
- if (otg->phy->state != OTG_STATE_UNDEFINED)
+ if (otg->state != OTG_STATE_UNDEFINED)
pm_schedule_suspend(dev, 1000);

return -EAGAIN;
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index c9517d8..ee87aa7 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
{
struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
struct usb_phy *phy = &mvotg->phy;
- int old_state = phy->state;
+ int old_state = mvotg->phy.otg->state;

switch (old_state) {
case OTG_STATE_UNDEFINED:
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */
case OTG_STATE_B_IDLE:
if (otg_ctrl->id == 0)
- phy->state = OTG_STATE_A_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_A_IDLE;
else if (otg_ctrl->b_sess_vld)
- phy->state = OTG_STATE_B_PERIPHERAL;
+ mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_B_PERIPHERAL:
if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_A_IDLE:
if (otg_ctrl->id)
- phy->state = OTG_STATE_B_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_B_IDLE;
else if (!(otg_ctrl->a_bus_drop) &&
(otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
- phy->state = OTG_STATE_A_WAIT_VRISE;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
break;
case OTG_STATE_A_WAIT_VRISE:
if (otg_ctrl->a_vbus_vld)
- phy->state = OTG_STATE_A_WAIT_BCON;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
break;
case OTG_STATE_A_WAIT_BCON:
if (otg_ctrl->id || otg_ctrl->a_bus_drop
|| otg_ctrl->a_wait_bcon_timeout) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_WAIT_VFALL;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
otg_ctrl->a_bus_req = 0;
} else if (!otg_ctrl->a_vbus_vld) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_VBUS_ERR;
+ mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
} else if (otg_ctrl->b_conn) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
- phy->state = OTG_STATE_A_HOST;
+ mvotg->phy.otg->state = OTG_STATE_A_HOST;
}
break;
case OTG_STATE_A_HOST:
if (otg_ctrl->id || !otg_ctrl->b_conn
|| otg_ctrl->a_bus_drop)
- phy->state = OTG_STATE_A_WAIT_BCON;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
else if (!otg_ctrl->a_vbus_vld)
- phy->state = OTG_STATE_A_VBUS_ERR;
+ mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
break;
case OTG_STATE_A_WAIT_VFALL:
if (otg_ctrl->id
|| (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
|| otg_ctrl->a_bus_req)
- phy->state = OTG_STATE_A_IDLE;
+ mvotg->phy.otg->state = OTG_STATE_A_IDLE;
break;
case OTG_STATE_A_VBUS_ERR:
if (otg_ctrl->id || otg_ctrl->a_clr_err
|| otg_ctrl->a_bus_drop) {
otg_ctrl->a_clr_err = 0;
- phy->state = OTG_STATE_A_WAIT_VFALL;
+ mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
}
break;
default:
@@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work)
run:
/* work queue is single thread, or we need spin_lock to protect */
phy = &mvotg->phy;
- otg = phy->otg;
- old_state = phy->state;
+ otg = mvotg->phy.otg;
+ old_state = otg->state;

if (!mvotg->active)
return;
@@ -429,12 +429,12 @@ run:
mv_otg_update_inputs(mvotg);
mv_otg_update_state(mvotg);

- if (old_state != phy->state) {
+ if (old_state != mvotg->phy.otg->state) {
dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
state_string[old_state],
- state_string[phy->state]);
+ state_string[mvotg->phy.otg->state]);

- switch (phy->state) {
+ switch (mvotg->phy.otg->state) {
case OTG_STATE_B_IDLE:
otg->default_a = 0;
if (old_state == OTG_STATE_B_PERIPHERAL)
@@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
return -1;

/* We will use this interface to change to A device */
- if (mvotg->phy.state != OTG_STATE_B_IDLE
- && mvotg->phy.state != OTG_STATE_A_IDLE)
+ if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
+ && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
return -1;

/* The clock may disabled and we need to set irq for ID detected */
@@ -715,9 +715,9 @@ static int mv_otg_probe(struct platform_device *pdev)
mvotg->phy.dev = &pdev->dev;
mvotg->phy.otg = otg;
mvotg->phy.label = driver_name;
- mvotg->phy.state = OTG_STATE_UNDEFINED;

otg->phy = &mvotg->phy;
+ otg->state = OTG_STATE_UNDEFINED;
otg->set_host = mv_otg_set_host;
otg->set_peripheral = mv_otg_set_peripheral;
otg->set_vbus = mv_otg_set_vbus;
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index cc61ee4..04ece53 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -81,33 +81,33 @@ static void check_vbus_state(struct tahvo_usb *tu)

reg = retu_read(rdev, TAHVO_REG_IDSR);
if (reg & TAHVO_STAT_VBUS) {
- switch (tu->phy.state) {
+ switch (tu->phy.otg->state) {
case OTG_STATE_B_IDLE:
/* Enable the gadget driver */
if (tu->phy.otg->gadget)
usb_gadget_vbus_connect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_PERIPHERAL;
+ tu->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break;
case OTG_STATE_A_IDLE:
/*
* Session is now valid assuming the USB hub is driving
* Vbus.
*/
- tu->phy.state = OTG_STATE_A_HOST;
+ tu->phy.otg->state = OTG_STATE_A_HOST;
break;
default:
break;
}
dev_info(&tu->pt_dev->dev, "USB cable connected\n");
} else {
- switch (tu->phy.state) {
+ switch (tu->phy.otg->state) {
case OTG_STATE_B_PERIPHERAL:
if (tu->phy.otg->gadget)
usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;
break;
case OTG_STATE_A_HOST:
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;
break;
default:
break;
@@ -132,14 +132,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu)
/* Power up the transceiver in USB host mode */
retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
USBR_MASTER_SW2 | USBR_MASTER_SW1);
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;

check_vbus_state(tu);
}

static void tahvo_usb_stop_host(struct tahvo_usb *tu)
{
- tu->phy.state = OTG_STATE_A_IDLE;
+ tu->phy.otg->state = OTG_STATE_A_IDLE;
}

static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
@@ -151,7 +151,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
/* Power up transceiver and set it in USB peripheral mode */
retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT |
USBR_NSUSPEND | USBR_SLAVE_SW);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;

check_vbus_state(tu);
}
@@ -160,7 +160,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu)
{
if (tu->phy.otg->gadget)
usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
- tu->phy.state = OTG_STATE_B_IDLE;
+ tu->phy.otg->state = OTG_STATE_B_IDLE;
}

static void tahvo_usb_power_off(struct tahvo_usb *tu)
@@ -173,7 +173,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu)

/* Power off transceiver */
retu_write(rdev, TAHVO_REG_USBR, 0);
- tu->phy.state = OTG_STATE_UNDEFINED;
+ tu->phy.otg->state = OTG_STATE_UNDEFINED;
}

static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend)
@@ -379,7 +379,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
/* Create OTG interface */
tahvo_usb_power_off(tu);
tu->phy.dev = &pdev->dev;
- tu->phy.state = OTG_STATE_UNDEFINED;
+ tu->phy.otg->state = OTG_STATE_UNDEFINED;
tu->phy.label = DRIVER_NAME;
tu->phy.set_suspend = tahvo_usb_set_suspend;

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 154332b..33d3480 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -18,6 +18,8 @@ struct usb_otg {
struct usb_bus *host;
struct usb_gadget *gadget;

+ enum usb_otg_state state;
+
/* bind/unbind the host controller */
int (*set_host)(struct usb_otg *otg, struct usb_bus *host);

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 353053a..ac7d791 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -77,7 +77,6 @@ struct usb_phy {
unsigned int flags;

enum usb_phy_type type;
- enum usb_otg_state state;
enum usb_phy_events last_event;

struct usb_otg *otg;

--
balbi


Attachments:
(No filename) (88.48 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-10-31 13:55:42

by Antoine Tenart

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

Hi Felipe,

On Fri, Oct 31, 2014 at 08:47:51AM -0500, Felipe Balbi wrote:
> On Fri, Oct 31, 2014 at 08:33:19AM -0500, Felipe Balbi wrote:
> > > > > > > > > Before using the PHY framework instead of the USB PHY one, we need to
> > > > > > > > > move the OTG state into another place, since it won't be available when
> > > > > > > > > USB PHY isn't used. This patch moves the OTG state into the OTG
> > > > > > > > > structure, and makes all the needed modifications in the drivers
> > > > > > > > > using the OTG state.
> > > > > > > > >
> > > > > > > > > Signed-off-by: Antoine Tenart <[email protected]>
> > > > > > > > > Acked-by: Peter Chen <[email protected]>
> > > > > > > >
> > > > > > > > Acked-by: Felipe Balbi <[email protected]>
> > > > > > >
> > > > > > > Please rebase on my testing/next and I'll take the series. When
> > > > > > > rebasing, then add Peter's Tested-by/Acked-by where they're missing.
> > > > > >
> > > > > > I just re-sent the series, rebased on your testing/next branch.
> > > > >
> > > > > Thanks, I put them on my testing/next and I'm running build tests.
> > > > >
> > > >
> > > > I see them, I will rebase your testing/next tree for coming chipidea dev, thanks.
> > >
> > > I fixed a build breakage caused by $subject which I fixed, updated patch
> > > below: (Aaro, can I get a tested-by by any chance ?)
> >
> > two more build regressions found (did you build test your patches ??)
>
> and yet another one on phy-isp1301-omap.c. Seriously, if I find another
> build regression I'll drop your series from my queue and defer it to
> 3.20. This is ridiculous already.

Sorry for the inconvenience, the series modify quite a lot of files and
testing all of them is quite difficult. If you'd like I can fully test
it and send a new version early next week.

Deferring it to 3.20 will not solve the issue and will raise the same
errors as these build failures. The series has been sent for quite a
long time now, without having any comments on the latests revisions and
was therefore delayed. Each time it is delayed, it makes it more
difficult to ensure everything is working fine because of all the
modifications done in this subsystem... I tried to keep it up with all
the other patches introduced between my revisions, but this is not as
easy as it sounds.

Again, sorry for these failures, I can send to you a new version early
next week so that no other patches comes in between, breaking the
build...


Antoine

--
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

2014-10-31 14:12:44

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH v7 1/7] usb: move the OTG state from the USB PHY to the OTG structure

Hi,

On Fri, Oct 31, 2014 at 02:55:35PM +0100, Antoine Tenart wrote:
> > > > > > > > > > Before using the PHY framework instead of the USB
> > > > > > > > > > PHY one, we need to move the OTG state into another
> > > > > > > > > > place, since it won't be available when USB PHY
> > > > > > > > > > isn't used. This patch moves the OTG state into the
> > > > > > > > > > OTG structure, and makes all the needed
> > > > > > > > > > modifications in the drivers using the OTG state.
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Antoine Tenart <[email protected]>
> > > > > > > > > > Acked-by: Peter Chen <[email protected]>
> > > > > > > > >
> > > > > > > > > Acked-by: Felipe Balbi <[email protected]>
> > > > > > > >
> > > > > > > > Please rebase on my testing/next and I'll take the
> > > > > > > > series. When rebasing, then add Peter's
> > > > > > > > Tested-by/Acked-by where they're missing.
> > > > > > >
> > > > > > > I just re-sent the series, rebased on your testing/next
> > > > > > > branch.
> > > > > >
> > > > > > Thanks, I put them on my testing/next and I'm running build
> > > > > > tests.
> > > > > >
> > > > >
> > > > > I see them, I will rebase your testing/next tree for coming
> > > > > chipidea dev, thanks.
> > > >
> > > > I fixed a build breakage caused by $subject which I fixed,
> > > > updated patch below: (Aaro, can I get a tested-by by any chance
> > > > ?)
> > >
> > > two more build regressions found (did you build test your patches
> > > ??)
> >
> > and yet another one on phy-isp1301-omap.c. Seriously, if I find
> > another build regression I'll drop your series from my queue and
> > defer it to 3.20. This is ridiculous already.
>
> Sorry for the inconvenience, the series modify quite a lot of files
> and testing all of them is quite difficult. If you'd like I can fully
> test

how come ? build testing is difficult ? if you have x86 and ARM
compilers you can build all of these modules with make allmodconfig.

You know, I have a very a simple 20-line script running randconfigs and
saving the output, after that I just grep for "error" on the logs and
look at what's broken.

> it and send a new version early next week.
>
> Deferring it to 3.20 will not solve the issue and will raise the same
> errors as these build failures. The series has been sent for quite a
> long time now, without having any comments on the latests revisions
> and was therefore delayed. Each time it is delayed, it makes it more
> difficult to ensure everything is working fine because of all the
> modifications done in this subsystem... I tried to keep it up with all
> the other patches introduced between my revisions, but this is not as
> easy as it sounds.

all the places I fixed haven't been touched for months, in some cases
years. This is a broken argument.

> Again, sorry for these failures, I can send to you a new version early
> next week so that no other patches comes in between, breaking the
> build...

nevermind, I already fixed so many of these mistakes anyway, it's
probably all clean now.

--
balbi


Attachments:
(No filename) (3.01 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments