linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 10/19] usb: otg: nop: Start using struct usb_otg
Date: Wed,  7 Sep 2011 10:16:03 +0300	[thread overview]
Message-ID: <1315379772-8830-11-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/nop-usb-xceiv.c |   64 ++++++++++++++++++--------------------
 1 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index 6a0c102..37ce4d3 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -33,7 +33,7 @@
 #include <linux/slab.h>
 
 struct nop_usb_xceiv {
-	struct usb_phy		otg;
+	struct usb_phy		xceiv;
 	struct device		*dev;
 };
 
@@ -58,51 +58,37 @@ void usb_nop_xceiv_unregister(void)
 }
 EXPORT_SYMBOL(usb_nop_xceiv_unregister);
 
-static inline struct nop_usb_xceiv *xceiv_to_nop(struct usb_phy *x)
-{
-	return container_of(x, struct nop_usb_xceiv, otg);
-}
-
 static int nop_set_suspend(struct usb_phy *x, int suspend)
 {
 	return 0;
 }
 
-static int nop_set_peripheral(struct usb_phy *x,
-		struct usb_gadget *gadget)
+static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
 {
-	struct nop_usb_xceiv *nop;
-
-	if (!x)
+	if (!otg)
 		return -ENODEV;
 
-	nop = xceiv_to_nop(x);
-
 	if (!gadget) {
-		nop->otg.gadget = NULL;
+		otg->gadget = NULL;
 		return -ENODEV;
 	}
 
-	nop->otg.gadget = gadget;
-	nop->otg.state = USB_PHY_STATE_B_IDLE;
+	otg->gadget = gadget;
+	otg->xceiv->state = USB_PHY_STATE_B_IDLE;
 	return 0;
 }
 
-static int nop_set_host(struct usb_phy *x, struct usb_bus *host)
+static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
 {
-	struct nop_usb_xceiv *nop;
-
-	if (!x)
+	if (!otg)
 		return -ENODEV;
 
-	nop = xceiv_to_nop(x);
-
 	if (!host) {
-		nop->otg.host = NULL;
+		otg->host = NULL;
 		return -ENODEV;
 	}
 
-	nop->otg.host = host;
+	otg->host = host;
 	return 0;
 }
 
@@ -115,15 +101,23 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
 	if (!nop)
 		return -ENOMEM;
 
+	nop->xceiv.otg = kzalloc(sizeof *nop->xceiv.otg, GFP_KERNEL);
+	if (!nop->xceiv.otg) {
+		kfree(nop);
+		return -ENOMEM;
+	}
+
 	nop->dev		= &pdev->dev;
-	nop->otg.dev		= nop->dev;
-	nop->otg.label		= "nop-xceiv";
-	nop->otg.state		= USB_PHY_STATE_UNDEFINED;
-	nop->otg.set_host	= nop_set_host;
-	nop->otg.set_peripheral	= nop_set_peripheral;
-	nop->otg.set_suspend	= nop_set_suspend;
-
-	err = otg_set_transceiver(&nop->otg);
+	nop->xceiv.dev		= nop->dev;
+	nop->xceiv.label	= "nop-xceiv";
+	nop->xceiv.set_suspend	= nop_set_suspend;
+	nop->xceiv.state	= USB_PHY_STATE_UNDEFINED;
+
+	nop->xceiv.otg->xceiv		= &nop->xceiv;
+	nop->xceiv.otg->set_host	= nop_set_host;
+	nop->xceiv.otg->set_peripheral	= nop_set_peripheral;
+
+	err = usb_set_transceiver(&nop->xceiv);
 	if (err) {
 		dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
 			err);
@@ -132,10 +126,11 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, nop);
 
-	ATOMIC_INIT_NOTIFIER_HEAD(&nop->otg.notifier);
+	ATOMIC_INIT_NOTIFIER_HEAD(&nop->xceiv.notifier);
 
 	return 0;
 exit:
+	kfree(nop->xceiv.otg);
 	kfree(nop);
 	return err;
 }
@@ -144,9 +139,10 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev)
 {
 	struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
 
-	otg_set_transceiver(NULL);
+	usb_set_transceiver(NULL);
 
 	platform_set_drvdata(pdev, NULL);
+	kfree(nop->xceiv.otg);
 	kfree(nop);
 
 	return 0;
-- 
1.7.4.1


  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 ` Heikki Krogerus [this message]
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-11-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).