aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/otg
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2012-02-13 06:24:10 -0500
committerFelipe Balbi <balbi@ti.com>2012-02-13 06:35:41 -0500
commit41adf109334650c35d0eb94e68082436bd3dd683 (patch)
tree0f32a20e42e91d24f6d86048c3cbf52c6c376ebf /drivers/usb/otg
parent1d4c9293ae3555f2dcf9f394d1e2a14fd9421c4f (diff)
usb: otg: nop: Start using struct usb_otg
Use struct usb_otg members with OTG specific functions instead of usb_phy members. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Cc: Ajay Kumar Gupta <ajay.gupta@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/otg')
-rw-r--r--drivers/usb/otg/nop-usb-xceiv.c64
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 2ab027997060..58b26df6afd1 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -33,7 +33,7 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34 34
35struct nop_usb_xceiv { 35struct nop_usb_xceiv {
36 struct usb_phy otg; 36 struct usb_phy phy;
37 struct device *dev; 37 struct device *dev;
38}; 38};
39 39
@@ -58,51 +58,37 @@ void usb_nop_xceiv_unregister(void)
58} 58}
59EXPORT_SYMBOL(usb_nop_xceiv_unregister); 59EXPORT_SYMBOL(usb_nop_xceiv_unregister);
60 60
61static inline struct nop_usb_xceiv *xceiv_to_nop(struct usb_phy *x)
62{
63 return container_of(x, struct nop_usb_xceiv, otg);
64}
65
66static int nop_set_suspend(struct usb_phy *x, int suspend) 61static int nop_set_suspend(struct usb_phy *x, int suspend)
67{ 62{
68 return 0; 63 return 0;
69} 64}
70 65
71static int nop_set_peripheral(struct usb_phy *x, 66static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
72 struct usb_gadget *gadget)
73{ 67{
74 struct nop_usb_xceiv *nop; 68 if (!otg)
75
76 if (!x)
77 return -ENODEV; 69 return -ENODEV;
78 70
79 nop = xceiv_to_nop(x);
80
81 if (!gadget) { 71 if (!gadget) {
82 nop->otg.gadget = NULL; 72 otg->gadget = NULL;
83 return -ENODEV; 73 return -ENODEV;
84 } 74 }
85 75
86 nop->otg.gadget = gadget; 76 otg->gadget = gadget;
87 nop->otg.state = OTG_STATE_B_IDLE; 77 otg->phy->state = OTG_STATE_B_IDLE;
88 return 0; 78 return 0;
89} 79}
90 80
91static int nop_set_host(struct usb_phy *x, struct usb_bus *host) 81static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
92{ 82{
93 struct nop_usb_xceiv *nop; 83 if (!otg)
94
95 if (!x)
96 return -ENODEV; 84 return -ENODEV;
97 85
98 nop = xceiv_to_nop(x);
99
100 if (!host) { 86 if (!host) {
101 nop->otg.host = NULL; 87 otg->host = NULL;
102 return -ENODEV; 88 return -ENODEV;
103 } 89 }
104 90
105 nop->otg.host = host; 91 otg->host = host;
106 return 0; 92 return 0;
107} 93}
108 94
@@ -115,15 +101,23 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
115 if (!nop) 101 if (!nop)
116 return -ENOMEM; 102 return -ENOMEM;
117 103
104 nop->phy.otg = kzalloc(sizeof *nop->phy.otg, GFP_KERNEL);
105 if (!nop->phy.otg) {
106 kfree(nop);
107 return -ENOMEM;
108 }
109
118 nop->dev = &pdev->dev; 110 nop->dev = &pdev->dev;
119 nop->otg.dev = nop->dev; 111 nop->phy.dev = nop->dev;
120 nop->otg.label = "nop-xceiv"; 112 nop->phy.label = "nop-xceiv";
121 nop->otg.state = OTG_STATE_UNDEFINED; 113 nop->phy.set_suspend = nop_set_suspend;
122 nop->otg.set_host = nop_set_host; 114 nop->phy.state = OTG_STATE_UNDEFINED;
123 nop->otg.set_peripheral = nop_set_peripheral; 115
124 nop->otg.set_suspend = nop_set_suspend; 116 nop->phy.otg->phy = &nop->phy;
125 117 nop->phy.otg->set_host = nop_set_host;
126 err = otg_set_transceiver(&nop->otg); 118 nop->phy.otg->set_peripheral = nop_set_peripheral;
119
120 err = usb_set_transceiver(&nop->phy);
127 if (err) { 121 if (err) {
128 dev_err(&pdev->dev, "can't register transceiver, err: %d\n", 122 dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
129 err); 123 err);
@@ -132,10 +126,11 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
132 126
133 platform_set_drvdata(pdev, nop); 127 platform_set_drvdata(pdev, nop);
134 128
135 ATOMIC_INIT_NOTIFIER_HEAD(&nop->otg.notifier); 129 ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier);
136 130
137 return 0; 131 return 0;
138exit: 132exit:
133 kfree(nop->phy.otg);
139 kfree(nop); 134 kfree(nop);
140 return err; 135 return err;
141} 136}
@@ -144,9 +139,10 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev)
144{ 139{
145 struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); 140 struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
146 141
147 otg_set_transceiver(NULL); 142 usb_set_transceiver(NULL);
148 143
149 platform_set_drvdata(pdev, NULL); 144 platform_set_drvdata(pdev, NULL);
145 kfree(nop->phy.otg);
150 kfree(nop); 146 kfree(nop);
151 147
152 return 0; 148 return 0;