diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-30 18:21:33 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:35:08 -0500 |
commit | 3e35bf39e0b9091d47a40e26fc2704b3b24e1ec4 (patch) | |
tree | abb52230906179e18b5bdf68a2160659eb7e19df | |
parent | 34bbe4c16ca06cb762b99a6263832cfdbbe154ad (diff) |
USB: fix codingstyle issues in drivers/usb/core/message.c
Fixes a number of coding style issues in the message.c file.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/message.c | 398 |
1 files changed, 204 insertions, 194 deletions
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 58b8e1c6b9a6..fefb92296e8f 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -39,7 +39,7 @@ static void usb_api_blocking_completion(struct urb *urb) | |||
39 | * own interruptible routines. | 39 | * own interruptible routines. |
40 | */ | 40 | */ |
41 | static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) | 41 | static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) |
42 | { | 42 | { |
43 | struct api_context ctx; | 43 | struct api_context ctx; |
44 | unsigned long expire; | 44 | unsigned long expire; |
45 | int retval; | 45 | int retval; |
@@ -74,9 +74,9 @@ out: | |||
74 | } | 74 | } |
75 | 75 | ||
76 | /*-------------------------------------------------------------------*/ | 76 | /*-------------------------------------------------------------------*/ |
77 | // returns status (negative) or length (positive) | 77 | /* returns status (negative) or length (positive) */ |
78 | static int usb_internal_control_msg(struct usb_device *usb_dev, | 78 | static int usb_internal_control_msg(struct usb_device *usb_dev, |
79 | unsigned int pipe, | 79 | unsigned int pipe, |
80 | struct usb_ctrlrequest *cmd, | 80 | struct usb_ctrlrequest *cmd, |
81 | void *data, int len, int timeout) | 81 | void *data, int len, int timeout) |
82 | { | 82 | { |
@@ -87,7 +87,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, | |||
87 | urb = usb_alloc_urb(0, GFP_NOIO); | 87 | urb = usb_alloc_urb(0, GFP_NOIO); |
88 | if (!urb) | 88 | if (!urb) |
89 | return -ENOMEM; | 89 | return -ENOMEM; |
90 | 90 | ||
91 | usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data, | 91 | usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data, |
92 | len, usb_api_blocking_completion, NULL); | 92 | len, usb_api_blocking_completion, NULL); |
93 | 93 | ||
@@ -99,47 +99,51 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, | |||
99 | } | 99 | } |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * usb_control_msg - Builds a control urb, sends it off and waits for completion | 102 | * usb_control_msg - Builds a control urb, sends it off and waits for completion |
103 | * @dev: pointer to the usb device to send the message to | 103 | * @dev: pointer to the usb device to send the message to |
104 | * @pipe: endpoint "pipe" to send the message to | 104 | * @pipe: endpoint "pipe" to send the message to |
105 | * @request: USB message request value | 105 | * @request: USB message request value |
106 | * @requesttype: USB message request type value | 106 | * @requesttype: USB message request type value |
107 | * @value: USB message value | 107 | * @value: USB message value |
108 | * @index: USB message index value | 108 | * @index: USB message index value |
109 | * @data: pointer to the data to send | 109 | * @data: pointer to the data to send |
110 | * @size: length in bytes of the data to send | 110 | * @size: length in bytes of the data to send |
111 | * @timeout: time in msecs to wait for the message to complete before | 111 | * @timeout: time in msecs to wait for the message to complete before timing |
112 | * timing out (if 0 the wait is forever) | 112 | * out (if 0 the wait is forever) |
113 | * Context: !in_interrupt () | 113 | * |
114 | * | 114 | * Context: !in_interrupt () |
115 | * This function sends a simple control message to a specified endpoint | 115 | * |
116 | * and waits for the message to complete, or timeout. | 116 | * This function sends a simple control message to a specified endpoint and |
117 | * | 117 | * waits for the message to complete, or timeout. |
118 | * If successful, it returns the number of bytes transferred, otherwise a negative error number. | 118 | * |
119 | * | 119 | * If successful, it returns the number of bytes transferred, otherwise a |
120 | * Don't use this function from within an interrupt context, like a | 120 | * negative error number. |
121 | * bottom half handler. If you need an asynchronous message, or need to send | 121 | * |
122 | * a message from within interrupt context, use usb_submit_urb() | 122 | * Don't use this function from within an interrupt context, like a bottom half |
123 | * If a thread in your driver uses this call, make sure your disconnect() | 123 | * handler. If you need an asynchronous message, or need to send a message |
124 | * method can wait for it to complete. Since you don't have a handle on | 124 | * from within interrupt context, use usb_submit_urb(). |
125 | * the URB used, you can't cancel the request. | 125 | * If a thread in your driver uses this call, make sure your disconnect() |
126 | * method can wait for it to complete. Since you don't have a handle on the | ||
127 | * URB used, you can't cancel the request. | ||
126 | */ | 128 | */ |
127 | int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, | 129 | int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, |
128 | __u16 value, __u16 index, void *data, __u16 size, int timeout) | 130 | __u8 requesttype, __u16 value, __u16 index, void *data, |
131 | __u16 size, int timeout) | ||
129 | { | 132 | { |
130 | struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); | 133 | struct usb_ctrlrequest *dr; |
131 | int ret; | 134 | int ret; |
132 | 135 | ||
136 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); | ||
133 | if (!dr) | 137 | if (!dr) |
134 | return -ENOMEM; | 138 | return -ENOMEM; |
135 | 139 | ||
136 | dr->bRequestType= requesttype; | 140 | dr->bRequestType = requesttype; |
137 | dr->bRequest = request; | 141 | dr->bRequest = request; |
138 | dr->wValue = cpu_to_le16p(&value); | 142 | dr->wValue = cpu_to_le16p(&value); |
139 | dr->wIndex = cpu_to_le16p(&index); | 143 | dr->wIndex = cpu_to_le16p(&index); |
140 | dr->wLength = cpu_to_le16p(&size); | 144 | dr->wLength = cpu_to_le16p(&size); |
141 | 145 | ||
142 | //dbg("usb_control_msg"); | 146 | /* dbg("usb_control_msg"); */ |
143 | 147 | ||
144 | ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); | 148 | ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); |
145 | 149 | ||
@@ -155,9 +159,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); | |||
155 | * @pipe: endpoint "pipe" to send the message to | 159 | * @pipe: endpoint "pipe" to send the message to |
156 | * @data: pointer to the data to send | 160 | * @data: pointer to the data to send |
157 | * @len: length in bytes of the data to send | 161 | * @len: length in bytes of the data to send |
158 | * @actual_length: pointer to a location to put the actual length transferred in bytes | 162 | * @actual_length: pointer to a location to put the actual length transferred |
163 | * in bytes | ||
159 | * @timeout: time in msecs to wait for the message to complete before | 164 | * @timeout: time in msecs to wait for the message to complete before |
160 | * timing out (if 0 the wait is forever) | 165 | * timing out (if 0 the wait is forever) |
166 | * | ||
161 | * Context: !in_interrupt () | 167 | * Context: !in_interrupt () |
162 | * | 168 | * |
163 | * This function sends a simple interrupt message to a specified endpoint and | 169 | * This function sends a simple interrupt message to a specified endpoint and |
@@ -181,38 +187,38 @@ int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe, | |||
181 | EXPORT_SYMBOL_GPL(usb_interrupt_msg); | 187 | EXPORT_SYMBOL_GPL(usb_interrupt_msg); |
182 | 188 | ||
183 | /** | 189 | /** |
184 | * usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion | 190 | * usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion |
185 | * @usb_dev: pointer to the usb device to send the message to | 191 | * @usb_dev: pointer to the usb device to send the message to |
186 | * @pipe: endpoint "pipe" to send the message to | 192 | * @pipe: endpoint "pipe" to send the message to |
187 | * @data: pointer to the data to send | 193 | * @data: pointer to the data to send |
188 | * @len: length in bytes of the data to send | 194 | * @len: length in bytes of the data to send |
189 | * @actual_length: pointer to a location to put the actual length transferred in bytes | 195 | * @actual_length: pointer to a location to put the actual length transferred |
190 | * @timeout: time in msecs to wait for the message to complete before | 196 | * in bytes |
191 | * timing out (if 0 the wait is forever) | 197 | * @timeout: time in msecs to wait for the message to complete before |
192 | * Context: !in_interrupt () | 198 | * timing out (if 0 the wait is forever) |
193 | * | 199 | * |
194 | * This function sends a simple bulk message to a specified endpoint | 200 | * Context: !in_interrupt () |
195 | * and waits for the message to complete, or timeout. | 201 | * |
196 | * | 202 | * This function sends a simple bulk message to a specified endpoint |
197 | * If successful, it returns 0, otherwise a negative error number. | 203 | * and waits for the message to complete, or timeout. |
198 | * The number of actual bytes transferred will be stored in the | 204 | * |
199 | * actual_length paramater. | 205 | * If successful, it returns 0, otherwise a negative error number. The number |
200 | * | 206 | * of actual bytes transferred will be stored in the actual_length paramater. |
201 | * Don't use this function from within an interrupt context, like a | 207 | * |
202 | * bottom half handler. If you need an asynchronous message, or need to | 208 | * Don't use this function from within an interrupt context, like a bottom half |
203 | * send a message from within interrupt context, use usb_submit_urb() | 209 | * handler. If you need an asynchronous message, or need to send a message |
204 | * If a thread in your driver uses this call, make sure your disconnect() | 210 | * from within interrupt context, use usb_submit_urb() If a thread in your |
205 | * method can wait for it to complete. Since you don't have a handle on | 211 | * driver uses this call, make sure your disconnect() method can wait for it to |
206 | * the URB used, you can't cancel the request. | 212 | * complete. Since you don't have a handle on the URB used, you can't cancel |
207 | * | 213 | * the request. |
208 | * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT | 214 | * |
209 | * ioctl, users are forced to abuse this routine by using it to submit | 215 | * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, |
210 | * URBs for interrupt endpoints. We will take the liberty of creating | 216 | * users are forced to abuse this routine by using it to submit URBs for |
211 | * an interrupt URB (with the default interval) if the target is an | 217 | * interrupt endpoints. We will take the liberty of creating an interrupt URB |
212 | * interrupt endpoint. | 218 | * (with the default interval) if the target is an interrupt endpoint. |
213 | */ | 219 | */ |
214 | int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, | 220 | int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, |
215 | void *data, int len, int *actual_length, int timeout) | 221 | void *data, int len, int *actual_length, int timeout) |
216 | { | 222 | { |
217 | struct urb *urb; | 223 | struct urb *urb; |
218 | struct usb_host_endpoint *ep; | 224 | struct usb_host_endpoint *ep; |
@@ -242,26 +248,26 @@ EXPORT_SYMBOL_GPL(usb_bulk_msg); | |||
242 | 248 | ||
243 | /*-------------------------------------------------------------------*/ | 249 | /*-------------------------------------------------------------------*/ |
244 | 250 | ||
245 | static void sg_clean (struct usb_sg_request *io) | 251 | static void sg_clean(struct usb_sg_request *io) |
246 | { | 252 | { |
247 | if (io->urbs) { | 253 | if (io->urbs) { |
248 | while (io->entries--) | 254 | while (io->entries--) |
249 | usb_free_urb (io->urbs [io->entries]); | 255 | usb_free_urb(io->urbs [io->entries]); |
250 | kfree (io->urbs); | 256 | kfree(io->urbs); |
251 | io->urbs = NULL; | 257 | io->urbs = NULL; |
252 | } | 258 | } |
253 | if (io->dev->dev.dma_mask != NULL) | 259 | if (io->dev->dev.dma_mask != NULL) |
254 | usb_buffer_unmap_sg (io->dev, usb_pipein(io->pipe), | 260 | usb_buffer_unmap_sg(io->dev, usb_pipein(io->pipe), |
255 | io->sg, io->nents); | 261 | io->sg, io->nents); |
256 | io->dev = NULL; | 262 | io->dev = NULL; |
257 | } | 263 | } |
258 | 264 | ||
259 | static void sg_complete (struct urb *urb) | 265 | static void sg_complete(struct urb *urb) |
260 | { | 266 | { |
261 | struct usb_sg_request *io = urb->context; | 267 | struct usb_sg_request *io = urb->context; |
262 | int status = urb->status; | 268 | int status = urb->status; |
263 | 269 | ||
264 | spin_lock (&io->lock); | 270 | spin_lock(&io->lock); |
265 | 271 | ||
266 | /* In 2.5 we require hcds' endpoint queues not to progress after fault | 272 | /* In 2.5 we require hcds' endpoint queues not to progress after fault |
267 | * reports, until the completion callback (this!) returns. That lets | 273 | * reports, until the completion callback (this!) returns. That lets |
@@ -277,13 +283,13 @@ static void sg_complete (struct urb *urb) | |||
277 | && (io->status != -ECONNRESET | 283 | && (io->status != -ECONNRESET |
278 | || status != -ECONNRESET) | 284 | || status != -ECONNRESET) |
279 | && urb->actual_length) { | 285 | && urb->actual_length) { |
280 | dev_err (io->dev->bus->controller, | 286 | dev_err(io->dev->bus->controller, |
281 | "dev %s ep%d%s scatterlist error %d/%d\n", | 287 | "dev %s ep%d%s scatterlist error %d/%d\n", |
282 | io->dev->devpath, | 288 | io->dev->devpath, |
283 | usb_endpoint_num(&urb->ep->desc), | 289 | usb_endpoint_num(&urb->ep->desc), |
284 | usb_urb_dir_in(urb) ? "in" : "out", | 290 | usb_urb_dir_in(urb) ? "in" : "out", |
285 | status, io->status); | 291 | status, io->status); |
286 | // BUG (); | 292 | /* BUG (); */ |
287 | } | 293 | } |
288 | 294 | ||
289 | if (io->status == 0 && status && status != -ECONNRESET) { | 295 | if (io->status == 0 && status && status != -ECONNRESET) { |
@@ -295,22 +301,22 @@ static void sg_complete (struct urb *urb) | |||
295 | * unlink pending urbs so they won't rx/tx bad data. | 301 | * unlink pending urbs so they won't rx/tx bad data. |
296 | * careful: unlink can sometimes be synchronous... | 302 | * careful: unlink can sometimes be synchronous... |
297 | */ | 303 | */ |
298 | spin_unlock (&io->lock); | 304 | spin_unlock(&io->lock); |
299 | for (i = 0, found = 0; i < io->entries; i++) { | 305 | for (i = 0, found = 0; i < io->entries; i++) { |
300 | if (!io->urbs [i] || !io->urbs [i]->dev) | 306 | if (!io->urbs [i] || !io->urbs [i]->dev) |
301 | continue; | 307 | continue; |
302 | if (found) { | 308 | if (found) { |
303 | retval = usb_unlink_urb (io->urbs [i]); | 309 | retval = usb_unlink_urb(io->urbs [i]); |
304 | if (retval != -EINPROGRESS && | 310 | if (retval != -EINPROGRESS && |
305 | retval != -ENODEV && | 311 | retval != -ENODEV && |
306 | retval != -EBUSY) | 312 | retval != -EBUSY) |
307 | dev_err (&io->dev->dev, | 313 | dev_err(&io->dev->dev, |
308 | "%s, unlink --> %d\n", | 314 | "%s, unlink --> %d\n", |
309 | __FUNCTION__, retval); | 315 | __FUNCTION__, retval); |
310 | } else if (urb == io->urbs [i]) | 316 | } else if (urb == io->urbs [i]) |
311 | found = 1; | 317 | found = 1; |
312 | } | 318 | } |
313 | spin_lock (&io->lock); | 319 | spin_lock(&io->lock); |
314 | } | 320 | } |
315 | urb->dev = NULL; | 321 | urb->dev = NULL; |
316 | 322 | ||
@@ -318,9 +324,9 @@ static void sg_complete (struct urb *urb) | |||
318 | io->bytes += urb->actual_length; | 324 | io->bytes += urb->actual_length; |
319 | io->count--; | 325 | io->count--; |
320 | if (!io->count) | 326 | if (!io->count) |
321 | complete (&io->complete); | 327 | complete(&io->complete); |
322 | 328 | ||
323 | spin_unlock (&io->lock); | 329 | spin_unlock(&io->lock); |
324 | } | 330 | } |
325 | 331 | ||
326 | 332 | ||
@@ -349,28 +355,21 @@ static void sg_complete (struct urb *urb) | |||
349 | * The request may be canceled with usb_sg_cancel(), either before or after | 355 | * The request may be canceled with usb_sg_cancel(), either before or after |
350 | * usb_sg_wait() is called. | 356 | * usb_sg_wait() is called. |
351 | */ | 357 | */ |
352 | int usb_sg_init ( | 358 | int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, |
353 | struct usb_sg_request *io, | 359 | unsigned pipe, unsigned period, struct scatterlist *sg, |
354 | struct usb_device *dev, | 360 | int nents, size_t length, gfp_t mem_flags) |
355 | unsigned pipe, | ||
356 | unsigned period, | ||
357 | struct scatterlist *sg, | ||
358 | int nents, | ||
359 | size_t length, | ||
360 | gfp_t mem_flags | ||
361 | ) | ||
362 | { | 361 | { |
363 | int i; | 362 | int i; |
364 | int urb_flags; | 363 | int urb_flags; |
365 | int dma; | 364 | int dma; |
366 | 365 | ||
367 | if (!io || !dev || !sg | 366 | if (!io || !dev || !sg |
368 | || usb_pipecontrol (pipe) | 367 | || usb_pipecontrol(pipe) |
369 | || usb_pipeisoc (pipe) | 368 | || usb_pipeisoc(pipe) |
370 | || nents <= 0) | 369 | || nents <= 0) |
371 | return -EINVAL; | 370 | return -EINVAL; |
372 | 371 | ||
373 | spin_lock_init (&io->lock); | 372 | spin_lock_init(&io->lock); |
374 | io->dev = dev; | 373 | io->dev = dev; |
375 | io->pipe = pipe; | 374 | io->pipe = pipe; |
376 | io->sg = sg; | 375 | io->sg = sg; |
@@ -382,7 +381,7 @@ int usb_sg_init ( | |||
382 | dma = (dev->dev.dma_mask != NULL); | 381 | dma = (dev->dev.dma_mask != NULL); |
383 | if (dma) | 382 | if (dma) |
384 | io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), | 383 | io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), |
385 | sg, nents); | 384 | sg, nents); |
386 | else | 385 | else |
387 | io->entries = nents; | 386 | io->entries = nents; |
388 | 387 | ||
@@ -391,30 +390,30 @@ int usb_sg_init ( | |||
391 | return io->entries; | 390 | return io->entries; |
392 | 391 | ||
393 | io->count = io->entries; | 392 | io->count = io->entries; |
394 | io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags); | 393 | io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags); |
395 | if (!io->urbs) | 394 | if (!io->urbs) |
396 | goto nomem; | 395 | goto nomem; |
397 | 396 | ||
398 | urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; | 397 | urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; |
399 | if (usb_pipein (pipe)) | 398 | if (usb_pipein(pipe)) |
400 | urb_flags |= URB_SHORT_NOT_OK; | 399 | urb_flags |= URB_SHORT_NOT_OK; |
401 | 400 | ||
402 | for (i = 0; i < io->entries; i++) { | 401 | for (i = 0; i < io->entries; i++) { |
403 | unsigned len; | 402 | unsigned len; |
404 | 403 | ||
405 | io->urbs [i] = usb_alloc_urb (0, mem_flags); | 404 | io->urbs[i] = usb_alloc_urb(0, mem_flags); |
406 | if (!io->urbs [i]) { | 405 | if (!io->urbs[i]) { |
407 | io->entries = i; | 406 | io->entries = i; |
408 | goto nomem; | 407 | goto nomem; |
409 | } | 408 | } |
410 | 409 | ||
411 | io->urbs [i]->dev = NULL; | 410 | io->urbs[i]->dev = NULL; |
412 | io->urbs [i]->pipe = pipe; | 411 | io->urbs[i]->pipe = pipe; |
413 | io->urbs [i]->interval = period; | 412 | io->urbs[i]->interval = period; |
414 | io->urbs [i]->transfer_flags = urb_flags; | 413 | io->urbs[i]->transfer_flags = urb_flags; |
415 | 414 | ||
416 | io->urbs [i]->complete = sg_complete; | 415 | io->urbs[i]->complete = sg_complete; |
417 | io->urbs [i]->context = io; | 416 | io->urbs[i]->context = io; |
418 | 417 | ||
419 | /* | 418 | /* |
420 | * Some systems need to revert to PIO when DMA is temporarily | 419 | * Some systems need to revert to PIO when DMA is temporarily |
@@ -433,8 +432,8 @@ int usb_sg_init ( | |||
433 | * to prevent stale pointers and to help spot bugs. | 432 | * to prevent stale pointers and to help spot bugs. |
434 | */ | 433 | */ |
435 | if (dma) { | 434 | if (dma) { |
436 | io->urbs [i]->transfer_dma = sg_dma_address (sg + i); | 435 | io->urbs[i]->transfer_dma = sg_dma_address(sg + i); |
437 | len = sg_dma_len (sg + i); | 436 | len = sg_dma_len(sg + i); |
438 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) | 437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) |
439 | io->urbs[i]->transfer_buffer = NULL; | 438 | io->urbs[i]->transfer_buffer = NULL; |
440 | #else | 439 | #else |
@@ -442,28 +441,28 @@ int usb_sg_init ( | |||
442 | #endif | 441 | #endif |
443 | } else { | 442 | } else { |
444 | /* hc may use _only_ transfer_buffer */ | 443 | /* hc may use _only_ transfer_buffer */ |
445 | io->urbs [i]->transfer_buffer = sg_virt(&sg[i]); | 444 | io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); |
446 | len = sg [i].length; | 445 | len = sg[i].length; |
447 | } | 446 | } |
448 | 447 | ||
449 | if (length) { | 448 | if (length) { |
450 | len = min_t (unsigned, len, length); | 449 | len = min_t(unsigned, len, length); |
451 | length -= len; | 450 | length -= len; |
452 | if (length == 0) | 451 | if (length == 0) |
453 | io->entries = i + 1; | 452 | io->entries = i + 1; |
454 | } | 453 | } |
455 | io->urbs [i]->transfer_buffer_length = len; | 454 | io->urbs[i]->transfer_buffer_length = len; |
456 | } | 455 | } |
457 | io->urbs [--i]->transfer_flags &= ~URB_NO_INTERRUPT; | 456 | io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; |
458 | 457 | ||
459 | /* transaction state */ | 458 | /* transaction state */ |
460 | io->status = 0; | 459 | io->status = 0; |
461 | io->bytes = 0; | 460 | io->bytes = 0; |
462 | init_completion (&io->complete); | 461 | init_completion(&io->complete); |
463 | return 0; | 462 | return 0; |
464 | 463 | ||
465 | nomem: | 464 | nomem: |
466 | sg_clean (io); | 465 | sg_clean(io); |
467 | return -ENOMEM; | 466 | return -ENOMEM; |
468 | } | 467 | } |
469 | EXPORT_SYMBOL_GPL(usb_sg_init); | 468 | EXPORT_SYMBOL_GPL(usb_sg_init); |
@@ -507,31 +506,32 @@ EXPORT_SYMBOL_GPL(usb_sg_init); | |||
507 | * speed interrupt endpoints, which allow at most one packet per millisecond, | 506 | * speed interrupt endpoints, which allow at most one packet per millisecond, |
508 | * of at most 8 or 64 bytes (respectively). | 507 | * of at most 8 or 64 bytes (respectively). |
509 | */ | 508 | */ |
510 | void usb_sg_wait (struct usb_sg_request *io) | 509 | void usb_sg_wait(struct usb_sg_request *io) |
511 | { | 510 | { |
512 | int i, entries = io->entries; | 511 | int i; |
512 | int entries = io->entries; | ||
513 | 513 | ||
514 | /* queue the urbs. */ | 514 | /* queue the urbs. */ |
515 | spin_lock_irq (&io->lock); | 515 | spin_lock_irq(&io->lock); |
516 | i = 0; | 516 | i = 0; |
517 | while (i < entries && !io->status) { | 517 | while (i < entries && !io->status) { |
518 | int retval; | 518 | int retval; |
519 | 519 | ||
520 | io->urbs [i]->dev = io->dev; | 520 | io->urbs[i]->dev = io->dev; |
521 | retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC); | 521 | retval = usb_submit_urb(io->urbs [i], GFP_ATOMIC); |
522 | 522 | ||
523 | /* after we submit, let completions or cancelations fire; | 523 | /* after we submit, let completions or cancelations fire; |
524 | * we handshake using io->status. | 524 | * we handshake using io->status. |
525 | */ | 525 | */ |
526 | spin_unlock_irq (&io->lock); | 526 | spin_unlock_irq(&io->lock); |
527 | switch (retval) { | 527 | switch (retval) { |
528 | /* maybe we retrying will recover */ | 528 | /* maybe we retrying will recover */ |
529 | case -ENXIO: // hc didn't queue this one | 529 | case -ENXIO: /* hc didn't queue this one */ |
530 | case -EAGAIN: | 530 | case -EAGAIN: |
531 | case -ENOMEM: | 531 | case -ENOMEM: |
532 | io->urbs[i]->dev = NULL; | 532 | io->urbs[i]->dev = NULL; |
533 | retval = 0; | 533 | retval = 0; |
534 | yield (); | 534 | yield(); |
535 | break; | 535 | break; |
536 | 536 | ||
537 | /* no error? continue immediately. | 537 | /* no error? continue immediately. |
@@ -542,33 +542,33 @@ void usb_sg_wait (struct usb_sg_request *io) | |||
542 | */ | 542 | */ |
543 | case 0: | 543 | case 0: |
544 | ++i; | 544 | ++i; |
545 | cpu_relax (); | 545 | cpu_relax(); |
546 | break; | 546 | break; |
547 | 547 | ||
548 | /* fail any uncompleted urbs */ | 548 | /* fail any uncompleted urbs */ |
549 | default: | 549 | default: |
550 | io->urbs [i]->dev = NULL; | 550 | io->urbs[i]->dev = NULL; |
551 | io->urbs [i]->status = retval; | 551 | io->urbs[i]->status = retval; |
552 | dev_dbg (&io->dev->dev, "%s, submit --> %d\n", | 552 | dev_dbg(&io->dev->dev, "%s, submit --> %d\n", |
553 | __FUNCTION__, retval); | 553 | __FUNCTION__, retval); |
554 | usb_sg_cancel (io); | 554 | usb_sg_cancel(io); |
555 | } | 555 | } |
556 | spin_lock_irq (&io->lock); | 556 | spin_lock_irq(&io->lock); |
557 | if (retval && (io->status == 0 || io->status == -ECONNRESET)) | 557 | if (retval && (io->status == 0 || io->status == -ECONNRESET)) |
558 | io->status = retval; | 558 | io->status = retval; |
559 | } | 559 | } |
560 | io->count -= entries - i; | 560 | io->count -= entries - i; |
561 | if (io->count == 0) | 561 | if (io->count == 0) |
562 | complete (&io->complete); | 562 | complete(&io->complete); |
563 | spin_unlock_irq (&io->lock); | 563 | spin_unlock_irq(&io->lock); |
564 | 564 | ||
565 | /* OK, yes, this could be packaged as non-blocking. | 565 | /* OK, yes, this could be packaged as non-blocking. |
566 | * So could the submit loop above ... but it's easier to | 566 | * So could the submit loop above ... but it's easier to |
567 | * solve neither problem than to solve both! | 567 | * solve neither problem than to solve both! |
568 | */ | 568 | */ |
569 | wait_for_completion (&io->complete); | 569 | wait_for_completion(&io->complete); |
570 | 570 | ||
571 | sg_clean (io); | 571 | sg_clean(io); |
572 | } | 572 | } |
573 | EXPORT_SYMBOL_GPL(usb_sg_wait); | 573 | EXPORT_SYMBOL_GPL(usb_sg_wait); |
574 | 574 | ||
@@ -580,31 +580,31 @@ EXPORT_SYMBOL_GPL(usb_sg_wait); | |||
580 | * It can also prevents one initialized by usb_sg_init() from starting, | 580 | * It can also prevents one initialized by usb_sg_init() from starting, |
581 | * so that call just frees resources allocated to the request. | 581 | * so that call just frees resources allocated to the request. |
582 | */ | 582 | */ |
583 | void usb_sg_cancel (struct usb_sg_request *io) | 583 | void usb_sg_cancel(struct usb_sg_request *io) |
584 | { | 584 | { |
585 | unsigned long flags; | 585 | unsigned long flags; |
586 | 586 | ||
587 | spin_lock_irqsave (&io->lock, flags); | 587 | spin_lock_irqsave(&io->lock, flags); |
588 | 588 | ||
589 | /* shut everything down, if it didn't already */ | 589 | /* shut everything down, if it didn't already */ |
590 | if (!io->status) { | 590 | if (!io->status) { |
591 | int i; | 591 | int i; |
592 | 592 | ||
593 | io->status = -ECONNRESET; | 593 | io->status = -ECONNRESET; |
594 | spin_unlock (&io->lock); | 594 | spin_unlock(&io->lock); |
595 | for (i = 0; i < io->entries; i++) { | 595 | for (i = 0; i < io->entries; i++) { |
596 | int retval; | 596 | int retval; |
597 | 597 | ||
598 | if (!io->urbs [i]->dev) | 598 | if (!io->urbs [i]->dev) |
599 | continue; | 599 | continue; |
600 | retval = usb_unlink_urb (io->urbs [i]); | 600 | retval = usb_unlink_urb(io->urbs [i]); |
601 | if (retval != -EINPROGRESS && retval != -EBUSY) | 601 | if (retval != -EINPROGRESS && retval != -EBUSY) |
602 | dev_warn (&io->dev->dev, "%s, unlink --> %d\n", | 602 | dev_warn(&io->dev->dev, "%s, unlink --> %d\n", |
603 | __FUNCTION__, retval); | 603 | __FUNCTION__, retval); |
604 | } | 604 | } |
605 | spin_lock (&io->lock); | 605 | spin_lock(&io->lock); |
606 | } | 606 | } |
607 | spin_unlock_irqrestore (&io->lock, flags); | 607 | spin_unlock_irqrestore(&io->lock, flags); |
608 | } | 608 | } |
609 | EXPORT_SYMBOL_GPL(usb_sg_cancel); | 609 | EXPORT_SYMBOL_GPL(usb_sg_cancel); |
610 | 610 | ||
@@ -632,12 +632,13 @@ EXPORT_SYMBOL_GPL(usb_sg_cancel); | |||
632 | * Returns the number of bytes received on success, or else the status code | 632 | * Returns the number of bytes received on success, or else the status code |
633 | * returned by the underlying usb_control_msg() call. | 633 | * returned by the underlying usb_control_msg() call. |
634 | */ | 634 | */ |
635 | int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size) | 635 | int usb_get_descriptor(struct usb_device *dev, unsigned char type, |
636 | unsigned char index, void *buf, int size) | ||
636 | { | 637 | { |
637 | int i; | 638 | int i; |
638 | int result; | 639 | int result; |
639 | 640 | ||
640 | memset(buf,0,size); // Make sure we parse really received data | 641 | memset(buf, 0, size); /* Make sure we parse really received data */ |
641 | 642 | ||
642 | for (i = 0; i < 3; ++i) { | 643 | for (i = 0; i < 3; ++i) { |
643 | /* retry on length 0 or error; some devices are flakey */ | 644 | /* retry on length 0 or error; some devices are flakey */ |
@@ -712,7 +713,7 @@ static void usb_try_string_workarounds(unsigned char *buf, int *length) | |||
712 | } | 713 | } |
713 | 714 | ||
714 | static int usb_string_sub(struct usb_device *dev, unsigned int langid, | 715 | static int usb_string_sub(struct usb_device *dev, unsigned int langid, |
715 | unsigned int index, unsigned char *buf) | 716 | unsigned int index, unsigned char *buf) |
716 | { | 717 | { |
717 | int rc; | 718 | int rc; |
718 | 719 | ||
@@ -755,7 +756,7 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid, | |||
755 | * @buf: where to put the string | 756 | * @buf: where to put the string |
756 | * @size: how big is "buf"? | 757 | * @size: how big is "buf"? |
757 | * Context: !in_interrupt () | 758 | * Context: !in_interrupt () |
758 | * | 759 | * |
759 | * This converts the UTF-16LE encoded strings returned by devices, from | 760 | * This converts the UTF-16LE encoded strings returned by devices, from |
760 | * usb_get_string_descriptor(), to null-terminated ISO-8859-1 encoded ones | 761 | * usb_get_string_descriptor(), to null-terminated ISO-8859-1 encoded ones |
761 | * that are more usable in most kernel contexts. Note that all characters | 762 | * that are more usable in most kernel contexts. Note that all characters |
@@ -791,23 +792,23 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | |||
791 | if (!dev->have_langid) { | 792 | if (!dev->have_langid) { |
792 | err = usb_string_sub(dev, 0, 0, tbuf); | 793 | err = usb_string_sub(dev, 0, 0, tbuf); |
793 | if (err < 0) { | 794 | if (err < 0) { |
794 | dev_err (&dev->dev, | 795 | dev_err(&dev->dev, |
795 | "string descriptor 0 read error: %d\n", | 796 | "string descriptor 0 read error: %d\n", |
796 | err); | 797 | err); |
797 | goto errout; | 798 | goto errout; |
798 | } else if (err < 4) { | 799 | } else if (err < 4) { |
799 | dev_err (&dev->dev, "string descriptor 0 too short\n"); | 800 | dev_err(&dev->dev, "string descriptor 0 too short\n"); |
800 | err = -EINVAL; | 801 | err = -EINVAL; |
801 | goto errout; | 802 | goto errout; |
802 | } else { | 803 | } else { |
803 | dev->have_langid = 1; | 804 | dev->have_langid = 1; |
804 | dev->string_langid = tbuf[2] | (tbuf[3]<< 8); | 805 | dev->string_langid = tbuf[2] | (tbuf[3] << 8); |
805 | /* always use the first langid listed */ | 806 | /* always use the first langid listed */ |
806 | dev_dbg (&dev->dev, "default language 0x%04x\n", | 807 | dev_dbg(&dev->dev, "default language 0x%04x\n", |
807 | dev->string_langid); | 808 | dev->string_langid); |
808 | } | 809 | } |
809 | } | 810 | } |
810 | 811 | ||
811 | err = usb_string_sub(dev, dev->string_langid, index, tbuf); | 812 | err = usb_string_sub(dev, dev->string_langid, index, tbuf); |
812 | if (err < 0) | 813 | if (err < 0) |
813 | goto errout; | 814 | goto errout; |
@@ -825,7 +826,9 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | |||
825 | err = idx; | 826 | err = idx; |
826 | 827 | ||
827 | if (tbuf[1] != USB_DT_STRING) | 828 | if (tbuf[1] != USB_DT_STRING) |
828 | dev_dbg(&dev->dev, "wrong descriptor type %02x for string %d (\"%s\")\n", tbuf[1], index, buf); | 829 | dev_dbg(&dev->dev, |
830 | "wrong descriptor type %02x for string %d (\"%s\")\n", | ||
831 | tbuf[1], index, buf); | ||
829 | 832 | ||
830 | errout: | 833 | errout: |
831 | kfree(tbuf); | 834 | kfree(tbuf); |
@@ -847,9 +850,15 @@ char *usb_cache_string(struct usb_device *udev, int index) | |||
847 | char *smallbuf = NULL; | 850 | char *smallbuf = NULL; |
848 | int len; | 851 | int len; |
849 | 852 | ||
850 | if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) { | 853 | if (index <= 0) |
851 | if ((len = usb_string(udev, index, buf, 256)) > 0) { | 854 | return NULL; |
852 | if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == NULL) | 855 | |
856 | buf = kmalloc(256, GFP_KERNEL); | ||
857 | if (buf) { | ||
858 | len = usb_string(udev, index, buf, 256); | ||
859 | if (len > 0) { | ||
860 | smallbuf = kmalloc(++len, GFP_KERNEL); | ||
861 | if (!smallbuf) | ||
853 | return buf; | 862 | return buf; |
854 | memcpy(smallbuf, buf, len); | 863 | memcpy(smallbuf, buf, len); |
855 | } | 864 | } |
@@ -888,7 +897,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size) | |||
888 | return -ENOMEM; | 897 | return -ENOMEM; |
889 | 898 | ||
890 | ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); | 899 | ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); |
891 | if (ret >= 0) | 900 | if (ret >= 0) |
892 | memcpy(&dev->descriptor, desc, size); | 901 | memcpy(&dev->descriptor, desc, size); |
893 | kfree(desc); | 902 | kfree(desc); |
894 | return ret; | 903 | return ret; |
@@ -961,8 +970,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe) | |||
961 | { | 970 | { |
962 | int result; | 971 | int result; |
963 | int endp = usb_pipeendpoint(pipe); | 972 | int endp = usb_pipeendpoint(pipe); |
964 | 973 | ||
965 | if (usb_pipein (pipe)) | 974 | if (usb_pipein(pipe)) |
966 | endp |= USB_DIR_IN; | 975 | endp |= USB_DIR_IN; |
967 | 976 | ||
968 | /* we don't care if it wasn't halted first. in fact some devices | 977 | /* we don't care if it wasn't halted first. in fact some devices |
@@ -1045,7 +1054,7 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf) | |||
1045 | } | 1054 | } |
1046 | } | 1055 | } |
1047 | 1056 | ||
1048 | /* | 1057 | /** |
1049 | * usb_disable_device - Disable all the endpoints for a USB device | 1058 | * usb_disable_device - Disable all the endpoints for a USB device |
1050 | * @dev: the device whose endpoints are being disabled | 1059 | * @dev: the device whose endpoints are being disabled |
1051 | * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. | 1060 | * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. |
@@ -1060,7 +1069,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1060 | int i; | 1069 | int i; |
1061 | 1070 | ||
1062 | dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, | 1071 | dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, |
1063 | skip_ep0 ? "non-ep0" : "all"); | 1072 | skip_ep0 ? "non-ep0" : "all"); |
1064 | for (i = skip_ep0; i < 16; ++i) { | 1073 | for (i = skip_ep0; i < 16; ++i) { |
1065 | usb_disable_endpoint(dev, i); | 1074 | usb_disable_endpoint(dev, i); |
1066 | usb_disable_endpoint(dev, i + USB_DIR_IN); | 1075 | usb_disable_endpoint(dev, i + USB_DIR_IN); |
@@ -1078,17 +1087,17 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1078 | interface = dev->actconfig->interface[i]; | 1087 | interface = dev->actconfig->interface[i]; |
1079 | if (!device_is_registered(&interface->dev)) | 1088 | if (!device_is_registered(&interface->dev)) |
1080 | continue; | 1089 | continue; |
1081 | dev_dbg (&dev->dev, "unregistering interface %s\n", | 1090 | dev_dbg(&dev->dev, "unregistering interface %s\n", |
1082 | interface->dev.bus_id); | 1091 | interface->dev.bus_id); |
1083 | usb_remove_sysfs_intf_files(interface); | 1092 | usb_remove_sysfs_intf_files(interface); |
1084 | device_del (&interface->dev); | 1093 | device_del(&interface->dev); |
1085 | } | 1094 | } |
1086 | 1095 | ||
1087 | /* Now that the interfaces are unbound, nobody should | 1096 | /* Now that the interfaces are unbound, nobody should |
1088 | * try to access them. | 1097 | * try to access them. |
1089 | */ | 1098 | */ |
1090 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { | 1099 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { |
1091 | put_device (&dev->actconfig->interface[i]->dev); | 1100 | put_device(&dev->actconfig->interface[i]->dev); |
1092 | dev->actconfig->interface[i] = NULL; | 1101 | dev->actconfig->interface[i] = NULL; |
1093 | } | 1102 | } |
1094 | dev->actconfig = NULL; | 1103 | dev->actconfig = NULL; |
@@ -1097,8 +1106,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1097 | } | 1106 | } |
1098 | } | 1107 | } |
1099 | 1108 | ||
1100 | 1109 | /** | |
1101 | /* | ||
1102 | * usb_enable_endpoint - Enable an endpoint for USB communications | 1110 | * usb_enable_endpoint - Enable an endpoint for USB communications |
1103 | * @dev: the device whose interface is being enabled | 1111 | * @dev: the device whose interface is being enabled |
1104 | * @ep: the endpoint | 1112 | * @ep: the endpoint |
@@ -1123,7 +1131,7 @@ void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep) | |||
1123 | ep->enabled = 1; | 1131 | ep->enabled = 1; |
1124 | } | 1132 | } |
1125 | 1133 | ||
1126 | /* | 1134 | /** |
1127 | * usb_enable_interface - Enable all the endpoints for an interface | 1135 | * usb_enable_interface - Enable all the endpoints for an interface |
1128 | * @dev: the device whose interface is being enabled | 1136 | * @dev: the device whose interface is being enabled |
1129 | * @intf: pointer to the interface descriptor | 1137 | * @intf: pointer to the interface descriptor |
@@ -1179,6 +1187,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1179 | struct usb_host_interface *alt; | 1187 | struct usb_host_interface *alt; |
1180 | int ret; | 1188 | int ret; |
1181 | int manual = 0; | 1189 | int manual = 0; |
1190 | unsigned int epaddr; | ||
1191 | unsigned int pipe; | ||
1182 | 1192 | ||
1183 | if (dev->state == USB_STATE_SUSPENDED) | 1193 | if (dev->state == USB_STATE_SUSPENDED) |
1184 | return -EHOSTUNREACH; | 1194 | return -EHOSTUNREACH; |
@@ -1233,11 +1243,11 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1233 | int i; | 1243 | int i; |
1234 | 1244 | ||
1235 | for (i = 0; i < alt->desc.bNumEndpoints; i++) { | 1245 | for (i = 0; i < alt->desc.bNumEndpoints; i++) { |
1236 | unsigned int epaddr = | 1246 | epaddr = alt->endpoint[i].desc.bEndpointAddress; |
1237 | alt->endpoint[i].desc.bEndpointAddress; | 1247 | pipe = __create_pipe(dev, |
1238 | unsigned int pipe = | 1248 | USB_ENDPOINT_NUMBER_MASK & epaddr) | |
1239 | __create_pipe(dev, USB_ENDPOINT_NUMBER_MASK & epaddr) | 1249 | (usb_endpoint_out(epaddr) ? |
1240 | | (usb_endpoint_out(epaddr) ? USB_DIR_OUT : USB_DIR_IN); | 1250 | USB_DIR_OUT : USB_DIR_IN); |
1241 | 1251 | ||
1242 | usb_clear_halt(dev, pipe); | 1252 | usb_clear_halt(dev, pipe); |
1243 | } | 1253 | } |
@@ -1366,7 +1376,8 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
1366 | return -ENOMEM; | 1376 | return -ENOMEM; |
1367 | 1377 | ||
1368 | if (add_uevent_var(env, | 1378 | if (add_uevent_var(env, |
1369 | "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", | 1379 | "MODALIAS=usb:" |
1380 | "v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", | ||
1370 | le16_to_cpu(usb_dev->descriptor.idVendor), | 1381 | le16_to_cpu(usb_dev->descriptor.idVendor), |
1371 | le16_to_cpu(usb_dev->descriptor.idProduct), | 1382 | le16_to_cpu(usb_dev->descriptor.idProduct), |
1372 | le16_to_cpu(usb_dev->descriptor.bcdDevice), | 1383 | le16_to_cpu(usb_dev->descriptor.bcdDevice), |
@@ -1396,8 +1407,8 @@ struct device_type usb_if_device_type = { | |||
1396 | }; | 1407 | }; |
1397 | 1408 | ||
1398 | static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, | 1409 | static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, |
1399 | struct usb_host_config *config, | 1410 | struct usb_host_config *config, |
1400 | u8 inum) | 1411 | u8 inum) |
1401 | { | 1412 | { |
1402 | struct usb_interface_assoc_descriptor *retval = NULL; | 1413 | struct usb_interface_assoc_descriptor *retval = NULL; |
1403 | struct usb_interface_assoc_descriptor *intf_assoc; | 1414 | struct usb_interface_assoc_descriptor *intf_assoc; |
@@ -1424,7 +1435,6 @@ static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, | |||
1424 | return retval; | 1435 | return retval; |
1425 | } | 1436 | } |
1426 | 1437 | ||
1427 | |||
1428 | /* | 1438 | /* |
1429 | * usb_set_configuration - Makes a particular device setting be current | 1439 | * usb_set_configuration - Makes a particular device setting be current |
1430 | * @dev: the device whose configuration is being updated | 1440 | * @dev: the device whose configuration is being updated |
@@ -1542,12 +1552,12 @@ free_interfaces: | |||
1542 | * getting rid of old interfaces means unbinding their drivers. | 1552 | * getting rid of old interfaces means unbinding their drivers. |
1543 | */ | 1553 | */ |
1544 | if (dev->state != USB_STATE_ADDRESS) | 1554 | if (dev->state != USB_STATE_ADDRESS) |
1545 | usb_disable_device (dev, 1); // Skip ep0 | 1555 | usb_disable_device(dev, 1); /* Skip ep0 */ |
1546 | |||
1547 | if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
1548 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | ||
1549 | NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) { | ||
1550 | 1556 | ||
1557 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
1558 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | ||
1559 | NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
1560 | if (ret < 0) { | ||
1551 | /* All the old state is gone, so what else can we do? | 1561 | /* All the old state is gone, so what else can we do? |
1552 | * The device is probably useless now anyway. | 1562 | * The device is probably useless now anyway. |
1553 | */ | 1563 | */ |
@@ -1594,11 +1604,11 @@ free_interfaces: | |||
1594 | intf->dev.bus = &usb_bus_type; | 1604 | intf->dev.bus = &usb_bus_type; |
1595 | intf->dev.type = &usb_if_device_type; | 1605 | intf->dev.type = &usb_if_device_type; |
1596 | intf->dev.dma_mask = dev->dev.dma_mask; | 1606 | intf->dev.dma_mask = dev->dev.dma_mask; |
1597 | device_initialize (&intf->dev); | 1607 | device_initialize(&intf->dev); |
1598 | mark_quiesced(intf); | 1608 | mark_quiesced(intf); |
1599 | sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d", | 1609 | sprintf(&intf->dev.bus_id[0], "%d-%s:%d.%d", |
1600 | dev->bus->busnum, dev->devpath, | 1610 | dev->bus->busnum, dev->devpath, |
1601 | configuration, alt->desc.bInterfaceNumber); | 1611 | configuration, alt->desc.bInterfaceNumber); |
1602 | } | 1612 | } |
1603 | kfree(new_interfaces); | 1613 | kfree(new_interfaces); |
1604 | 1614 | ||
@@ -1614,11 +1624,11 @@ free_interfaces: | |||
1614 | for (i = 0; i < nintf; ++i) { | 1624 | for (i = 0; i < nintf; ++i) { |
1615 | struct usb_interface *intf = cp->interface[i]; | 1625 | struct usb_interface *intf = cp->interface[i]; |
1616 | 1626 | ||
1617 | dev_dbg (&dev->dev, | 1627 | dev_dbg(&dev->dev, |
1618 | "adding %s (config #%d, interface %d)\n", | 1628 | "adding %s (config #%d, interface %d)\n", |
1619 | intf->dev.bus_id, configuration, | 1629 | intf->dev.bus_id, configuration, |
1620 | intf->cur_altsetting->desc.bInterfaceNumber); | 1630 | intf->cur_altsetting->desc.bInterfaceNumber); |
1621 | ret = device_add (&intf->dev); | 1631 | ret = device_add(&intf->dev); |
1622 | if (ret != 0) { | 1632 | if (ret != 0) { |
1623 | dev_err(&dev->dev, "device_add(%s) --> %d\n", | 1633 | dev_err(&dev->dev, "device_add(%s) --> %d\n", |
1624 | intf->dev.bus_id, ret); | 1634 | intf->dev.bus_id, ret); |