diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-01-26 05:52:34 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-03-24 07:30:13 -0400 |
commit | 132db99ae2c6f6a586fc932507fcf4484d90c8fa (patch) | |
tree | 352ce15418e9ec8e07a6c12e77c87483c1d4dced /drivers/usb/host/ohci-sa1111.c | |
parent | 3f878dbcd6ca4bbdbac0a1380d25161a7ba610ab (diff) |
USB: sa1111: reorganize ohci-sa1111.c
Combine usb_hcd_sa1111_probe() and ohci_hcd_sa1111_drv_probe(), doing
the same for the remove methods.
Move sa1111_start_hc and sa1111_stop_hc to be located next to these
the probe/release functions, as they're only called from them.
Get rid of the /*----*/ breaker lines.
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/usb/host/ohci-sa1111.c')
-rw-r--r-- | drivers/usb/host/ohci-sa1111.c | 227 |
1 files changed, 93 insertions, 134 deletions
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index e797f18acb33..83f3a40db538 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c | |||
@@ -41,7 +41,78 @@ | |||
41 | #define USB_STATUS_NHCIMFCLR (1 << 10) | 41 | #define USB_STATUS_NHCIMFCLR (1 << 10) |
42 | #define USB_STATUS_USBPWRSENSE (1 << 11) | 42 | #define USB_STATUS_USBPWRSENSE (1 << 11) |
43 | 43 | ||
44 | /*-------------------------------------------------------------------------*/ | 44 | #if 0 |
45 | static void dump_hci_status(struct usb_hcd *hcd, const char *label) | ||
46 | { | ||
47 | unsigned long status = sa1111_readl(hcd->regs + USB_STATUS); | ||
48 | |||
49 | dbg("%s USB_STATUS = { %s%s%s%s%s}", label, | ||
50 | ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""), | ||
51 | ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""), | ||
52 | ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "), | ||
53 | ((status & USB_STATUS_NHCIMFCLR) ? "" : "HCIMFCLR "), | ||
54 | ((status & USB_STATUS_USBPWRSENSE) ? "USBPWRSENSE " : "")); | ||
55 | } | ||
56 | #endif | ||
57 | |||
58 | static int __devinit ohci_sa1111_start(struct usb_hcd *hcd) | ||
59 | { | ||
60 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
61 | int ret; | ||
62 | |||
63 | ret = ohci_init(ohci); | ||
64 | if (ret < 0) | ||
65 | return ret; | ||
66 | |||
67 | ret = ohci_run(ohci); | ||
68 | if (ret < 0) { | ||
69 | err("can't start %s", hcd->self.bus_name); | ||
70 | ohci_stop(hcd); | ||
71 | return ret; | ||
72 | } | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static const struct hc_driver ohci_sa1111_hc_driver = { | ||
77 | .description = hcd_name, | ||
78 | .product_desc = "SA-1111 OHCI", | ||
79 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
80 | |||
81 | /* | ||
82 | * generic hardware linkage | ||
83 | */ | ||
84 | .irq = ohci_irq, | ||
85 | .flags = HCD_USB11 | HCD_MEMORY, | ||
86 | |||
87 | /* | ||
88 | * basic lifecycle operations | ||
89 | */ | ||
90 | .start = ohci_sa1111_start, | ||
91 | .stop = ohci_stop, | ||
92 | |||
93 | /* | ||
94 | * managing i/o requests and associated device resources | ||
95 | */ | ||
96 | .urb_enqueue = ohci_urb_enqueue, | ||
97 | .urb_dequeue = ohci_urb_dequeue, | ||
98 | .endpoint_disable = ohci_endpoint_disable, | ||
99 | |||
100 | /* | ||
101 | * scheduling support | ||
102 | */ | ||
103 | .get_frame_number = ohci_get_frame, | ||
104 | |||
105 | /* | ||
106 | * root hub support | ||
107 | */ | ||
108 | .hub_status_data = ohci_hub_status_data, | ||
109 | .hub_control = ohci_hub_control, | ||
110 | #ifdef CONFIG_PM | ||
111 | .bus_suspend = ohci_bus_suspend, | ||
112 | .bus_resume = ohci_bus_resume, | ||
113 | #endif | ||
114 | .start_port_reset = ohci_start_port_reset, | ||
115 | }; | ||
45 | 116 | ||
46 | static int sa1111_start_hc(struct sa1111_dev *dev) | 117 | static int sa1111_start_hc(struct sa1111_dev *dev) |
47 | { | 118 | { |
@@ -95,46 +166,21 @@ static void sa1111_stop_hc(struct sa1111_dev *dev) | |||
95 | sa1111_disable_device(dev); | 166 | sa1111_disable_device(dev); |
96 | } | 167 | } |
97 | 168 | ||
98 | |||
99 | /*-------------------------------------------------------------------------*/ | ||
100 | |||
101 | #if 0 | ||
102 | static void dump_hci_status(struct usb_hcd *hcd, const char *label) | ||
103 | { | ||
104 | unsigned long status = sa1111_readl(hcd->regs + USB_STATUS); | ||
105 | |||
106 | dbg("%s USB_STATUS = { %s%s%s%s%s}", label, | ||
107 | ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""), | ||
108 | ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""), | ||
109 | ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "), | ||
110 | ((status & USB_STATUS_NHCIMFCLR) ? "" : "HCIMFCLR "), | ||
111 | ((status & USB_STATUS_USBPWRSENSE) ? "USBPWRSENSE " : "")); | ||
112 | } | ||
113 | #endif | ||
114 | |||
115 | /*-------------------------------------------------------------------------*/ | ||
116 | |||
117 | /* configure so an HC device and id are always provided */ | ||
118 | /* always called with process context; sleeping is OK */ | ||
119 | |||
120 | |||
121 | /** | 169 | /** |
122 | * usb_hcd_sa1111_probe - initialize SA-1111-based HCDs | 170 | * ohci_hcd_sa1111_probe - initialize SA-1111-based HCDs |
123 | * Context: !in_interrupt() | ||
124 | * | 171 | * |
125 | * Allocates basic resources for this USB host controller, and | 172 | * Allocates basic resources for this USB host controller, and |
126 | * then invokes the start() method for the HCD associated with it | 173 | * then invokes the start() method for the HCD associated with it. |
127 | * through the hotplug entry's driver_data. | ||
128 | * | ||
129 | * Store this function in the HCD's struct pci_driver as probe(). | ||
130 | */ | 174 | */ |
131 | static int usb_hcd_sa1111_probe(const struct hc_driver *driver, | 175 | static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev) |
132 | struct sa1111_dev *dev) | ||
133 | { | 176 | { |
134 | struct usb_hcd *hcd; | 177 | struct usb_hcd *hcd; |
135 | int retval; | 178 | int ret; |
179 | |||
180 | if (usb_disabled()) | ||
181 | return -ENODEV; | ||
136 | 182 | ||
137 | hcd = usb_create_hcd(driver, &dev->dev, "sa1111"); | 183 | hcd = usb_create_hcd(&ohci_sa1111_hc_driver, &dev->dev, "sa1111"); |
138 | if (!hcd) | 184 | if (!hcd) |
139 | return -ENOMEM; | 185 | return -ENOMEM; |
140 | 186 | ||
@@ -143,7 +189,7 @@ static int usb_hcd_sa1111_probe(const struct hc_driver *driver, | |||
143 | 189 | ||
144 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 190 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { |
145 | dbg("request_mem_region failed"); | 191 | dbg("request_mem_region failed"); |
146 | retval = -EBUSY; | 192 | ret = -EBUSY; |
147 | goto err1; | 193 | goto err1; |
148 | } | 194 | } |
149 | 195 | ||
@@ -155,120 +201,34 @@ static int usb_hcd_sa1111_probe(const struct hc_driver *driver, | |||
155 | 201 | ||
156 | ohci_hcd_init(hcd_to_ohci(hcd)); | 202 | ohci_hcd_init(hcd_to_ohci(hcd)); |
157 | 203 | ||
158 | retval = usb_add_hcd(hcd, dev->irq[1], 0); | 204 | ret = usb_add_hcd(hcd, dev->irq[1], 0); |
159 | if (retval == 0) | 205 | if (ret == 0) |
160 | return retval; | 206 | return ret; |
161 | 207 | ||
162 | sa1111_stop_hc(dev); | 208 | sa1111_stop_hc(dev); |
163 | err2: | 209 | err2: |
164 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 210 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
165 | err1: | 211 | err1: |
166 | usb_put_hcd(hcd); | 212 | usb_put_hcd(hcd); |
167 | return retval; | 213 | return ret; |
168 | } | 214 | } |
169 | 215 | ||
170 | |||
171 | /* may be called without controller electrically present */ | ||
172 | /* may be called with controller, bus, and devices active */ | ||
173 | |||
174 | /** | 216 | /** |
175 | * usb_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs | 217 | * ohci_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs |
176 | * @dev: USB Host Controller being removed | 218 | * @dev: USB Host Controller being removed |
177 | * Context: !in_interrupt() | ||
178 | * | 219 | * |
179 | * Reverses the effect of usb_hcd_sa1111_probe(), first invoking | 220 | * Reverses the effect of ohci_hcd_sa1111_probe(), first invoking |
180 | * the HCD's stop() method. It is always called from a thread | 221 | * the HCD's stop() method. |
181 | * context, normally "rmmod", "apmd", or something similar. | ||
182 | */ | 222 | */ |
183 | static void usb_hcd_sa1111_remove(struct usb_hcd *hcd, struct sa1111_dev *dev) | 223 | static int ohci_hcd_sa1111_remove(struct sa1111_dev *dev) |
184 | { | 224 | { |
225 | struct usb_hcd *hcd = sa1111_get_drvdata(dev); | ||
226 | |||
185 | usb_remove_hcd(hcd); | 227 | usb_remove_hcd(hcd); |
186 | sa1111_stop_hc(dev); | 228 | sa1111_stop_hc(dev); |
187 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 229 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
188 | usb_put_hcd(hcd); | 230 | usb_put_hcd(hcd); |
189 | } | ||
190 | |||
191 | /*-------------------------------------------------------------------------*/ | ||
192 | 231 | ||
193 | static int __devinit ohci_sa1111_start(struct usb_hcd *hcd) | ||
194 | { | ||
195 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
196 | int ret; | ||
197 | |||
198 | ret = ohci_init(ohci); | ||
199 | if (ret < 0) | ||
200 | return ret; | ||
201 | |||
202 | ret = ohci_run(ohci); | ||
203 | if (ret < 0) { | ||
204 | err("can't start %s", hcd->self.bus_name); | ||
205 | ohci_stop(hcd); | ||
206 | return ret; | ||
207 | } | ||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | /*-------------------------------------------------------------------------*/ | ||
212 | |||
213 | static const struct hc_driver ohci_sa1111_hc_driver = { | ||
214 | .description = hcd_name, | ||
215 | .product_desc = "SA-1111 OHCI", | ||
216 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
217 | |||
218 | /* | ||
219 | * generic hardware linkage | ||
220 | */ | ||
221 | .irq = ohci_irq, | ||
222 | .flags = HCD_USB11 | HCD_MEMORY, | ||
223 | |||
224 | /* | ||
225 | * basic lifecycle operations | ||
226 | */ | ||
227 | .start = ohci_sa1111_start, | ||
228 | .stop = ohci_stop, | ||
229 | |||
230 | /* | ||
231 | * managing i/o requests and associated device resources | ||
232 | */ | ||
233 | .urb_enqueue = ohci_urb_enqueue, | ||
234 | .urb_dequeue = ohci_urb_dequeue, | ||
235 | .endpoint_disable = ohci_endpoint_disable, | ||
236 | |||
237 | /* | ||
238 | * scheduling support | ||
239 | */ | ||
240 | .get_frame_number = ohci_get_frame, | ||
241 | |||
242 | /* | ||
243 | * root hub support | ||
244 | */ | ||
245 | .hub_status_data = ohci_hub_status_data, | ||
246 | .hub_control = ohci_hub_control, | ||
247 | #ifdef CONFIG_PM | ||
248 | .bus_suspend = ohci_bus_suspend, | ||
249 | .bus_resume = ohci_bus_resume, | ||
250 | #endif | ||
251 | .start_port_reset = ohci_start_port_reset, | ||
252 | }; | ||
253 | |||
254 | /*-------------------------------------------------------------------------*/ | ||
255 | |||
256 | static int ohci_hcd_sa1111_drv_probe(struct sa1111_dev *dev) | ||
257 | { | ||
258 | int ret; | ||
259 | |||
260 | if (usb_disabled()) | ||
261 | return -ENODEV; | ||
262 | |||
263 | ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, dev); | ||
264 | return ret; | ||
265 | } | ||
266 | |||
267 | static int ohci_hcd_sa1111_drv_remove(struct sa1111_dev *dev) | ||
268 | { | ||
269 | struct usb_hcd *hcd = sa1111_get_drvdata(dev); | ||
270 | |||
271 | usb_hcd_sa1111_remove(hcd, dev); | ||
272 | return 0; | 232 | return 0; |
273 | } | 233 | } |
274 | 234 | ||
@@ -278,7 +238,6 @@ static struct sa1111_driver ohci_hcd_sa1111_driver = { | |||
278 | .owner = THIS_MODULE, | 238 | .owner = THIS_MODULE, |
279 | }, | 239 | }, |
280 | .devid = SA1111_DEVID_USB, | 240 | .devid = SA1111_DEVID_USB, |
281 | .probe = ohci_hcd_sa1111_drv_probe, | 241 | .probe = ohci_hcd_sa1111_probe, |
282 | .remove = ohci_hcd_sa1111_drv_remove, | 242 | .remove = ohci_hcd_sa1111_remove, |
283 | }; | 243 | }; |
284 | |||