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>,
Philipp Zabel <philipp.zabel@gmail.com>
Subject: [PATCHv5 06/19] usb: otg: gpio_vbus: Start using struct usb_otg
Date: Mon, 26 Sep 2011 14:21:19 +0300 [thread overview]
Message-ID: <1317036092-3000-7-git-send-email-heikki.krogerus@linux.intel.com> (raw)
In-Reply-To: <1317036092-3000-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: Philipp Zabel <philipp.zabel@gmail.com>
---
drivers/usb/otg/gpio_vbus.c | 61 +++++++++++++++++++++++++-----------------
1 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c
index 14f48e8..548720c 100644
--- a/drivers/usb/otg/gpio_vbus.c
+++ b/drivers/usb/otg/gpio_vbus.c
@@ -31,7 +31,7 @@
* Needs to be loaded before the UDC driver that will use it.
*/
struct gpio_vbus_data {
- struct usb_phy otg;
+ struct usb_phy xceiv;
struct device *dev;
struct regulator *vbus_draw;
int vbus_draw_enabled;
@@ -97,7 +97,7 @@ static void gpio_vbus_work(struct work_struct *work)
struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data;
int gpio;
- if (!gpio_vbus->otg.gadget)
+ if (!gpio_vbus->xceiv.otg->gadget)
return;
/* Peripheral controllers which manage the pullup themselves won't have
@@ -107,8 +107,8 @@ static void gpio_vbus_work(struct work_struct *work)
*/
gpio = pdata->gpio_pullup;
if (is_vbus_powered(pdata)) {
- gpio_vbus->otg.state = USB_PHY_STATE_B_PERIPHERAL;
- usb_gadget_vbus_connect(gpio_vbus->otg.gadget);
+ gpio_vbus->xceiv.state = USB_PHY_STATE_B_PERIPHERAL;
+ usb_gadget_vbus_connect(gpio_vbus->xceiv.otg->gadget);
/* drawing a "unit load" is *always* OK, except for OTG */
set_vbus_draw(gpio_vbus, 100);
@@ -123,8 +123,8 @@ static void gpio_vbus_work(struct work_struct *work)
set_vbus_draw(gpio_vbus, 0);
- usb_gadget_vbus_disconnect(gpio_vbus->otg.gadget);
- gpio_vbus->otg.state = USB_PHY_STATE_B_IDLE;
+ usb_gadget_vbus_disconnect(gpio_vbus->xceiv.otg->gadget);
+ gpio_vbus->xceiv.state = USB_PHY_STATE_B_IDLE;
}
}
@@ -134,12 +134,13 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data)
struct platform_device *pdev = data;
struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data;
struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev);
+ struct usb_otg *otg = gpio_vbus->xceiv.otg;
dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n",
is_vbus_powered(pdata) ? "supplied" : "inactive",
- gpio_vbus->otg.gadget ? gpio_vbus->otg.gadget->name : "none");
+ otg->gadget ? otg->gadget->name : "none");
- if (gpio_vbus->otg.gadget)
+ if (otg->gadget)
schedule_work(&gpio_vbus->work);
return IRQ_HANDLED;
@@ -148,15 +149,15 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data)
/* OTG transceiver interface */
/* bind/unbind the peripheral controller */
-static int gpio_vbus_set_peripheral(struct usb_phy *otg,
- struct usb_gadget *gadget)
+static int gpio_vbus_set_peripheral(struct usb_otg *otg,
+ struct usb_gadget *gadget)
{
struct gpio_vbus_data *gpio_vbus;
struct gpio_vbus_mach_info *pdata;
struct platform_device *pdev;
int gpio, irq;
- gpio_vbus = container_of(otg, struct gpio_vbus_data, otg);
+ gpio_vbus = container_of(otg->xceiv, struct gpio_vbus_data, xceiv);
pdev = to_platform_device(gpio_vbus->dev);
pdata = gpio_vbus->dev->platform_data;
irq = gpio_to_irq(pdata->gpio_vbus);
@@ -173,7 +174,7 @@ static int gpio_vbus_set_peripheral(struct usb_phy *otg,
set_vbus_draw(gpio_vbus, 0);
usb_gadget_vbus_disconnect(otg->gadget);
- otg->state = USB_PHY_STATE_UNDEFINED;
+ otg->xceiv->state = USB_PHY_STATE_UNDEFINED;
otg->gadget = NULL;
return 0;
@@ -188,23 +189,23 @@ static int gpio_vbus_set_peripheral(struct usb_phy *otg,
}
/* effective for B devices, ignored for A-peripheral */
-static int gpio_vbus_set_power(struct usb_phy *otg, unsigned mA)
+static int gpio_vbus_set_power(struct usb_phy *xceiv, unsigned mA)
{
struct gpio_vbus_data *gpio_vbus;
- gpio_vbus = container_of(otg, struct gpio_vbus_data, otg);
+ gpio_vbus = container_of(xceiv, struct gpio_vbus_data, xceiv);
- if (otg->state == USB_PHY_STATE_B_PERIPHERAL)
+ if (xceiv->state == USB_PHY_STATE_B_PERIPHERAL)
set_vbus_draw(gpio_vbus, mA);
return 0;
}
/* for non-OTG B devices: set/clear transceiver suspend mode */
-static int gpio_vbus_set_suspend(struct usb_phy *otg, int suspend)
+static int gpio_vbus_set_suspend(struct usb_phy *xceiv, int suspend)
{
struct gpio_vbus_data *gpio_vbus;
- gpio_vbus = container_of(otg, struct gpio_vbus_data, otg);
+ gpio_vbus = container_of(xceiv, struct gpio_vbus_data, xceiv);
/* draw max 0 mA from vbus in suspend mode; or the previously
* recorded amount of current if not suspended
@@ -212,7 +213,7 @@ static int gpio_vbus_set_suspend(struct usb_phy *otg, int suspend)
* NOTE: high powered configs (mA > 100) may draw up to 2.5 mA
* if they're wake-enabled ... we don't handle that yet.
*/
- return gpio_vbus_set_power(otg, suspend ? 0 : gpio_vbus->mA);
+ return gpio_vbus_set_power(xceiv, suspend ? 0 : gpio_vbus->mA);
}
/* platform driver interface */
@@ -232,13 +233,21 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
if (!gpio_vbus)
return -ENOMEM;
+ gpio_vbus->xceiv.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL);
+ if (!gpio_vbus->xceiv.otg) {
+ kfree(gpio_vbus);
+ return -ENOMEM;
+ }
+
platform_set_drvdata(pdev, gpio_vbus);
gpio_vbus->dev = &pdev->dev;
- gpio_vbus->otg.label = "gpio-vbus";
- gpio_vbus->otg.state = USB_PHY_STATE_UNDEFINED;
- gpio_vbus->otg.set_peripheral = gpio_vbus_set_peripheral;
- gpio_vbus->otg.set_power = gpio_vbus_set_power;
- gpio_vbus->otg.set_suspend = gpio_vbus_set_suspend;
+ gpio_vbus->xceiv.label = "gpio-vbus";
+ gpio_vbus->xceiv.set_power = gpio_vbus_set_power;
+ gpio_vbus->xceiv.set_suspend = gpio_vbus_set_suspend;
+ gpio_vbus->xceiv.state = USB_PHY_STATE_UNDEFINED;
+
+ gpio_vbus->xceiv.otg->xceiv = &gpio_vbus->xceiv;
+ gpio_vbus->xceiv.otg->set_peripheral = gpio_vbus_set_peripheral;
err = gpio_request(gpio, "vbus_detect");
if (err) {
@@ -287,7 +296,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
}
/* only active when a gadget is registered */
- err = otg_set_transceiver(&gpio_vbus->otg);
+ err = usb_set_transceiver(&gpio_vbus->xceiv);
if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err);
@@ -303,6 +312,7 @@ err_irq:
gpio_free(pdata->gpio_vbus);
err_gpio:
platform_set_drvdata(pdev, NULL);
+ kfree(gpio_vbus->xceiv.otg);
kfree(gpio_vbus);
return err;
}
@@ -315,13 +325,14 @@ static int __exit gpio_vbus_remove(struct platform_device *pdev)
regulator_put(gpio_vbus->vbus_draw);
- otg_set_transceiver(NULL);
+ usb_set_transceiver(NULL);
free_irq(gpio_to_irq(gpio), &pdev->dev);
if (gpio_is_valid(pdata->gpio_pullup))
gpio_free(pdata->gpio_pullup);
gpio_free(gpio);
platform_set_drvdata(pdev, NULL);
+ kfree(gpio_vbus->xceiv.otg);
kfree(gpio_vbus);
return 0;
--
1.7.4.1
next prev parent reply other threads:[~2011-09-26 11:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-26 11:21 [PATCHv5 00/19] First round in OTG rework Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 01/19] usb: otg: Rename otg_transceiver to usb_phy Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 02/19] usb: otg: Rename usb_otg and usb_xceiv " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 03/19] usb: otg: Separate otg members from usb_phy Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 04/19] usb: otg: ab8500: Start using struct usb_otg Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 05/19] usb: otg: fsl: " Heikki Krogerus
2011-09-26 11:21 ` Heikki Krogerus [this message]
2011-09-26 11:21 ` [PATCHv5 07/19] usb: otg: isp1301_omap: " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 08/19] usb: otg: msm: " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 09/19] usb: otg: langwell: " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 10/19] usb: otg: nop: " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 11/19] usb: otg: twl4030: " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 12/19] usb: otg: twl6030: " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 13/19] usb: otg: ulpi: " Heikki Krogerus
2011-10-24 12:28 ` Igor Grinberg
2011-09-26 11:21 ` [PATCHv5 14/19] arm: imx: " Heikki Krogerus
2011-10-03 13:04 ` Heikki Krogerus
2011-10-03 13:29 ` Fabio Estevam
2011-10-04 13:51 ` Philippe Rétornaz
2011-10-04 14:38 ` Heikki Krogerus
2011-10-04 17:05 ` Philippe Rétornaz
2011-10-05 9:51 ` Heikki Krogerus
2011-10-07 12:52 ` Sascha Hauer
2011-09-26 11:21 ` [PATCHv5 15/19] usb: musb: " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 16/19] power_supply: Convert all users to new usb_phy Heikki Krogerus
[not found] ` <20111003131055.GC2487@xps8300>
2011-10-10 19:08 ` Anton Vorontsov
2011-10-24 10:14 ` Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 17/19] usb: " Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 18/19] usb: otg: Remove OTG specific members from usb_phy Heikki Krogerus
2011-09-26 11:21 ` [PATCHv5 19/19] usb: otg: Convert all users to pass struct usb_otg for OTG functions Heikki Krogerus
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=1317036092-3000-7-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 \
--cc=philipp.zabel@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.