From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Felipe Balbi <balbi@ti.com>, Greg KH <gregkh@suse.de>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Peter Chen <peter.chen@freescale.com>,
Lin Tony-B19295 <B19295@freescale.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Subject: [PATCHv4 04/19] usb: otg: ab8500: Start using struct usb_otg
Date: Wed, 7 Sep 2011 10:15:57 +0300 [thread overview]
Message-ID: <1315379772-8830-5-git-send-email-heikki.krogerus@linux.intel.com> (raw)
In-Reply-To: <1315379772-8830-1-git-send-email-heikki.krogerus@linux.intel.com>
Use struct usb_otg members with OTG specific functions instead
of usb_phy members.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
---
drivers/usb/otg/ab8500-usb.c | 87 +++++++++++++++++++++++-------------------
1 files changed, 48 insertions(+), 39 deletions(-)
diff --git a/drivers/usb/otg/ab8500-usb.c b/drivers/usb/otg/ab8500-usb.c
index 366c3af..3d659c3 100644
--- a/drivers/usb/otg/ab8500-usb.c
+++ b/drivers/usb/otg/ab8500-usb.c
@@ -68,7 +68,7 @@ enum ab8500_usb_link_status {
};
struct ab8500_usb {
- struct usb_phy otg;
+ struct usb_phy xceiv;
struct device *dev;
int irq_num_id_rise;
int irq_num_id_fall;
@@ -84,7 +84,7 @@ struct ab8500_usb {
static inline struct ab8500_usb *xceiv_to_ab(struct usb_phy *x)
{
- return container_of(x, struct ab8500_usb, otg);
+ return container_of(x, struct ab8500_usb, xceiv);
}
static void ab8500_usb_wd_workaround(struct ab8500_usb *ab)
@@ -169,8 +169,8 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab)
/* TODO: Disable regulators. */
ab8500_usb_host_phy_dis(ab);
ab8500_usb_peri_phy_dis(ab);
- ab->otg.state = USB_PHY_STATE_B_IDLE;
- ab->otg.default_a = false;
+ ab->xceiv.state = USB_PHY_STATE_B_IDLE;
+ ab->xceiv.otg->default_a = false;
ab->vbus_draw = 0;
event = USB_EVENT_NONE;
break;
@@ -181,22 +181,22 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab)
case USB_LINK_HOST_CHG_NM:
case USB_LINK_HOST_CHG_HS:
case USB_LINK_HOST_CHG_HS_CHIRP:
- if (ab->otg.gadget) {
+ if (ab->xceiv.otg->gadget) {
/* TODO: Enable regulators. */
ab8500_usb_peri_phy_en(ab);
- v = ab->otg.gadget;
+ v = ab->xceiv.otg->gadget;
}
event = USB_EVENT_VBUS;
break;
case USB_LINK_HM_IDGND:
- if (ab->otg.host) {
+ if (ab->xceiv.otg->host) {
/* TODO: Enable regulators. */
ab8500_usb_host_phy_en(ab);
- v = ab->otg.host;
+ v = ab->xceiv.otg->host;
}
- ab->otg.state = USB_PHY_STATE_A_IDLE;
- ab->otg.default_a = true;
+ ab->xceiv.state = USB_PHY_STATE_A_IDLE;
+ ab->xceiv.otg->default_a = true;
event = USB_EVENT_ID;
break;
@@ -212,7 +212,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab)
break;
}
- atomic_notifier_call_chain(&ab->otg.notifier, event, v);
+ atomic_notifier_call_chain(&ab->xceiv.notifier, event, v);
return 0;
}
@@ -262,27 +262,27 @@ static void ab8500_usb_phy_disable_work(struct work_struct *work)
struct ab8500_usb *ab = container_of(work, struct ab8500_usb,
phy_dis_work);
- if (!ab->otg.host)
+ if (!ab->xceiv.otg->host)
ab8500_usb_host_phy_dis(ab);
- if (!ab->otg.gadget)
+ if (!ab->xceiv.otg->gadget)
ab8500_usb_peri_phy_dis(ab);
}
-static int ab8500_usb_set_power(struct usb_phy *otg, unsigned mA)
+static int ab8500_usb_set_power(struct usb_phy *xceiv, unsigned mA)
{
struct ab8500_usb *ab;
- if (!otg)
+ if (!xceiv)
return -ENODEV;
- ab = xceiv_to_ab(otg);
+ ab = xceiv_to_ab(xceiv);
ab->vbus_draw = mA;
if (mA)
- atomic_notifier_call_chain(&ab->otg.notifier,
- USB_EVENT_ENUMERATED, ab->otg.gadget);
+ atomic_notifier_call_chain(&ab->xceiv.notifier,
+ USB_EVENT_ENUMERATED, ab->xceiv.otg->gadget);
return 0;
}
@@ -296,15 +296,15 @@ static int ab8500_usb_set_suspend(struct usb_phy *x, int suspend)
return 0;
}
-static int ab8500_usb_set_peripheral(struct usb_phy *otg,
- struct usb_gadget *gadget)
+static int ab8500_usb_set_peripheral(struct usb_otg *otg,
+ struct usb_gadget *gadget)
{
struct ab8500_usb *ab;
if (!otg)
return -ENODEV;
- ab = xceiv_to_ab(otg);
+ ab = xceiv_to_ab(otg->xceiv);
/* Some drivers call this function in atomic context.
* Do not update ab8500 registers directly till this
@@ -313,11 +313,11 @@ static int ab8500_usb_set_peripheral(struct usb_phy *otg,
if (!gadget) {
/* TODO: Disable regulators. */
- ab->otg.gadget = NULL;
+ otg->gadget = NULL;
schedule_work(&ab->phy_dis_work);
} else {
- ab->otg.gadget = gadget;
- ab->otg.state = USB_PHY_STATE_B_IDLE;
+ otg->gadget = gadget;
+ otg->xceiv->state = USB_PHY_STATE_B_IDLE;
/* Phy will not be enabled if cable is already
* plugged-in. Schedule to enable phy.
@@ -329,15 +329,14 @@ static int ab8500_usb_set_peripheral(struct usb_phy *otg,
return 0;
}
-static int ab8500_usb_set_host(struct usb_phy *otg,
- struct usb_bus *host)
+static int ab8500_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{
struct ab8500_usb *ab;
if (!otg)
return -ENODEV;
- ab = xceiv_to_ab(otg);
+ ab = xceiv_to_ab(otg->xceiv);
/* Some drivers call this function in atomic context.
* Do not update ab8500 registers directly till this
@@ -346,10 +345,10 @@ static int ab8500_usb_set_host(struct usb_phy *otg,
if (!host) {
/* TODO: Disable regulators. */
- ab->otg.host = NULL;
+ otg->host = NULL;
schedule_work(&ab->phy_dis_work);
} else {
- ab->otg.host = host;
+ otg->host = host;
/* Phy will not be enabled if cable is already
* plugged-in. Schedule to enable phy.
* Use same delay to avoid any race condition.
@@ -488,19 +487,27 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev)
if (!ab)
return -ENOMEM;
+ ab->xceiv.otg = kzalloc(sizeof *ab->xceiv.otg, GFP_KERNEL);
+ if (!ab->xceiv.otg) {
+ kfree(ab);
+ return -ENOMEM;
+ }
+
ab->dev = &pdev->dev;
ab->rev = rev;
- ab->otg.dev = ab->dev;
- ab->otg.label = "ab8500";
- ab->otg.state = USB_PHY_STATE_UNDEFINED;
- ab->otg.set_host = ab8500_usb_set_host;
- ab->otg.set_peripheral = ab8500_usb_set_peripheral;
- ab->otg.set_suspend = ab8500_usb_set_suspend;
- ab->otg.set_power = ab8500_usb_set_power;
+ ab->xceiv.dev = ab->dev;
+ ab->xceiv.label = "ab8500";
+ ab->xceiv.set_suspend = ab8500_usb_set_suspend;
+ ab->xceiv.set_power = ab8500_usb_set_power;
+ ab->xceiv.state = USB_PHY_STATE_UNDEFINED;
+
+ ab->xceiv.otg->xceiv = &ab->xceiv;
+ ab->xceiv.otg->set_host = ab8500_usb_set_host;
+ ab->xceiv.otg->set_peripheral = ab8500_usb_set_peripheral;
platform_set_drvdata(pdev, ab);
- ATOMIC_INIT_NOTIFIER_HEAD(&ab->otg.notifier);
+ ATOMIC_INIT_NOTIFIER_HEAD(&ab->xceiv.notifier);
/* v1: Wait for link status to become stable.
* all: Updates form set_host and set_peripheral as they are atomic.
@@ -520,7 +527,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev)
if (err < 0)
goto fail0;
- err = otg_set_transceiver(&ab->otg);
+ err = usb_set_transceiver(&ab->xceiv);
if (err) {
dev_err(&pdev->dev, "Can't register transceiver\n");
goto fail1;
@@ -532,6 +539,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev)
fail1:
ab8500_usb_irq_free(ab);
fail0:
+ kfree(ab->xceiv.otg);
kfree(ab);
return err;
}
@@ -546,13 +554,14 @@ static int __devexit ab8500_usb_remove(struct platform_device *pdev)
cancel_work_sync(&ab->phy_dis_work);
- otg_set_transceiver(NULL);
+ usb_set_transceiver(NULL);
ab8500_usb_host_phy_dis(ab);
ab8500_usb_peri_phy_dis(ab);
platform_set_drvdata(pdev, NULL);
+ kfree(ab->xceiv.otg);
kfree(ab);
return 0;
--
1.7.4.1
next prev parent reply other threads:[~2011-09-07 17:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-07 7:15 [PATCHv4 00/19] First round in OTG rework Heikki Krogerus
2011-09-07 7:15 ` [PATCHv4 01/19] usb: otg: Rename otg_transceiver to usb_phy Heikki Krogerus
2011-09-07 7:15 ` [PATCHv4 02/19] usb: otg: Rename usb_otg and usb_xceiv " Heikki Krogerus
2011-09-07 7:15 ` [PATCHv4 03/19] usb: otg: Separate otg members from usb_phy Heikki Krogerus
2011-09-07 7:15 ` Heikki Krogerus [this message]
2011-09-07 14:58 ` [PATCHv4 04/19] usb: otg: ab8500: Start using struct usb_otg Mian Yousaf Kaukab
2011-09-07 7:15 ` [PATCHv4 05/19] usb: otg: fsl: " Heikki Krogerus
2011-09-07 7:15 ` [PATCHv4 06/19] usb: otg: gpio_vbus: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 07/19] usb: otg: isp1301_omap: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 08/19] usb: otg: msm: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 09/19] usb: otg: langwell: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 10/19] usb: otg: nop: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 11/19] usb: otg: twl4030: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 12/19] usb: otg: twl6030: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 13/19] usb: otg: ulpi: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 14/19] arm: imx: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 15/19] usb: musb: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 16/19] power_supply: Convert all users to new usb_phy Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 17/19] usb: " Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 18/19] usb: otg: Remove OTG specific members from usb_phy Heikki Krogerus
2011-09-07 7:16 ` [PATCHv4 19/19] usb: otg: Convert all users to pass struct usb_otg for OTG functions Heikki Krogerus
2011-09-12 12:12 ` [PATCHv4 00/19] First round in OTG rework Heikki Krogerus
2011-09-12 12:45 ` ABRAHAM, KISHON VIJAY
2011-09-13 7:56 ` Igor Grinberg
2011-09-19 11:55 ` Sascha Hauer
2011-09-20 6:50 ` Heikki Krogerus
2011-09-20 10:01 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1315379772-8830-5-git-send-email-heikki.krogerus@linux.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=B19295@freescale.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=balbi@ti.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mian.yousaf.kaukab@stericsson.com \
--cc=peter.chen@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).