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>
Subject: [PATCHv4 11/19] usb: otg: twl4030: Start using struct usb_otg
Date: Wed, 7 Sep 2011 10:16:04 +0300 [thread overview]
Message-ID: <1315379772-8830-12-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>
---
drivers/usb/otg/twl4030-usb.c | 77 +++++++++++++++++++++++------------------
1 files changed, 43 insertions(+), 34 deletions(-)
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index 9eed1f3..4151004 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -144,7 +144,7 @@
#define GPIO_USB_4PIN_ULPI_2430C (3 << 0)
struct twl4030_usb {
- struct usb_phy otg;
+ struct usb_phy xceiv;
struct device *dev;
/* TWL4030 internal USB regulator supplies */
@@ -166,7 +166,7 @@ struct twl4030_usb {
};
/* internal define on top of container_of */
-#define xceiv_to_twl(x) container_of((x), struct twl4030_usb, otg)
+#define xceiv_to_twl(x) container_of((x), struct twl4030_usb, xceiv)
/*-------------------------------------------------------------------------*/
@@ -250,6 +250,7 @@ static enum usb_phy_events twl4030_usb_linkstat(struct twl4030_usb *twl)
{
int status;
int linkstat = USB_EVENT_NONE;
+ struct usb_otg *otg = twl->xceiv.otg;
twl->vbus_supplied = false;
@@ -281,7 +282,7 @@ static enum usb_phy_events twl4030_usb_linkstat(struct twl4030_usb *twl)
dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n",
status, status, linkstat);
- twl->otg.last_event = linkstat;
+ twl->xceiv.last_event = linkstat;
/* REVISIT this assumes host and peripheral controllers
* are registered, and that both are active...
@@ -290,11 +291,11 @@ static enum usb_phy_events twl4030_usb_linkstat(struct twl4030_usb *twl)
spin_lock_irq(&twl->lock);
twl->linkstat = linkstat;
if (linkstat == USB_EVENT_ID) {
- twl->otg.default_a = true;
- twl->otg.state = USB_PHY_STATE_A_IDLE;
+ otg->default_a = true;
+ twl->xceiv.state = USB_PHY_STATE_A_IDLE;
} else {
- twl->otg.default_a = false;
- twl->otg.state = USB_PHY_STATE_B_IDLE;
+ otg->default_a = false;
+ twl->xceiv.state = USB_PHY_STATE_B_IDLE;
}
spin_unlock_irq(&twl->lock);
@@ -520,8 +521,8 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
else
twl4030_phy_resume(twl);
- atomic_notifier_call_chain(&twl->otg.notifier, status,
- twl->otg.gadget);
+ atomic_notifier_call_chain(&twl->xceiv.notifier, status,
+ twl->xceiv.otg->gadget);
}
sysfs_notify(&twl->dev->kobj, NULL, "vbus");
@@ -542,8 +543,8 @@ static void twl4030_usb_phy_init(struct twl4030_usb *twl)
twl->asleep = 0;
}
- atomic_notifier_call_chain(&twl->otg.notifier, status,
- twl->otg.gadget);
+ atomic_notifier_call_chain(&twl->xceiv.notifier, status,
+ twl->xceiv.otg->gadget);
}
sysfs_notify(&twl->dev->kobj, NULL, "vbus");
}
@@ -560,33 +561,27 @@ static int twl4030_set_suspend(struct usb_phy *x, int suspend)
return 0;
}
-static int twl4030_set_peripheral(struct usb_phy *x,
- struct usb_gadget *gadget)
+static int twl4030_set_peripheral(struct usb_otg *otg,
+ struct usb_gadget *gadget)
{
- struct twl4030_usb *twl;
-
- if (!x)
+ if (!otg)
return -ENODEV;
- twl = xceiv_to_twl(x);
- twl->otg.gadget = gadget;
+ otg->gadget = gadget;
if (!gadget)
- twl->otg.state = USB_PHY_STATE_UNDEFINED;
+ otg->xceiv->state = USB_PHY_STATE_UNDEFINED;
return 0;
}
-static int twl4030_set_host(struct usb_phy *x, struct usb_bus *host)
+static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct twl4030_usb *twl;
-
- if (!x)
+ if (!otg)
return -ENODEV;
- twl = xceiv_to_twl(x);
- twl->otg.host = host;
+ otg->host = host;
if (!host)
- twl->otg.state = USB_PHY_STATE_UNDEFINED;
+ otg->xceiv->state = USB_PHY_STATE_UNDEFINED;
return 0;
}
@@ -596,6 +591,7 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)
struct twl4030_usb_data *pdata = pdev->dev.platform_data;
struct twl4030_usb *twl;
int status, err;
+ struct usb_otg *otg;
if (!pdata) {
dev_dbg(&pdev->dev, "platform_data not available\n");
@@ -606,16 +602,26 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)
if (!twl)
return -ENOMEM;
+ otg = kzalloc(sizeof *otg, GFP_KERNEL);
+ if (!otg) {
+ kfree(twl);
+ return -ENOMEM;
+ }
+
twl->dev = &pdev->dev;
twl->irq = platform_get_irq(pdev, 0);
- twl->otg.dev = twl->dev;
- twl->otg.label = "twl4030";
- twl->otg.set_host = twl4030_set_host;
- twl->otg.set_peripheral = twl4030_set_peripheral;
- twl->otg.set_suspend = twl4030_set_suspend;
twl->usb_mode = pdata->usb_mode;
twl->vbus_supplied = false;
- twl->asleep = 1;
+ twl->asleep = 1;
+
+ twl->xceiv.dev = twl->dev;
+ twl->xceiv.label = "twl4030";
+ twl->xceiv.otg = otg;
+ twl->xceiv.set_suspend = twl4030_set_suspend;
+
+ otg->xceiv = &twl->xceiv;
+ otg->set_host = twl4030_set_host;
+ otg->set_peripheral = twl4030_set_peripheral;
/* init spinlock for workqueue */
spin_lock_init(&twl->lock);
@@ -623,16 +629,17 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)
err = twl4030_usb_ldo_init(twl);
if (err) {
dev_err(&pdev->dev, "ldo init failed\n");
+ kfree(otg);
kfree(twl);
return err;
}
- otg_set_transceiver(&twl->otg);
+ usb_set_transceiver(&twl->xceiv);
platform_set_drvdata(pdev, twl);
if (device_create_file(&pdev->dev, &dev_attr_vbus))
dev_warn(&pdev->dev, "could not create sysfs file\n");
- ATOMIC_INIT_NOTIFIER_HEAD(&twl->otg.notifier);
+ ATOMIC_INIT_NOTIFIER_HEAD(&twl->xceiv.notifier);
/* Our job is to use irqs and status from the power module
* to keep the transceiver disabled when nothing's connected.
@@ -649,6 +656,7 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n",
twl->irq, status);
+ kfree(otg);
kfree(twl);
return status;
}
@@ -693,6 +701,7 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev)
regulator_put(twl->usb1v8);
regulator_put(twl->usb3v1);
+ kfree(twl->xceiv.otg);
kfree(twl);
return 0;
--
1.7.4.1
next prev parent reply other threads:[~2011-09-07 16:59 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 ` [PATCHv4 04/19] usb: otg: ab8500: Start using struct usb_otg Heikki Krogerus
2011-09-07 14:58 ` 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 ` Heikki Krogerus [this message]
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-12-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=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).