diff options
Diffstat (limited to 'drivers/usb/core')
-rw-r--r-- | drivers/usb/core/Kconfig | 15 | ||||
-rw-r--r-- | drivers/usb/core/buffer.c | 20 | ||||
-rw-r--r-- | drivers/usb/core/config.c | 14 | ||||
-rw-r--r-- | drivers/usb/core/devices.c | 154 | ||||
-rw-r--r-- | drivers/usb/core/devio.c | 359 | ||||
-rw-r--r-- | drivers/usb/core/driver.c | 44 | ||||
-rw-r--r-- | drivers/usb/core/file.c | 4 | ||||
-rw-r--r-- | drivers/usb/core/hcd-pci.c | 145 | ||||
-rw-r--r-- | drivers/usb/core/hcd.c | 216 | ||||
-rw-r--r-- | drivers/usb/core/hcd.h | 92 | ||||
-rw-r--r-- | drivers/usb/core/hub.c | 88 | ||||
-rw-r--r-- | drivers/usb/core/hub.h | 18 | ||||
-rw-r--r-- | drivers/usb/core/inode.c | 42 | ||||
-rw-r--r-- | drivers/usb/core/message.c | 430 | ||||
-rw-r--r-- | drivers/usb/core/notify.c | 2 | ||||
-rw-r--r-- | drivers/usb/core/otg_whitelist.h | 6 | ||||
-rw-r--r-- | drivers/usb/core/sysfs.c | 69 | ||||
-rw-r--r-- | drivers/usb/core/urb.c | 37 | ||||
-rw-r--r-- | drivers/usb/core/usb.c | 117 | ||||
-rw-r--r-- | drivers/usb/core/usb.h | 21 |
20 files changed, 1099 insertions, 794 deletions
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index 97b09f282705..5c33cdb9cac7 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig | |||
@@ -9,6 +9,21 @@ config USB_DEBUG | |||
9 | of debug messages to the system log. Select this if you are having a | 9 | of debug messages to the system log. Select this if you are having a |
10 | problem with USB support and want to see more of what is going on. | 10 | problem with USB support and want to see more of what is going on. |
11 | 11 | ||
12 | config USB_ANNOUNCE_NEW_DEVICES | ||
13 | bool "USB announce new devices" | ||
14 | depends on USB | ||
15 | default N | ||
16 | help | ||
17 | Say Y here if you want the USB core to always announce the | ||
18 | idVendor, idProduct, Manufacturer, Product, and SerialNumber | ||
19 | strings for every new USB device to the syslog. This option is | ||
20 | usually used by distro vendors to help with debugging and to | ||
21 | let users know what specific device was added to the machine | ||
22 | in what location. | ||
23 | |||
24 | If you do not want this kind of information sent to the system | ||
25 | log, or have any doubts about this, say N here. | ||
26 | |||
12 | comment "Miscellaneous USB options" | 27 | comment "Miscellaneous USB options" |
13 | depends on USB | 28 | depends on USB |
14 | 29 | ||
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index 28d4972f7ad5..cadb2dc1d28a 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c | |||
@@ -53,11 +53,13 @@ int hcd_buffer_create(struct usb_hcd *hcd) | |||
53 | char name[16]; | 53 | char name[16]; |
54 | int i, size; | 54 | int i, size; |
55 | 55 | ||
56 | if (!hcd->self.controller->dma_mask) | 56 | if (!hcd->self.controller->dma_mask && |
57 | !(hcd->driver->flags & HCD_LOCAL_MEM)) | ||
57 | return 0; | 58 | return 0; |
58 | 59 | ||
59 | for (i = 0; i < HCD_BUFFER_POOLS; i++) { | 60 | for (i = 0; i < HCD_BUFFER_POOLS; i++) { |
60 | if (!(size = pool_max [i])) | 61 | size = pool_max[i]; |
62 | if (!size) | ||
61 | continue; | 63 | continue; |
62 | snprintf(name, sizeof name, "buffer-%d", size); | 64 | snprintf(name, sizeof name, "buffer-%d", size); |
63 | hcd->pool[i] = dma_pool_create(name, hcd->self.controller, | 65 | hcd->pool[i] = dma_pool_create(name, hcd->self.controller, |
@@ -80,10 +82,10 @@ int hcd_buffer_create(struct usb_hcd *hcd) | |||
80 | */ | 82 | */ |
81 | void hcd_buffer_destroy(struct usb_hcd *hcd) | 83 | void hcd_buffer_destroy(struct usb_hcd *hcd) |
82 | { | 84 | { |
83 | int i; | 85 | int i; |
84 | 86 | ||
85 | for (i = 0; i < HCD_BUFFER_POOLS; i++) { | 87 | for (i = 0; i < HCD_BUFFER_POOLS; i++) { |
86 | struct dma_pool *pool = hcd->pool[i]; | 88 | struct dma_pool *pool = hcd->pool[i]; |
87 | if (pool) { | 89 | if (pool) { |
88 | dma_pool_destroy(pool); | 90 | dma_pool_destroy(pool); |
89 | hcd->pool[i] = NULL; | 91 | hcd->pool[i] = NULL; |
@@ -107,7 +109,8 @@ void *hcd_buffer_alloc( | |||
107 | int i; | 109 | int i; |
108 | 110 | ||
109 | /* some USB hosts just use PIO */ | 111 | /* some USB hosts just use PIO */ |
110 | if (!bus->controller->dma_mask) { | 112 | if (!bus->controller->dma_mask && |
113 | !(hcd->driver->flags & HCD_LOCAL_MEM)) { | ||
111 | *dma = ~(dma_addr_t) 0; | 114 | *dma = ~(dma_addr_t) 0; |
112 | return kmalloc(size, mem_flags); | 115 | return kmalloc(size, mem_flags); |
113 | } | 116 | } |
@@ -132,7 +135,8 @@ void hcd_buffer_free( | |||
132 | if (!addr) | 135 | if (!addr) |
133 | return; | 136 | return; |
134 | 137 | ||
135 | if (!bus->controller->dma_mask) { | 138 | if (!bus->controller->dma_mask && |
139 | !(hcd->driver->flags & HCD_LOCAL_MEM)) { | ||
136 | kfree(addr); | 140 | kfree(addr); |
137 | return; | 141 | return; |
138 | } | 142 | } |
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 1a8edcee7f30..a92122a216bc 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c | |||
@@ -238,7 +238,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno, | |||
238 | 238 | ||
239 | /* Allocate space for the right(?) number of endpoints */ | 239 | /* Allocate space for the right(?) number of endpoints */ |
240 | num_ep = num_ep_orig = alt->desc.bNumEndpoints; | 240 | num_ep = num_ep_orig = alt->desc.bNumEndpoints; |
241 | alt->desc.bNumEndpoints = 0; // Use as a counter | 241 | alt->desc.bNumEndpoints = 0; /* Use as a counter */ |
242 | if (num_ep > USB_MAXENDPOINTS) { | 242 | if (num_ep > USB_MAXENDPOINTS) { |
243 | dev_warn(ddev, "too many endpoints for config %d interface %d " | 243 | dev_warn(ddev, "too many endpoints for config %d interface %d " |
244 | "altsetting %d: %d, using maximum allowed: %d\n", | 244 | "altsetting %d: %d, using maximum allowed: %d\n", |
@@ -246,7 +246,8 @@ static int usb_parse_interface(struct device *ddev, int cfgno, | |||
246 | num_ep = USB_MAXENDPOINTS; | 246 | num_ep = USB_MAXENDPOINTS; |
247 | } | 247 | } |
248 | 248 | ||
249 | if (num_ep > 0) { /* Can't allocate 0 bytes */ | 249 | if (num_ep > 0) { |
250 | /* Can't allocate 0 bytes */ | ||
250 | len = sizeof(struct usb_host_endpoint) * num_ep; | 251 | len = sizeof(struct usb_host_endpoint) * num_ep; |
251 | alt->endpoint = kzalloc(len, GFP_KERNEL); | 252 | alt->endpoint = kzalloc(len, GFP_KERNEL); |
252 | if (!alt->endpoint) | 253 | if (!alt->endpoint) |
@@ -475,8 +476,9 @@ static int usb_parse_configuration(struct device *ddev, int cfgidx, | |||
475 | return 0; | 476 | return 0; |
476 | } | 477 | } |
477 | 478 | ||
478 | // hub-only!! ... and only exported for reset/reinit path. | 479 | /* hub-only!! ... and only exported for reset/reinit path. |
479 | // otherwise used internally on disconnect/destroy path | 480 | * otherwise used internally on disconnect/destroy path |
481 | */ | ||
480 | void usb_destroy_configuration(struct usb_device *dev) | 482 | void usb_destroy_configuration(struct usb_device *dev) |
481 | { | 483 | { |
482 | int c, i; | 484 | int c, i; |
@@ -498,7 +500,7 @@ void usb_destroy_configuration(struct usb_device *dev) | |||
498 | kfree(cf->string); | 500 | kfree(cf->string); |
499 | for (i = 0; i < cf->desc.bNumInterfaces; i++) { | 501 | for (i = 0; i < cf->desc.bNumInterfaces; i++) { |
500 | if (cf->intf_cache[i]) | 502 | if (cf->intf_cache[i]) |
501 | kref_put(&cf->intf_cache[i]->ref, | 503 | kref_put(&cf->intf_cache[i]->ref, |
502 | usb_release_interface_cache); | 504 | usb_release_interface_cache); |
503 | } | 505 | } |
504 | } | 506 | } |
@@ -525,7 +527,7 @@ int usb_get_configuration(struct usb_device *dev) | |||
525 | unsigned int cfgno, length; | 527 | unsigned int cfgno, length; |
526 | unsigned char *buffer; | 528 | unsigned char *buffer; |
527 | unsigned char *bigbuffer; | 529 | unsigned char *bigbuffer; |
528 | struct usb_config_descriptor *desc; | 530 | struct usb_config_descriptor *desc; |
529 | 531 | ||
530 | cfgno = 0; | 532 | cfgno = 0; |
531 | if (dev->authorized == 0) /* Not really an error */ | 533 | if (dev->authorized == 0) /* Not really an error */ |
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 87c794d60aa0..83d9dc379d96 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c | |||
@@ -89,7 +89,7 @@ static const char *format_string_serialnumber = | |||
89 | static const char *format_bandwidth = | 89 | static const char *format_bandwidth = |
90 | /* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ | 90 | /* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ |
91 | "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; | 91 | "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; |
92 | 92 | ||
93 | static const char *format_device1 = | 93 | static const char *format_device1 = |
94 | /* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ | 94 | /* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ |
95 | "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; | 95 | "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; |
@@ -101,7 +101,7 @@ static const char *format_device2 = | |||
101 | static const char *format_config = | 101 | static const char *format_config = |
102 | /* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ | 102 | /* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ |
103 | "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; | 103 | "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; |
104 | 104 | ||
105 | static const char *format_iad = | 105 | static const char *format_iad = |
106 | /* A: FirstIf#=dd IfCount=dd Cls=xx(sssss) Sub=xx Prot=xx */ | 106 | /* A: FirstIf#=dd IfCount=dd Cls=xx(sssss) Sub=xx Prot=xx */ |
107 | "A: FirstIf#=%2d IfCount=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x\n"; | 107 | "A: FirstIf#=%2d IfCount=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x\n"; |
@@ -122,7 +122,7 @@ static const char *format_endpt = | |||
122 | */ | 122 | */ |
123 | 123 | ||
124 | static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); | 124 | static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); |
125 | static unsigned int conndiscevcnt = 0; | 125 | static unsigned int conndiscevcnt; |
126 | 126 | ||
127 | /* this struct stores the poll state for <mountpoint>/devices pollers */ | 127 | /* this struct stores the poll state for <mountpoint>/devices pollers */ |
128 | struct usb_device_status { | 128 | struct usb_device_status { |
@@ -172,12 +172,8 @@ static const char *class_decode(const int class) | |||
172 | return clas_info[ix].class_name; | 172 | return clas_info[ix].class_name; |
173 | } | 173 | } |
174 | 174 | ||
175 | static char *usb_dump_endpoint_descriptor( | 175 | static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, |
176 | int speed, | 176 | const struct usb_endpoint_descriptor *desc) |
177 | char *start, | ||
178 | char *end, | ||
179 | const struct usb_endpoint_descriptor *desc | ||
180 | ) | ||
181 | { | 177 | { |
182 | char dir, unit, *type; | 178 | char dir, unit, *type; |
183 | unsigned interval, bandwidth = 1; | 179 | unsigned interval, bandwidth = 1; |
@@ -235,22 +231,24 @@ static char *usb_dump_endpoint_descriptor( | |||
235 | 231 | ||
236 | start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, | 232 | start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, |
237 | desc->bmAttributes, type, | 233 | desc->bmAttributes, type, |
238 | (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * bandwidth, | 234 | (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * |
235 | bandwidth, | ||
239 | interval, unit); | 236 | interval, unit); |
240 | return start; | 237 | return start; |
241 | } | 238 | } |
242 | 239 | ||
243 | static char *usb_dump_interface_descriptor(char *start, char *end, | 240 | static char *usb_dump_interface_descriptor(char *start, char *end, |
244 | const struct usb_interface_cache *intfc, | 241 | const struct usb_interface_cache *intfc, |
245 | const struct usb_interface *iface, | 242 | const struct usb_interface *iface, |
246 | int setno) | 243 | int setno) |
247 | { | 244 | { |
248 | const struct usb_interface_descriptor *desc = &intfc->altsetting[setno].desc; | 245 | const struct usb_interface_descriptor *desc; |
249 | const char *driver_name = ""; | 246 | const char *driver_name = ""; |
250 | int active = 0; | 247 | int active = 0; |
251 | 248 | ||
252 | if (start > end) | 249 | if (start > end) |
253 | return start; | 250 | return start; |
251 | desc = &intfc->altsetting[setno].desc; | ||
254 | if (iface) { | 252 | if (iface) { |
255 | driver_name = (iface->dev.driver | 253 | driver_name = (iface->dev.driver |
256 | ? iface->dev.driver->name | 254 | ? iface->dev.driver->name |
@@ -270,14 +268,10 @@ static char *usb_dump_interface_descriptor(char *start, char *end, | |||
270 | return start; | 268 | return start; |
271 | } | 269 | } |
272 | 270 | ||
273 | static char *usb_dump_interface( | 271 | static char *usb_dump_interface(int speed, char *start, char *end, |
274 | int speed, | 272 | const struct usb_interface_cache *intfc, |
275 | char *start, | 273 | const struct usb_interface *iface, int setno) |
276 | char *end, | 274 | { |
277 | const struct usb_interface_cache *intfc, | ||
278 | const struct usb_interface *iface, | ||
279 | int setno | ||
280 | ) { | ||
281 | const struct usb_host_interface *desc = &intfc->altsetting[setno]; | 275 | const struct usb_host_interface *desc = &intfc->altsetting[setno]; |
282 | int i; | 276 | int i; |
283 | 277 | ||
@@ -292,7 +286,7 @@ static char *usb_dump_interface( | |||
292 | } | 286 | } |
293 | 287 | ||
294 | static char *usb_dump_iad_descriptor(char *start, char *end, | 288 | static char *usb_dump_iad_descriptor(char *start, char *end, |
295 | const struct usb_interface_assoc_descriptor *iad) | 289 | const struct usb_interface_assoc_descriptor *iad) |
296 | { | 290 | { |
297 | if (start > end) | 291 | if (start > end) |
298 | return start; | 292 | return start; |
@@ -311,13 +305,15 @@ static char *usb_dump_iad_descriptor(char *start, char *end, | |||
311 | * 1. marking active interface altsettings (code lists all, but should mark | 305 | * 1. marking active interface altsettings (code lists all, but should mark |
312 | * which ones are active, if any) | 306 | * which ones are active, if any) |
313 | */ | 307 | */ |
314 | 308 | static char *usb_dump_config_descriptor(char *start, char *end, | |
315 | static char *usb_dump_config_descriptor(char *start, char *end, const struct usb_config_descriptor *desc, int active) | 309 | const struct usb_config_descriptor *desc, |
310 | int active) | ||
316 | { | 311 | { |
317 | if (start > end) | 312 | if (start > end) |
318 | return start; | 313 | return start; |
319 | start += sprintf(start, format_config, | 314 | start += sprintf(start, format_config, |
320 | active ? '*' : ' ', /* mark active/actual/current cfg. */ | 315 | /* mark active/actual/current cfg. */ |
316 | active ? '*' : ' ', | ||
321 | desc->bNumInterfaces, | 317 | desc->bNumInterfaces, |
322 | desc->bConfigurationValue, | 318 | desc->bConfigurationValue, |
323 | desc->bmAttributes, | 319 | desc->bmAttributes, |
@@ -325,13 +321,8 @@ static char *usb_dump_config_descriptor(char *start, char *end, const struct usb | |||
325 | return start; | 321 | return start; |
326 | } | 322 | } |
327 | 323 | ||
328 | static char *usb_dump_config ( | 324 | static char *usb_dump_config(int speed, char *start, char *end, |
329 | int speed, | 325 | const struct usb_host_config *config, int active) |
330 | char *start, | ||
331 | char *end, | ||
332 | const struct usb_host_config *config, | ||
333 | int active | ||
334 | ) | ||
335 | { | 326 | { |
336 | int i, j; | 327 | int i, j; |
337 | struct usb_interface_cache *intfc; | 328 | struct usb_interface_cache *intfc; |
@@ -339,7 +330,8 @@ static char *usb_dump_config ( | |||
339 | 330 | ||
340 | if (start > end) | 331 | if (start > end) |
341 | return start; | 332 | return start; |
342 | if (!config) /* getting these some in 2.3.7; none in 2.3.6 */ | 333 | if (!config) |
334 | /* getting these some in 2.3.7; none in 2.3.6 */ | ||
343 | return start + sprintf(start, "(null Cfg. desc.)\n"); | 335 | return start + sprintf(start, "(null Cfg. desc.)\n"); |
344 | start = usb_dump_config_descriptor(start, end, &config->desc, active); | 336 | start = usb_dump_config_descriptor(start, end, &config->desc, active); |
345 | for (i = 0; i < USB_MAXIADS; i++) { | 337 | for (i = 0; i < USB_MAXIADS; i++) { |
@@ -364,7 +356,8 @@ static char *usb_dump_config ( | |||
364 | /* | 356 | /* |
365 | * Dump the different USB descriptors. | 357 | * Dump the different USB descriptors. |
366 | */ | 358 | */ |
367 | static char *usb_dump_device_descriptor(char *start, char *end, const struct usb_device_descriptor *desc) | 359 | static char *usb_dump_device_descriptor(char *start, char *end, |
360 | const struct usb_device_descriptor *desc) | ||
368 | { | 361 | { |
369 | u16 bcdUSB = le16_to_cpu(desc->bcdUSB); | 362 | u16 bcdUSB = le16_to_cpu(desc->bcdUSB); |
370 | u16 bcdDevice = le16_to_cpu(desc->bcdDevice); | 363 | u16 bcdDevice = le16_to_cpu(desc->bcdDevice); |
@@ -374,7 +367,7 @@ static char *usb_dump_device_descriptor(char *start, char *end, const struct usb | |||
374 | start += sprintf(start, format_device1, | 367 | start += sprintf(start, format_device1, |
375 | bcdUSB >> 8, bcdUSB & 0xff, | 368 | bcdUSB >> 8, bcdUSB & 0xff, |
376 | desc->bDeviceClass, | 369 | desc->bDeviceClass, |
377 | class_decode (desc->bDeviceClass), | 370 | class_decode(desc->bDeviceClass), |
378 | desc->bDeviceSubClass, | 371 | desc->bDeviceSubClass, |
379 | desc->bDeviceProtocol, | 372 | desc->bDeviceProtocol, |
380 | desc->bMaxPacketSize0, | 373 | desc->bMaxPacketSize0, |
@@ -391,12 +384,14 @@ static char *usb_dump_device_descriptor(char *start, char *end, const struct usb | |||
391 | /* | 384 | /* |
392 | * Dump the different strings that this device holds. | 385 | * Dump the different strings that this device holds. |
393 | */ | 386 | */ |
394 | static char *usb_dump_device_strings(char *start, char *end, struct usb_device *dev) | 387 | static char *usb_dump_device_strings(char *start, char *end, |
388 | struct usb_device *dev) | ||
395 | { | 389 | { |
396 | if (start > end) | 390 | if (start > end) |
397 | return start; | 391 | return start; |
398 | if (dev->manufacturer) | 392 | if (dev->manufacturer) |
399 | start += sprintf(start, format_string_manufacturer, dev->manufacturer); | 393 | start += sprintf(start, format_string_manufacturer, |
394 | dev->manufacturer); | ||
400 | if (start > end) | 395 | if (start > end) |
401 | goto out; | 396 | goto out; |
402 | if (dev->product) | 397 | if (dev->product) |
@@ -405,7 +400,8 @@ static char *usb_dump_device_strings(char *start, char *end, struct usb_device * | |||
405 | goto out; | 400 | goto out; |
406 | #ifdef ALLOW_SERIAL_NUMBER | 401 | #ifdef ALLOW_SERIAL_NUMBER |
407 | if (dev->serial) | 402 | if (dev->serial) |
408 | start += sprintf(start, format_string_serialnumber, dev->serial); | 403 | start += sprintf(start, format_string_serialnumber, |
404 | dev->serial); | ||
409 | #endif | 405 | #endif |
410 | out: | 406 | out: |
411 | return start; | 407 | return start; |
@@ -417,12 +413,12 @@ static char *usb_dump_desc(char *start, char *end, struct usb_device *dev) | |||
417 | 413 | ||
418 | if (start > end) | 414 | if (start > end) |
419 | return start; | 415 | return start; |
420 | 416 | ||
421 | start = usb_dump_device_descriptor(start, end, &dev->descriptor); | 417 | start = usb_dump_device_descriptor(start, end, &dev->descriptor); |
422 | 418 | ||
423 | if (start > end) | 419 | if (start > end) |
424 | return start; | 420 | return start; |
425 | 421 | ||
426 | start = usb_dump_device_strings(start, end, dev); | 422 | start = usb_dump_device_strings(start, end, dev); |
427 | 423 | ||
428 | for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { | 424 | for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { |
@@ -439,7 +435,8 @@ static char *usb_dump_desc(char *start, char *end, struct usb_device *dev) | |||
439 | 435 | ||
440 | #ifdef PROC_EXTRA /* TBD: may want to add this code later */ | 436 | #ifdef PROC_EXTRA /* TBD: may want to add this code later */ |
441 | 437 | ||
442 | static char *usb_dump_hub_descriptor(char *start, char *end, const struct usb_hub_descriptor * desc) | 438 | static char *usb_dump_hub_descriptor(char *start, char *end, |
439 | const struct usb_hub_descriptor *desc) | ||
443 | { | 440 | { |
444 | int leng = USB_DT_HUB_NONVAR_SIZE; | 441 | int leng = USB_DT_HUB_NONVAR_SIZE; |
445 | unsigned char *ptr = (unsigned char *)desc; | 442 | unsigned char *ptr = (unsigned char *)desc; |
@@ -455,13 +452,16 @@ static char *usb_dump_hub_descriptor(char *start, char *end, const struct usb_hu | |||
455 | return start; | 452 | return start; |
456 | } | 453 | } |
457 | 454 | ||
458 | static char *usb_dump_string(char *start, char *end, const struct usb_device *dev, char *id, int index) | 455 | static char *usb_dump_string(char *start, char *end, |
456 | const struct usb_device *dev, char *id, int index) | ||
459 | { | 457 | { |
460 | if (start > end) | 458 | if (start > end) |
461 | return start; | 459 | return start; |
462 | start += sprintf(start, "Interface:"); | 460 | start += sprintf(start, "Interface:"); |
463 | if (index <= dev->maxstring && dev->stringindex && dev->stringindex[index]) | 461 | if (index <= dev->maxstring && dev->stringindex && |
464 | start += sprintf(start, "%s: %.100s ", id, dev->stringindex[index]); | 462 | dev->stringindex[index]) |
463 | start += sprintf(start, "%s: %.100s ", id, | ||
464 | dev->stringindex[index]); | ||
465 | return start; | 465 | return start; |
466 | } | 466 | } |
467 | 467 | ||
@@ -476,8 +476,10 @@ static char *usb_dump_string(char *start, char *end, const struct usb_device *de | |||
476 | * file_offset - the offset into the devices file on completion | 476 | * file_offset - the offset into the devices file on completion |
477 | * The caller must own the device lock. | 477 | * The caller must own the device lock. |
478 | */ | 478 | */ |
479 | static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *skip_bytes, loff_t *file_offset, | 479 | static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, |
480 | struct usb_device *usbdev, struct usb_bus *bus, int level, int index, int count) | 480 | loff_t *skip_bytes, loff_t *file_offset, |
481 | struct usb_device *usbdev, struct usb_bus *bus, | ||
482 | int level, int index, int count) | ||
481 | { | 483 | { |
482 | int chix; | 484 | int chix; |
483 | int ret, cnt = 0; | 485 | int ret, cnt = 0; |
@@ -485,17 +487,19 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski | |||
485 | char *pages_start, *data_end, *speed; | 487 | char *pages_start, *data_end, *speed; |
486 | unsigned int length; | 488 | unsigned int length; |
487 | ssize_t total_written = 0; | 489 | ssize_t total_written = 0; |
488 | 490 | ||
489 | /* don't bother with anything else if we're not writing any data */ | 491 | /* don't bother with anything else if we're not writing any data */ |
490 | if (*nbytes <= 0) | 492 | if (*nbytes <= 0) |
491 | return 0; | 493 | return 0; |
492 | 494 | ||
493 | if (level > MAX_TOPO_LEVEL) | 495 | if (level > MAX_TOPO_LEVEL) |
494 | return 0; | 496 | return 0; |
495 | /* allocate 2^1 pages = 8K (on i386); should be more than enough for one device */ | 497 | /* allocate 2^1 pages = 8K (on i386); |
496 | if (!(pages_start = (char*) __get_free_pages(GFP_KERNEL,1))) | 498 | * should be more than enough for one device */ |
497 | return -ENOMEM; | 499 | pages_start = (char *)__get_free_pages(GFP_KERNEL, 1); |
498 | 500 | if (!pages_start) | |
501 | return -ENOMEM; | ||
502 | |||
499 | if (usbdev->parent && usbdev->parent->devnum != -1) | 503 | if (usbdev->parent && usbdev->parent->devnum != -1) |
500 | parent_devnum = usbdev->parent->devnum; | 504 | parent_devnum = usbdev->parent->devnum; |
501 | /* | 505 | /* |
@@ -541,15 +545,16 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski | |||
541 | bus->bandwidth_allocated, max, | 545 | bus->bandwidth_allocated, max, |
542 | (100 * bus->bandwidth_allocated + max / 2) | 546 | (100 * bus->bandwidth_allocated + max / 2) |
543 | / max, | 547 | / max, |
544 | bus->bandwidth_int_reqs, | 548 | bus->bandwidth_int_reqs, |
545 | bus->bandwidth_isoc_reqs); | 549 | bus->bandwidth_isoc_reqs); |
546 | 550 | ||
547 | } | 551 | } |
548 | data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256, usbdev); | 552 | data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256, |
549 | 553 | usbdev); | |
554 | |||
550 | if (data_end > (pages_start + (2 * PAGE_SIZE) - 256)) | 555 | if (data_end > (pages_start + (2 * PAGE_SIZE) - 256)) |
551 | data_end += sprintf(data_end, "(truncated)\n"); | 556 | data_end += sprintf(data_end, "(truncated)\n"); |
552 | 557 | ||
553 | length = data_end - pages_start; | 558 | length = data_end - pages_start; |
554 | /* if we can start copying some data to the user */ | 559 | /* if we can start copying some data to the user */ |
555 | if (length > *skip_bytes) { | 560 | if (length > *skip_bytes) { |
@@ -567,17 +572,18 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski | |||
567 | *skip_bytes = 0; | 572 | *skip_bytes = 0; |
568 | } else | 573 | } else |
569 | *skip_bytes -= length; | 574 | *skip_bytes -= length; |
570 | 575 | ||
571 | free_pages((unsigned long)pages_start, 1); | 576 | free_pages((unsigned long)pages_start, 1); |
572 | 577 | ||
573 | /* Now look at all of this device's children. */ | 578 | /* Now look at all of this device's children. */ |
574 | for (chix = 0; chix < usbdev->maxchild; chix++) { | 579 | for (chix = 0; chix < usbdev->maxchild; chix++) { |
575 | struct usb_device *childdev = usbdev->children[chix]; | 580 | struct usb_device *childdev = usbdev->children[chix]; |
576 | 581 | ||
577 | if (childdev) { | 582 | if (childdev) { |
578 | usb_lock_device(childdev); | 583 | usb_lock_device(childdev); |
579 | ret = usb_device_dump(buffer, nbytes, skip_bytes, file_offset, childdev, | 584 | ret = usb_device_dump(buffer, nbytes, skip_bytes, |
580 | bus, level + 1, chix, ++cnt); | 585 | file_offset, childdev, bus, |
586 | level + 1, chix, ++cnt); | ||
581 | usb_unlock_device(childdev); | 587 | usb_unlock_device(childdev); |
582 | if (ret == -EFAULT) | 588 | if (ret == -EFAULT) |
583 | return total_written; | 589 | return total_written; |
@@ -587,7 +593,8 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski | |||
587 | return total_written; | 593 | return total_written; |
588 | } | 594 | } |
589 | 595 | ||
590 | static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | 596 | static ssize_t usb_device_read(struct file *file, char __user *buf, |
597 | size_t nbytes, loff_t *ppos) | ||
591 | { | 598 | { |
592 | struct usb_bus *bus; | 599 | struct usb_bus *bus; |
593 | ssize_t ret, total_written = 0; | 600 | ssize_t ret, total_written = 0; |
@@ -607,7 +614,8 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte | |||
607 | if (!bus->root_hub) | 614 | if (!bus->root_hub) |
608 | continue; | 615 | continue; |
609 | usb_lock_device(bus->root_hub); | 616 | usb_lock_device(bus->root_hub); |
610 | ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); | 617 | ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, |
618 | bus->root_hub, bus, 0, 0, 0); | ||
611 | usb_unlock_device(bus->root_hub); | 619 | usb_unlock_device(bus->root_hub); |
612 | if (ret < 0) { | 620 | if (ret < 0) { |
613 | mutex_unlock(&usb_bus_list_lock); | 621 | mutex_unlock(&usb_bus_list_lock); |
@@ -620,7 +628,8 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte | |||
620 | } | 628 | } |
621 | 629 | ||
622 | /* Kernel lock for "lastev" protection */ | 630 | /* Kernel lock for "lastev" protection */ |
623 | static unsigned int usb_device_poll(struct file *file, struct poll_table_struct *wait) | 631 | static unsigned int usb_device_poll(struct file *file, |
632 | struct poll_table_struct *wait) | ||
624 | { | 633 | { |
625 | struct usb_device_status *st = file->private_data; | 634 | struct usb_device_status *st = file->private_data; |
626 | unsigned int mask = 0; | 635 | unsigned int mask = 0; |
@@ -629,7 +638,8 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct | |||
629 | if (!st) { | 638 | if (!st) { |
630 | st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); | 639 | st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); |
631 | 640 | ||
632 | /* we may have dropped BKL - need to check for having lost the race */ | 641 | /* we may have dropped BKL - |
642 | * need to check for having lost the race */ | ||
633 | if (file->private_data) { | 643 | if (file->private_data) { |
634 | kfree(st); | 644 | kfree(st); |
635 | st = file->private_data; | 645 | st = file->private_data; |
@@ -652,7 +662,7 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct | |||
652 | } | 662 | } |
653 | lost_race: | 663 | lost_race: |
654 | if (file->f_mode & FMODE_READ) | 664 | if (file->f_mode & FMODE_READ) |
655 | poll_wait(file, &deviceconndiscwq, wait); | 665 | poll_wait(file, &deviceconndiscwq, wait); |
656 | if (st->lastev != conndiscevcnt) | 666 | if (st->lastev != conndiscevcnt) |
657 | mask |= POLLIN; | 667 | mask |= POLLIN; |
658 | st->lastev = conndiscevcnt; | 668 | st->lastev = conndiscevcnt; |
@@ -662,18 +672,18 @@ lost_race: | |||
662 | 672 | ||
663 | static int usb_device_open(struct inode *inode, struct file *file) | 673 | static int usb_device_open(struct inode *inode, struct file *file) |
664 | { | 674 | { |
665 | file->private_data = NULL; | 675 | file->private_data = NULL; |
666 | return 0; | 676 | return 0; |
667 | } | 677 | } |
668 | 678 | ||
669 | static int usb_device_release(struct inode *inode, struct file *file) | 679 | static int usb_device_release(struct inode *inode, struct file *file) |
670 | { | 680 | { |
671 | kfree(file->private_data); | 681 | kfree(file->private_data); |
672 | file->private_data = NULL; | 682 | file->private_data = NULL; |
673 | return 0; | 683 | return 0; |
674 | } | 684 | } |
675 | 685 | ||
676 | static loff_t usb_device_lseek(struct file * file, loff_t offset, int orig) | 686 | static loff_t usb_device_lseek(struct file *file, loff_t offset, int orig) |
677 | { | 687 | { |
678 | loff_t ret; | 688 | loff_t ret; |
679 | 689 | ||
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 1f4f6d02fe25..ae94176c64e4 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -75,14 +75,14 @@ struct async { | |||
75 | u32 secid; | 75 | u32 secid; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | static int usbfs_snoop = 0; | 78 | static int usbfs_snoop; |
79 | module_param (usbfs_snoop, bool, S_IRUGO | S_IWUSR); | 79 | module_param(usbfs_snoop, bool, S_IRUGO | S_IWUSR); |
80 | MODULE_PARM_DESC (usbfs_snoop, "true to log all usbfs traffic"); | 80 | MODULE_PARM_DESC(usbfs_snoop, "true to log all usbfs traffic"); |
81 | 81 | ||
82 | #define snoop(dev, format, arg...) \ | 82 | #define snoop(dev, format, arg...) \ |
83 | do { \ | 83 | do { \ |
84 | if (usbfs_snoop) \ | 84 | if (usbfs_snoop) \ |
85 | dev_info( dev , format , ## arg); \ | 85 | dev_info(dev , format , ## arg); \ |
86 | } while (0) | 86 | } while (0) |
87 | 87 | ||
88 | #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) | 88 | #define USB_DEVICE_DEV MKDEV(USB_DEVICE_MAJOR, 0) |
@@ -90,7 +90,7 @@ MODULE_PARM_DESC (usbfs_snoop, "true to log all usbfs traffic"); | |||
90 | 90 | ||
91 | #define MAX_USBFS_BUFFER_SIZE 16384 | 91 | #define MAX_USBFS_BUFFER_SIZE 16384 |
92 | 92 | ||
93 | static inline int connected (struct dev_state *ps) | 93 | static inline int connected(struct dev_state *ps) |
94 | { | 94 | { |
95 | return (!list_empty(&ps->list) && | 95 | return (!list_empty(&ps->list) && |
96 | ps->dev->state != USB_STATE_NOTATTACHED); | 96 | ps->dev->state != USB_STATE_NOTATTACHED); |
@@ -120,7 +120,8 @@ static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig) | |||
120 | return ret; | 120 | return ret; |
121 | } | 121 | } |
122 | 122 | ||
123 | static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | 123 | static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, |
124 | loff_t *ppos) | ||
124 | { | 125 | { |
125 | struct dev_state *ps = file->private_data; | 126 | struct dev_state *ps = file->private_data; |
126 | struct usb_device *dev = ps->dev; | 127 | struct usb_device *dev = ps->dev; |
@@ -140,7 +141,8 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l | |||
140 | } | 141 | } |
141 | 142 | ||
142 | if (pos < sizeof(struct usb_device_descriptor)) { | 143 | if (pos < sizeof(struct usb_device_descriptor)) { |
143 | struct usb_device_descriptor temp_desc ; /* 18 bytes - fits on the stack */ | 144 | /* 18 bytes - fits on the stack */ |
145 | struct usb_device_descriptor temp_desc; | ||
144 | 146 | ||
145 | memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor)); | 147 | memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor)); |
146 | le16_to_cpus(&temp_desc.bcdUSB); | 148 | le16_to_cpus(&temp_desc.bcdUSB); |
@@ -210,17 +212,17 @@ err: | |||
210 | 212 | ||
211 | static struct async *alloc_async(unsigned int numisoframes) | 213 | static struct async *alloc_async(unsigned int numisoframes) |
212 | { | 214 | { |
213 | unsigned int assize = sizeof(struct async) + numisoframes * sizeof(struct usb_iso_packet_descriptor); | 215 | struct async *as; |
214 | struct async *as = kzalloc(assize, GFP_KERNEL); | ||
215 | 216 | ||
216 | if (!as) | 217 | as = kzalloc(sizeof(struct async), GFP_KERNEL); |
217 | return NULL; | 218 | if (!as) |
219 | return NULL; | ||
218 | as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); | 220 | as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); |
219 | if (!as->urb) { | 221 | if (!as->urb) { |
220 | kfree(as); | 222 | kfree(as); |
221 | return NULL; | 223 | return NULL; |
222 | } | 224 | } |
223 | return as; | 225 | return as; |
224 | } | 226 | } |
225 | 227 | ||
226 | static void free_async(struct async *as) | 228 | static void free_async(struct async *as) |
@@ -234,52 +236,54 @@ static void free_async(struct async *as) | |||
234 | 236 | ||
235 | static inline void async_newpending(struct async *as) | 237 | static inline void async_newpending(struct async *as) |
236 | { | 238 | { |
237 | struct dev_state *ps = as->ps; | 239 | struct dev_state *ps = as->ps; |
238 | unsigned long flags; | 240 | unsigned long flags; |
239 | 241 | ||
240 | spin_lock_irqsave(&ps->lock, flags); | 242 | spin_lock_irqsave(&ps->lock, flags); |
241 | list_add_tail(&as->asynclist, &ps->async_pending); | 243 | list_add_tail(&as->asynclist, &ps->async_pending); |
242 | spin_unlock_irqrestore(&ps->lock, flags); | 244 | spin_unlock_irqrestore(&ps->lock, flags); |
243 | } | 245 | } |
244 | 246 | ||
245 | static inline void async_removepending(struct async *as) | 247 | static inline void async_removepending(struct async *as) |
246 | { | 248 | { |
247 | struct dev_state *ps = as->ps; | 249 | struct dev_state *ps = as->ps; |
248 | unsigned long flags; | 250 | unsigned long flags; |
249 | 251 | ||
250 | spin_lock_irqsave(&ps->lock, flags); | 252 | spin_lock_irqsave(&ps->lock, flags); |
251 | list_del_init(&as->asynclist); | 253 | list_del_init(&as->asynclist); |
252 | spin_unlock_irqrestore(&ps->lock, flags); | 254 | spin_unlock_irqrestore(&ps->lock, flags); |
253 | } | 255 | } |
254 | 256 | ||
255 | static inline struct async *async_getcompleted(struct dev_state *ps) | 257 | static inline struct async *async_getcompleted(struct dev_state *ps) |
256 | { | 258 | { |
257 | unsigned long flags; | 259 | unsigned long flags; |
258 | struct async *as = NULL; | 260 | struct async *as = NULL; |
259 | 261 | ||
260 | spin_lock_irqsave(&ps->lock, flags); | 262 | spin_lock_irqsave(&ps->lock, flags); |
261 | if (!list_empty(&ps->async_completed)) { | 263 | if (!list_empty(&ps->async_completed)) { |
262 | as = list_entry(ps->async_completed.next, struct async, asynclist); | 264 | as = list_entry(ps->async_completed.next, struct async, |
263 | list_del_init(&as->asynclist); | 265 | asynclist); |
264 | } | 266 | list_del_init(&as->asynclist); |
265 | spin_unlock_irqrestore(&ps->lock, flags); | 267 | } |
266 | return as; | 268 | spin_unlock_irqrestore(&ps->lock, flags); |
269 | return as; | ||
267 | } | 270 | } |
268 | 271 | ||
269 | static inline struct async *async_getpending(struct dev_state *ps, void __user *userurb) | 272 | static inline struct async *async_getpending(struct dev_state *ps, |
273 | void __user *userurb) | ||
270 | { | 274 | { |
271 | unsigned long flags; | 275 | unsigned long flags; |
272 | struct async *as; | 276 | struct async *as; |
273 | 277 | ||
274 | spin_lock_irqsave(&ps->lock, flags); | 278 | spin_lock_irqsave(&ps->lock, flags); |
275 | list_for_each_entry(as, &ps->async_pending, asynclist) | 279 | list_for_each_entry(as, &ps->async_pending, asynclist) |
276 | if (as->userurb == userurb) { | 280 | if (as->userurb == userurb) { |
277 | list_del_init(&as->asynclist); | 281 | list_del_init(&as->asynclist); |
278 | spin_unlock_irqrestore(&ps->lock, flags); | 282 | spin_unlock_irqrestore(&ps->lock, flags); |
279 | return as; | 283 | return as; |
280 | } | 284 | } |
281 | spin_unlock_irqrestore(&ps->lock, flags); | 285 | spin_unlock_irqrestore(&ps->lock, flags); |
282 | return NULL; | 286 | return NULL; |
283 | } | 287 | } |
284 | 288 | ||
285 | static void snoop_urb(struct urb *urb, void __user *userurb) | 289 | static void snoop_urb(struct urb *urb, void __user *userurb) |
@@ -298,19 +302,19 @@ static void snoop_urb(struct urb *urb, void __user *userurb) | |||
298 | dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length); | 302 | dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length); |
299 | dev_info(&urb->dev->dev, "data: "); | 303 | dev_info(&urb->dev->dev, "data: "); |
300 | for (j = 0; j < urb->transfer_buffer_length; ++j) | 304 | for (j = 0; j < urb->transfer_buffer_length; ++j) |
301 | printk ("%02x ", data[j]); | 305 | printk("%02x ", data[j]); |
302 | printk("\n"); | 306 | printk("\n"); |
303 | } | 307 | } |
304 | 308 | ||
305 | static void async_completed(struct urb *urb) | 309 | static void async_completed(struct urb *urb) |
306 | { | 310 | { |
307 | struct async *as = urb->context; | 311 | struct async *as = urb->context; |
308 | struct dev_state *ps = as->ps; | 312 | struct dev_state *ps = as->ps; |
309 | struct siginfo sinfo; | 313 | struct siginfo sinfo; |
310 | 314 | ||
311 | spin_lock(&ps->lock); | 315 | spin_lock(&ps->lock); |
312 | list_move_tail(&as->asynclist, &ps->async_completed); | 316 | list_move_tail(&as->asynclist, &ps->async_completed); |
313 | spin_unlock(&ps->lock); | 317 | spin_unlock(&ps->lock); |
314 | as->status = urb->status; | 318 | as->status = urb->status; |
315 | if (as->signr) { | 319 | if (as->signr) { |
316 | sinfo.si_signo = as->signr; | 320 | sinfo.si_signo = as->signr; |
@@ -325,7 +329,7 @@ static void async_completed(struct urb *urb) | |||
325 | wake_up(&ps->wait); | 329 | wake_up(&ps->wait); |
326 | } | 330 | } |
327 | 331 | ||
328 | static void destroy_async (struct dev_state *ps, struct list_head *list) | 332 | static void destroy_async(struct dev_state *ps, struct list_head *list) |
329 | { | 333 | { |
330 | struct async *as; | 334 | struct async *as; |
331 | unsigned long flags; | 335 | unsigned long flags; |
@@ -348,7 +352,8 @@ static void destroy_async (struct dev_state *ps, struct list_head *list) | |||
348 | } | 352 | } |
349 | } | 353 | } |
350 | 354 | ||
351 | static void destroy_async_on_interface (struct dev_state *ps, unsigned int ifnum) | 355 | static void destroy_async_on_interface(struct dev_state *ps, |
356 | unsigned int ifnum) | ||
352 | { | 357 | { |
353 | struct list_head *p, *q, hitlist; | 358 | struct list_head *p, *q, hitlist; |
354 | unsigned long flags; | 359 | unsigned long flags; |
@@ -364,7 +369,7 @@ static void destroy_async_on_interface (struct dev_state *ps, unsigned int ifnum | |||
364 | 369 | ||
365 | static inline void destroy_all_async(struct dev_state *ps) | 370 | static inline void destroy_all_async(struct dev_state *ps) |
366 | { | 371 | { |
367 | destroy_async(ps, &ps->async_pending); | 372 | destroy_async(ps, &ps->async_pending); |
368 | } | 373 | } |
369 | 374 | ||
370 | /* | 375 | /* |
@@ -373,15 +378,15 @@ static inline void destroy_all_async(struct dev_state *ps) | |||
373 | * they're also undone when devices disconnect. | 378 | * they're also undone when devices disconnect. |
374 | */ | 379 | */ |
375 | 380 | ||
376 | static int driver_probe (struct usb_interface *intf, | 381 | static int driver_probe(struct usb_interface *intf, |
377 | const struct usb_device_id *id) | 382 | const struct usb_device_id *id) |
378 | { | 383 | { |
379 | return -ENODEV; | 384 | return -ENODEV; |
380 | } | 385 | } |
381 | 386 | ||
382 | static void driver_disconnect(struct usb_interface *intf) | 387 | static void driver_disconnect(struct usb_interface *intf) |
383 | { | 388 | { |
384 | struct dev_state *ps = usb_get_intfdata (intf); | 389 | struct dev_state *ps = usb_get_intfdata(intf); |
385 | unsigned int ifnum = intf->altsetting->desc.bInterfaceNumber; | 390 | unsigned int ifnum = intf->altsetting->desc.bInterfaceNumber; |
386 | 391 | ||
387 | if (!ps) | 392 | if (!ps) |
@@ -396,16 +401,31 @@ static void driver_disconnect(struct usb_interface *intf) | |||
396 | else | 401 | else |
397 | warn("interface number %u out of range", ifnum); | 402 | warn("interface number %u out of range", ifnum); |
398 | 403 | ||
399 | usb_set_intfdata (intf, NULL); | 404 | usb_set_intfdata(intf, NULL); |
400 | 405 | ||
401 | /* force async requests to complete */ | 406 | /* force async requests to complete */ |
402 | destroy_async_on_interface(ps, ifnum); | 407 | destroy_async_on_interface(ps, ifnum); |
403 | } | 408 | } |
404 | 409 | ||
410 | /* The following routines are merely placeholders. There is no way | ||
411 | * to inform a user task about suspend or resumes. | ||
412 | */ | ||
413 | static int driver_suspend(struct usb_interface *intf, pm_message_t msg) | ||
414 | { | ||
415 | return 0; | ||
416 | } | ||
417 | |||
418 | static int driver_resume(struct usb_interface *intf) | ||
419 | { | ||
420 | return 0; | ||
421 | } | ||
422 | |||
405 | struct usb_driver usbfs_driver = { | 423 | struct usb_driver usbfs_driver = { |
406 | .name = "usbfs", | 424 | .name = "usbfs", |
407 | .probe = driver_probe, | 425 | .probe = driver_probe, |
408 | .disconnect = driver_disconnect, | 426 | .disconnect = driver_disconnect, |
427 | .suspend = driver_suspend, | ||
428 | .resume = driver_resume, | ||
409 | }; | 429 | }; |
410 | 430 | ||
411 | static int claimintf(struct dev_state *ps, unsigned int ifnum) | 431 | static int claimintf(struct dev_state *ps, unsigned int ifnum) |
@@ -459,15 +479,16 @@ static int checkintf(struct dev_state *ps, unsigned int ifnum) | |||
459 | if (test_bit(ifnum, &ps->ifclaimed)) | 479 | if (test_bit(ifnum, &ps->ifclaimed)) |
460 | return 0; | 480 | return 0; |
461 | /* if not yet claimed, claim it for the driver */ | 481 | /* if not yet claimed, claim it for the driver */ |
462 | dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim interface %u before use\n", | 482 | dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim " |
463 | task_pid_nr(current), current->comm, ifnum); | 483 | "interface %u before use\n", task_pid_nr(current), |
484 | current->comm, ifnum); | ||
464 | return claimintf(ps, ifnum); | 485 | return claimintf(ps, ifnum); |
465 | } | 486 | } |
466 | 487 | ||
467 | static int findintfep(struct usb_device *dev, unsigned int ep) | 488 | static int findintfep(struct usb_device *dev, unsigned int ep) |
468 | { | 489 | { |
469 | unsigned int i, j, e; | 490 | unsigned int i, j, e; |
470 | struct usb_interface *intf; | 491 | struct usb_interface *intf; |
471 | struct usb_host_interface *alts; | 492 | struct usb_host_interface *alts; |
472 | struct usb_endpoint_descriptor *endpt; | 493 | struct usb_endpoint_descriptor *endpt; |
473 | 494 | ||
@@ -478,7 +499,7 @@ static int findintfep(struct usb_device *dev, unsigned int ep) | |||
478 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { | 499 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { |
479 | intf = dev->actconfig->interface[i]; | 500 | intf = dev->actconfig->interface[i]; |
480 | for (j = 0; j < intf->num_altsetting; j++) { | 501 | for (j = 0; j < intf->num_altsetting; j++) { |
481 | alts = &intf->altsetting[j]; | 502 | alts = &intf->altsetting[j]; |
482 | for (e = 0; e < alts->desc.bNumEndpoints; e++) { | 503 | for (e = 0; e < alts->desc.bNumEndpoints; e++) { |
483 | endpt = &alts->endpoint[e].desc; | 504 | endpt = &alts->endpoint[e].desc; |
484 | if (endpt->bEndpointAddress == ep) | 505 | if (endpt->bEndpointAddress == ep) |
@@ -486,10 +507,11 @@ static int findintfep(struct usb_device *dev, unsigned int ep) | |||
486 | } | 507 | } |
487 | } | 508 | } |
488 | } | 509 | } |
489 | return -ENOENT; | 510 | return -ENOENT; |
490 | } | 511 | } |
491 | 512 | ||
492 | static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsigned int index) | 513 | static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, |
514 | unsigned int index) | ||
493 | { | 515 | { |
494 | int ret = 0; | 516 | int ret = 0; |
495 | 517 | ||
@@ -502,7 +524,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsig | |||
502 | index &= 0xff; | 524 | index &= 0xff; |
503 | switch (requesttype & USB_RECIP_MASK) { | 525 | switch (requesttype & USB_RECIP_MASK) { |
504 | case USB_RECIP_ENDPOINT: | 526 | case USB_RECIP_ENDPOINT: |
505 | if ((ret = findintfep(ps->dev, index)) >= 0) | 527 | ret = findintfep(ps->dev, index); |
528 | if (ret >= 0) | ||
506 | ret = checkintf(ps, ret); | 529 | ret = checkintf(ps, ret); |
507 | break; | 530 | break; |
508 | 531 | ||
@@ -546,7 +569,8 @@ static int usbdev_open(struct inode *inode, struct file *file) | |||
546 | mutex_lock(&usbfs_mutex); | 569 | mutex_lock(&usbfs_mutex); |
547 | 570 | ||
548 | ret = -ENOMEM; | 571 | ret = -ENOMEM; |
549 | if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL))) | 572 | ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL); |
573 | if (!ps) | ||
550 | goto out; | 574 | goto out; |
551 | 575 | ||
552 | ret = -ENOENT; | 576 | ret = -ENOENT; |
@@ -627,15 +651,18 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
627 | 651 | ||
628 | if (copy_from_user(&ctrl, arg, sizeof(ctrl))) | 652 | if (copy_from_user(&ctrl, arg, sizeof(ctrl))) |
629 | return -EFAULT; | 653 | return -EFAULT; |
630 | if ((ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex))) | 654 | ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex); |
655 | if (ret) | ||
631 | return ret; | 656 | return ret; |
632 | if (ctrl.wLength > PAGE_SIZE) | 657 | if (ctrl.wLength > PAGE_SIZE) |
633 | return -EINVAL; | 658 | return -EINVAL; |
634 | if (!(tbuf = (unsigned char *)__get_free_page(GFP_KERNEL))) | 659 | tbuf = (unsigned char *)__get_free_page(GFP_KERNEL); |
660 | if (!tbuf) | ||
635 | return -ENOMEM; | 661 | return -ENOMEM; |
636 | tmo = ctrl.timeout; | 662 | tmo = ctrl.timeout; |
637 | if (ctrl.bRequestType & 0x80) { | 663 | if (ctrl.bRequestType & 0x80) { |
638 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, ctrl.wLength)) { | 664 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, |
665 | ctrl.wLength)) { | ||
639 | free_page((unsigned long)tbuf); | 666 | free_page((unsigned long)tbuf); |
640 | return -EINVAL; | 667 | return -EINVAL; |
641 | } | 668 | } |
@@ -646,14 +673,15 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
646 | ctrl.wIndex, ctrl.wLength); | 673 | ctrl.wIndex, ctrl.wLength); |
647 | 674 | ||
648 | usb_unlock_device(dev); | 675 | usb_unlock_device(dev); |
649 | i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, | 676 | i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, |
650 | ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo); | 677 | ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, |
678 | tbuf, ctrl.wLength, tmo); | ||
651 | usb_lock_device(dev); | 679 | usb_lock_device(dev); |
652 | if ((i > 0) && ctrl.wLength) { | 680 | if ((i > 0) && ctrl.wLength) { |
653 | if (usbfs_snoop) { | 681 | if (usbfs_snoop) { |
654 | dev_info(&dev->dev, "control read: data "); | 682 | dev_info(&dev->dev, "control read: data "); |
655 | for (j = 0; j < i; ++j) | 683 | for (j = 0; j < i; ++j) |
656 | printk("%02x ", (unsigned char)(tbuf)[j]); | 684 | printk("%02x ", (u8)(tbuf)[j]); |
657 | printk("\n"); | 685 | printk("\n"); |
658 | } | 686 | } |
659 | if (copy_to_user(ctrl.data, tbuf, i)) { | 687 | if (copy_to_user(ctrl.data, tbuf, i)) { |
@@ -680,12 +708,13 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
680 | printk("\n"); | 708 | printk("\n"); |
681 | } | 709 | } |
682 | usb_unlock_device(dev); | 710 | usb_unlock_device(dev); |
683 | i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, | 711 | i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, |
684 | ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo); | 712 | ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, |
713 | tbuf, ctrl.wLength, tmo); | ||
685 | usb_lock_device(dev); | 714 | usb_lock_device(dev); |
686 | } | 715 | } |
687 | free_page((unsigned long)tbuf); | 716 | free_page((unsigned long)tbuf); |
688 | if (i<0 && i != -EPIPE) { | 717 | if (i < 0 && i != -EPIPE) { |
689 | dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " | 718 | dev_printk(KERN_DEBUG, &dev->dev, "usbfs: USBDEVFS_CONTROL " |
690 | "failed cmd %s rqt %u rq %u len %u ret %d\n", | 719 | "failed cmd %s rqt %u rq %u len %u ret %d\n", |
691 | current->comm, ctrl.bRequestType, ctrl.bRequest, | 720 | current->comm, ctrl.bRequestType, ctrl.bRequest, |
@@ -705,9 +734,11 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
705 | 734 | ||
706 | if (copy_from_user(&bulk, arg, sizeof(bulk))) | 735 | if (copy_from_user(&bulk, arg, sizeof(bulk))) |
707 | return -EFAULT; | 736 | return -EFAULT; |
708 | if ((ret = findintfep(ps->dev, bulk.ep)) < 0) | 737 | ret = findintfep(ps->dev, bulk.ep); |
738 | if (ret < 0) | ||
709 | return ret; | 739 | return ret; |
710 | if ((ret = checkintf(ps, ret))) | 740 | ret = checkintf(ps, ret); |
741 | if (ret) | ||
711 | return ret; | 742 | return ret; |
712 | if (bulk.ep & USB_DIR_IN) | 743 | if (bulk.ep & USB_DIR_IN) |
713 | pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f); | 744 | pipe = usb_rcvbulkpipe(dev, bulk.ep & 0x7f); |
@@ -735,7 +766,7 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
735 | if (usbfs_snoop) { | 766 | if (usbfs_snoop) { |
736 | dev_info(&dev->dev, "bulk read: data "); | 767 | dev_info(&dev->dev, "bulk read: data "); |
737 | for (j = 0; j < len2; ++j) | 768 | for (j = 0; j < len2; ++j) |
738 | printk("%02x ", (unsigned char)(tbuf)[j]); | 769 | printk("%02x ", (u8)(tbuf)[j]); |
739 | printk("\n"); | 770 | printk("\n"); |
740 | } | 771 | } |
741 | if (copy_to_user(bulk.data, tbuf, len2)) { | 772 | if (copy_to_user(bulk.data, tbuf, len2)) { |
@@ -775,9 +806,11 @@ static int proc_resetep(struct dev_state *ps, void __user *arg) | |||
775 | 806 | ||
776 | if (get_user(ep, (unsigned int __user *)arg)) | 807 | if (get_user(ep, (unsigned int __user *)arg)) |
777 | return -EFAULT; | 808 | return -EFAULT; |
778 | if ((ret = findintfep(ps->dev, ep)) < 0) | 809 | ret = findintfep(ps->dev, ep); |
810 | if (ret < 0) | ||
779 | return ret; | 811 | return ret; |
780 | if ((ret = checkintf(ps, ret))) | 812 | ret = checkintf(ps, ret); |
813 | if (ret) | ||
781 | return ret; | 814 | return ret; |
782 | usb_settoggle(ps->dev, ep & 0xf, !(ep & USB_DIR_IN), 0); | 815 | usb_settoggle(ps->dev, ep & 0xf, !(ep & USB_DIR_IN), 0); |
783 | return 0; | 816 | return 0; |
@@ -791,18 +824,19 @@ static int proc_clearhalt(struct dev_state *ps, void __user *arg) | |||
791 | 824 | ||
792 | if (get_user(ep, (unsigned int __user *)arg)) | 825 | if (get_user(ep, (unsigned int __user *)arg)) |
793 | return -EFAULT; | 826 | return -EFAULT; |
794 | if ((ret = findintfep(ps->dev, ep)) < 0) | 827 | ret = findintfep(ps->dev, ep); |
828 | if (ret < 0) | ||
795 | return ret; | 829 | return ret; |
796 | if ((ret = checkintf(ps, ret))) | 830 | ret = checkintf(ps, ret); |
831 | if (ret) | ||
797 | return ret; | 832 | return ret; |
798 | if (ep & USB_DIR_IN) | 833 | if (ep & USB_DIR_IN) |
799 | pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); | 834 | pipe = usb_rcvbulkpipe(ps->dev, ep & 0x7f); |
800 | else | 835 | else |
801 | pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); | 836 | pipe = usb_sndbulkpipe(ps->dev, ep & 0x7f); |
802 | 837 | ||
803 | return usb_clear_halt(ps->dev, pipe); | 838 | return usb_clear_halt(ps->dev, pipe); |
804 | } | 839 | } |
805 | |||
806 | 840 | ||
807 | static int proc_getdriver(struct dev_state *ps, void __user *arg) | 841 | static int proc_getdriver(struct dev_state *ps, void __user *arg) |
808 | { | 842 | { |
@@ -856,23 +890,23 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg) | |||
856 | { | 890 | { |
857 | int u; | 891 | int u; |
858 | int status = 0; | 892 | int status = 0; |
859 | struct usb_host_config *actconfig; | 893 | struct usb_host_config *actconfig; |
860 | 894 | ||
861 | if (get_user(u, (int __user *)arg)) | 895 | if (get_user(u, (int __user *)arg)) |
862 | return -EFAULT; | 896 | return -EFAULT; |
863 | 897 | ||
864 | actconfig = ps->dev->actconfig; | 898 | actconfig = ps->dev->actconfig; |
865 | 899 | ||
866 | /* Don't touch the device if any interfaces are claimed. | 900 | /* Don't touch the device if any interfaces are claimed. |
867 | * It could interfere with other drivers' operations, and if | 901 | * It could interfere with other drivers' operations, and if |
868 | * an interface is claimed by usbfs it could easily deadlock. | 902 | * an interface is claimed by usbfs it could easily deadlock. |
869 | */ | 903 | */ |
870 | if (actconfig) { | 904 | if (actconfig) { |
871 | int i; | 905 | int i; |
872 | 906 | ||
873 | for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) { | 907 | for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) { |
874 | if (usb_interface_claimed(actconfig->interface[i])) { | 908 | if (usb_interface_claimed(actconfig->interface[i])) { |
875 | dev_warn (&ps->dev->dev, | 909 | dev_warn(&ps->dev->dev, |
876 | "usbfs: interface %d claimed by %s " | 910 | "usbfs: interface %d claimed by %s " |
877 | "while '%s' sets config #%d\n", | 911 | "while '%s' sets config #%d\n", |
878 | actconfig->interface[i] | 912 | actconfig->interface[i] |
@@ -881,11 +915,11 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg) | |||
881 | actconfig->interface[i] | 915 | actconfig->interface[i] |
882 | ->dev.driver->name, | 916 | ->dev.driver->name, |
883 | current->comm, u); | 917 | current->comm, u); |
884 | status = -EBUSY; | 918 | status = -EBUSY; |
885 | break; | 919 | break; |
886 | } | 920 | } |
887 | } | 921 | } |
888 | } | 922 | } |
889 | 923 | ||
890 | /* SET_CONFIGURATION is often abused as a "cheap" driver reset, | 924 | /* SET_CONFIGURATION is often abused as a "cheap" driver reset, |
891 | * so avoid usb_set_configuration()'s kick to sysfs | 925 | * so avoid usb_set_configuration()'s kick to sysfs |
@@ -901,8 +935,8 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg) | |||
901 | } | 935 | } |
902 | 936 | ||
903 | static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | 937 | static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, |
904 | struct usbdevfs_iso_packet_desc __user *iso_frame_desc, | 938 | struct usbdevfs_iso_packet_desc __user *iso_frame_desc, |
905 | void __user *arg) | 939 | void __user *arg) |
906 | { | 940 | { |
907 | struct usbdevfs_iso_packet_desc *isopkt = NULL; | 941 | struct usbdevfs_iso_packet_desc *isopkt = NULL; |
908 | struct usb_host_endpoint *ep; | 942 | struct usb_host_endpoint *ep; |
@@ -917,12 +951,16 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
917 | return -EINVAL; | 951 | return -EINVAL; |
918 | if (!uurb->buffer) | 952 | if (!uurb->buffer) |
919 | return -EINVAL; | 953 | return -EINVAL; |
920 | if (uurb->signr != 0 && (uurb->signr < SIGRTMIN || uurb->signr > SIGRTMAX)) | 954 | if (uurb->signr != 0 && (uurb->signr < SIGRTMIN || |
955 | uurb->signr > SIGRTMAX)) | ||
921 | return -EINVAL; | 956 | return -EINVAL; |
922 | if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { | 957 | if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && |
923 | if ((ifnum = findintfep(ps->dev, uurb->endpoint)) < 0) | 958 | (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { |
959 | ifnum = findintfep(ps->dev, uurb->endpoint); | ||
960 | if (ifnum < 0) | ||
924 | return ifnum; | 961 | return ifnum; |
925 | if ((ret = checkintf(ps, ifnum))) | 962 | ret = checkintf(ps, ifnum); |
963 | if (ret) | ||
926 | return ret; | 964 | return ret; |
927 | } | 965 | } |
928 | if ((uurb->endpoint & USB_ENDPOINT_DIR_MASK) != 0) { | 966 | if ((uurb->endpoint & USB_ENDPOINT_DIR_MASK) != 0) { |
@@ -938,10 +976,13 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
938 | case USBDEVFS_URB_TYPE_CONTROL: | 976 | case USBDEVFS_URB_TYPE_CONTROL: |
939 | if (!usb_endpoint_xfer_control(&ep->desc)) | 977 | if (!usb_endpoint_xfer_control(&ep->desc)) |
940 | return -EINVAL; | 978 | return -EINVAL; |
941 | /* min 8 byte setup packet, max 8 byte setup plus an arbitrary data stage */ | 979 | /* min 8 byte setup packet, |
942 | if (uurb->buffer_length < 8 || uurb->buffer_length > (8 + MAX_USBFS_BUFFER_SIZE)) | 980 | * max 8 byte setup plus an arbitrary data stage */ |
981 | if (uurb->buffer_length < 8 || | ||
982 | uurb->buffer_length > (8 + MAX_USBFS_BUFFER_SIZE)) | ||
943 | return -EINVAL; | 983 | return -EINVAL; |
944 | if (!(dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL))) | 984 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); |
985 | if (!dr) | ||
945 | return -ENOMEM; | 986 | return -ENOMEM; |
946 | if (copy_from_user(dr, uurb->buffer, 8)) { | 987 | if (copy_from_user(dr, uurb->buffer, 8)) { |
947 | kfree(dr); | 988 | kfree(dr); |
@@ -951,7 +992,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
951 | kfree(dr); | 992 | kfree(dr); |
952 | return -EINVAL; | 993 | return -EINVAL; |
953 | } | 994 | } |
954 | if ((ret = check_ctrlrecip(ps, dr->bRequestType, le16_to_cpup(&dr->wIndex)))) { | 995 | ret = check_ctrlrecip(ps, dr->bRequestType, |
996 | le16_to_cpup(&dr->wIndex)); | ||
997 | if (ret) { | ||
955 | kfree(dr); | 998 | kfree(dr); |
956 | return ret; | 999 | return ret; |
957 | } | 1000 | } |
@@ -997,11 +1040,13 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
997 | 1040 | ||
998 | case USBDEVFS_URB_TYPE_ISO: | 1041 | case USBDEVFS_URB_TYPE_ISO: |
999 | /* arbitrary limit */ | 1042 | /* arbitrary limit */ |
1000 | if (uurb->number_of_packets < 1 || uurb->number_of_packets > 128) | 1043 | if (uurb->number_of_packets < 1 || |
1044 | uurb->number_of_packets > 128) | ||
1001 | return -EINVAL; | 1045 | return -EINVAL; |
1002 | if (!usb_endpoint_xfer_isoc(&ep->desc)) | 1046 | if (!usb_endpoint_xfer_isoc(&ep->desc)) |
1003 | return -EINVAL; | 1047 | return -EINVAL; |
1004 | isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * uurb->number_of_packets; | 1048 | isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * |
1049 | uurb->number_of_packets; | ||
1005 | if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) | 1050 | if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) |
1006 | return -ENOMEM; | 1051 | return -ENOMEM; |
1007 | if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { | 1052 | if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { |
@@ -1009,7 +1054,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1009 | return -EFAULT; | 1054 | return -EFAULT; |
1010 | } | 1055 | } |
1011 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { | 1056 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { |
1012 | /* arbitrary limit, sufficient for USB 2.0 high-bandwidth iso */ | 1057 | /* arbitrary limit, |
1058 | * sufficient for USB 2.0 high-bandwidth iso */ | ||
1013 | if (isopkt[u].length > 8192) { | 1059 | if (isopkt[u].length > 8192) { |
1014 | kfree(isopkt); | 1060 | kfree(isopkt); |
1015 | return -EINVAL; | 1061 | return -EINVAL; |
@@ -1039,25 +1085,27 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1039 | default: | 1085 | default: |
1040 | return -EINVAL; | 1086 | return -EINVAL; |
1041 | } | 1087 | } |
1042 | if (!(as = alloc_async(uurb->number_of_packets))) { | 1088 | as = alloc_async(uurb->number_of_packets); |
1089 | if (!as) { | ||
1043 | kfree(isopkt); | 1090 | kfree(isopkt); |
1044 | kfree(dr); | 1091 | kfree(dr); |
1045 | return -ENOMEM; | 1092 | return -ENOMEM; |
1046 | } | 1093 | } |
1047 | if (!(as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL))) { | 1094 | as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL); |
1095 | if (!as->urb->transfer_buffer) { | ||
1048 | kfree(isopkt); | 1096 | kfree(isopkt); |
1049 | kfree(dr); | 1097 | kfree(dr); |
1050 | free_async(as); | 1098 | free_async(as); |
1051 | return -ENOMEM; | 1099 | return -ENOMEM; |
1052 | } | 1100 | } |
1053 | as->urb->dev = ps->dev; | 1101 | as->urb->dev = ps->dev; |
1054 | as->urb->pipe = (uurb->type << 30) | | 1102 | as->urb->pipe = (uurb->type << 30) | |
1055 | __create_pipe(ps->dev, uurb->endpoint & 0xf) | | 1103 | __create_pipe(ps->dev, uurb->endpoint & 0xf) | |
1056 | (uurb->endpoint & USB_DIR_IN); | 1104 | (uurb->endpoint & USB_DIR_IN); |
1057 | as->urb->transfer_flags = uurb->flags | | 1105 | as->urb->transfer_flags = uurb->flags | |
1058 | (is_in ? URB_DIR_IN : URB_DIR_OUT); | 1106 | (is_in ? URB_DIR_IN : URB_DIR_OUT); |
1059 | as->urb->transfer_buffer_length = uurb->buffer_length; | 1107 | as->urb->transfer_buffer_length = uurb->buffer_length; |
1060 | as->urb->setup_packet = (unsigned char*)dr; | 1108 | as->urb->setup_packet = (unsigned char *)dr; |
1061 | as->urb->start_frame = uurb->start_frame; | 1109 | as->urb->start_frame = uurb->start_frame; |
1062 | as->urb->number_of_packets = uurb->number_of_packets; | 1110 | as->urb->number_of_packets = uurb->number_of_packets; |
1063 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || | 1111 | if (uurb->type == USBDEVFS_URB_TYPE_ISO || |
@@ -1065,8 +1113,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1065 | as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); | 1113 | as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); |
1066 | else | 1114 | else |
1067 | as->urb->interval = ep->desc.bInterval; | 1115 | as->urb->interval = ep->desc.bInterval; |
1068 | as->urb->context = as; | 1116 | as->urb->context = as; |
1069 | as->urb->complete = async_completed; | 1117 | as->urb->complete = async_completed; |
1070 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { | 1118 | for (totlen = u = 0; u < uurb->number_of_packets; u++) { |
1071 | as->urb->iso_frame_desc[u].offset = totlen; | 1119 | as->urb->iso_frame_desc[u].offset = totlen; |
1072 | as->urb->iso_frame_desc[u].length = isopkt[u].length; | 1120 | as->urb->iso_frame_desc[u].length = isopkt[u].length; |
@@ -1074,7 +1122,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1074 | } | 1122 | } |
1075 | kfree(isopkt); | 1123 | kfree(isopkt); |
1076 | as->ps = ps; | 1124 | as->ps = ps; |
1077 | as->userurb = arg; | 1125 | as->userurb = arg; |
1078 | if (uurb->endpoint & USB_DIR_IN) | 1126 | if (uurb->endpoint & USB_DIR_IN) |
1079 | as->userbuffer = uurb->buffer; | 1127 | as->userbuffer = uurb->buffer; |
1080 | else | 1128 | else |
@@ -1093,14 +1141,15 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1093 | } | 1141 | } |
1094 | } | 1142 | } |
1095 | snoop_urb(as->urb, as->userurb); | 1143 | snoop_urb(as->urb, as->userurb); |
1096 | async_newpending(as); | 1144 | async_newpending(as); |
1097 | if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { | 1145 | if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { |
1098 | dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret); | 1146 | dev_printk(KERN_DEBUG, &ps->dev->dev, |
1099 | async_removepending(as); | 1147 | "usbfs: usb_submit_urb returned %d\n", ret); |
1100 | free_async(as); | 1148 | async_removepending(as); |
1101 | return ret; | 1149 | free_async(as); |
1102 | } | 1150 | return ret; |
1103 | return 0; | 1151 | } |
1152 | return 0; | ||
1104 | } | 1153 | } |
1105 | 1154 | ||
1106 | static int proc_submiturb(struct dev_state *ps, void __user *arg) | 1155 | static int proc_submiturb(struct dev_state *ps, void __user *arg) |
@@ -1110,7 +1159,9 @@ static int proc_submiturb(struct dev_state *ps, void __user *arg) | |||
1110 | if (copy_from_user(&uurb, arg, sizeof(uurb))) | 1159 | if (copy_from_user(&uurb, arg, sizeof(uurb))) |
1111 | return -EFAULT; | 1160 | return -EFAULT; |
1112 | 1161 | ||
1113 | return proc_do_submiturb(ps, &uurb, (((struct usbdevfs_urb __user *)arg)->iso_frame_desc), arg); | 1162 | return proc_do_submiturb(ps, &uurb, |
1163 | (((struct usbdevfs_urb __user *)arg)->iso_frame_desc), | ||
1164 | arg); | ||
1114 | } | 1165 | } |
1115 | 1166 | ||
1116 | static int proc_unlinkurb(struct dev_state *ps, void __user *arg) | 1167 | static int proc_unlinkurb(struct dev_state *ps, void __user *arg) |
@@ -1132,7 +1183,8 @@ static int processcompl(struct async *as, void __user * __user *arg) | |||
1132 | unsigned int i; | 1183 | unsigned int i; |
1133 | 1184 | ||
1134 | if (as->userbuffer) | 1185 | if (as->userbuffer) |
1135 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, urb->transfer_buffer_length)) | 1186 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, |
1187 | urb->transfer_buffer_length)) | ||
1136 | return -EFAULT; | 1188 | return -EFAULT; |
1137 | if (put_user(as->status, &userurb->status)) | 1189 | if (put_user(as->status, &userurb->status)) |
1138 | return -EFAULT; | 1190 | return -EFAULT; |
@@ -1159,16 +1211,17 @@ static int processcompl(struct async *as, void __user * __user *arg) | |||
1159 | return 0; | 1211 | return 0; |
1160 | } | 1212 | } |
1161 | 1213 | ||
1162 | static struct async* reap_as(struct dev_state *ps) | 1214 | static struct async *reap_as(struct dev_state *ps) |
1163 | { | 1215 | { |
1164 | DECLARE_WAITQUEUE(wait, current); | 1216 | DECLARE_WAITQUEUE(wait, current); |
1165 | struct async *as = NULL; | 1217 | struct async *as = NULL; |
1166 | struct usb_device *dev = ps->dev; | 1218 | struct usb_device *dev = ps->dev; |
1167 | 1219 | ||
1168 | add_wait_queue(&ps->wait, &wait); | 1220 | add_wait_queue(&ps->wait, &wait); |
1169 | for (;;) { | 1221 | for (;;) { |
1170 | __set_current_state(TASK_INTERRUPTIBLE); | 1222 | __set_current_state(TASK_INTERRUPTIBLE); |
1171 | if ((as = async_getcompleted(ps))) | 1223 | as = async_getcompleted(ps); |
1224 | if (as) | ||
1172 | break; | 1225 | break; |
1173 | if (signal_pending(current)) | 1226 | if (signal_pending(current)) |
1174 | break; | 1227 | break; |
@@ -1232,10 +1285,12 @@ static int proc_submiturb_compat(struct dev_state *ps, void __user *arg) | |||
1232 | { | 1285 | { |
1233 | struct usbdevfs_urb uurb; | 1286 | struct usbdevfs_urb uurb; |
1234 | 1287 | ||
1235 | if (get_urb32(&uurb,(struct usbdevfs_urb32 __user *)arg)) | 1288 | if (get_urb32(&uurb, (struct usbdevfs_urb32 __user *)arg)) |
1236 | return -EFAULT; | 1289 | return -EFAULT; |
1237 | 1290 | ||
1238 | return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, arg); | 1291 | return proc_do_submiturb(ps, &uurb, |
1292 | ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, | ||
1293 | arg); | ||
1239 | } | 1294 | } |
1240 | 1295 | ||
1241 | static int processcompl_compat(struct async *as, void __user * __user *arg) | 1296 | static int processcompl_compat(struct async *as, void __user * __user *arg) |
@@ -1246,7 +1301,8 @@ static int processcompl_compat(struct async *as, void __user * __user *arg) | |||
1246 | unsigned int i; | 1301 | unsigned int i; |
1247 | 1302 | ||
1248 | if (as->userbuffer) | 1303 | if (as->userbuffer) |
1249 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, urb->transfer_buffer_length)) | 1304 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, |
1305 | urb->transfer_buffer_length)) | ||
1250 | return -EFAULT; | 1306 | return -EFAULT; |
1251 | if (put_user(as->status, &userurb->status)) | 1307 | if (put_user(as->status, &userurb->status)) |
1252 | return -EFAULT; | 1308 | return -EFAULT; |
@@ -1337,16 +1393,16 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1337 | struct usb_driver *driver = NULL; | 1393 | struct usb_driver *driver = NULL; |
1338 | 1394 | ||
1339 | /* alloc buffer */ | 1395 | /* alloc buffer */ |
1340 | if ((size = _IOC_SIZE (ctl->ioctl_code)) > 0) { | 1396 | if ((size = _IOC_SIZE(ctl->ioctl_code)) > 0) { |
1341 | if ((buf = kmalloc (size, GFP_KERNEL)) == NULL) | 1397 | if ((buf = kmalloc(size, GFP_KERNEL)) == NULL) |
1342 | return -ENOMEM; | 1398 | return -ENOMEM; |
1343 | if ((_IOC_DIR(ctl->ioctl_code) & _IOC_WRITE)) { | 1399 | if ((_IOC_DIR(ctl->ioctl_code) & _IOC_WRITE)) { |
1344 | if (copy_from_user (buf, ctl->data, size)) { | 1400 | if (copy_from_user(buf, ctl->data, size)) { |
1345 | kfree(buf); | 1401 | kfree(buf); |
1346 | return -EFAULT; | 1402 | return -EFAULT; |
1347 | } | 1403 | } |
1348 | } else { | 1404 | } else { |
1349 | memset (buf, 0, size); | 1405 | memset(buf, 0, size); |
1350 | } | 1406 | } |
1351 | } | 1407 | } |
1352 | 1408 | ||
@@ -1357,15 +1413,15 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1357 | 1413 | ||
1358 | if (ps->dev->state != USB_STATE_CONFIGURED) | 1414 | if (ps->dev->state != USB_STATE_CONFIGURED) |
1359 | retval = -EHOSTUNREACH; | 1415 | retval = -EHOSTUNREACH; |
1360 | else if (!(intf = usb_ifnum_to_if (ps->dev, ctl->ifno))) | 1416 | else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno))) |
1361 | retval = -EINVAL; | 1417 | retval = -EINVAL; |
1362 | else switch (ctl->ioctl_code) { | 1418 | else switch (ctl->ioctl_code) { |
1363 | 1419 | ||
1364 | /* disconnect kernel driver from interface */ | 1420 | /* disconnect kernel driver from interface */ |
1365 | case USBDEVFS_DISCONNECT: | 1421 | case USBDEVFS_DISCONNECT: |
1366 | if (intf->dev.driver) { | 1422 | if (intf->dev.driver) { |
1367 | driver = to_usb_driver(intf->dev.driver); | 1423 | driver = to_usb_driver(intf->dev.driver); |
1368 | dev_dbg (&intf->dev, "disconnect by usbfs\n"); | 1424 | dev_dbg(&intf->dev, "disconnect by usbfs\n"); |
1369 | usb_driver_release_interface(driver, intf); | 1425 | usb_driver_release_interface(driver, intf); |
1370 | } else | 1426 | } else |
1371 | retval = -ENODATA; | 1427 | retval = -ENODATA; |
@@ -1373,9 +1429,10 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1373 | 1429 | ||
1374 | /* let kernel drivers try to (re)bind to the interface */ | 1430 | /* let kernel drivers try to (re)bind to the interface */ |
1375 | case USBDEVFS_CONNECT: | 1431 | case USBDEVFS_CONNECT: |
1376 | usb_unlock_device(ps->dev); | 1432 | if (!intf->dev.driver) |
1377 | retval = bus_rescan_devices(intf->dev.bus); | 1433 | retval = device_attach(&intf->dev); |
1378 | usb_lock_device(ps->dev); | 1434 | else |
1435 | retval = -EBUSY; | ||
1379 | break; | 1436 | break; |
1380 | 1437 | ||
1381 | /* talk directly to the interface's driver */ | 1438 | /* talk directly to the interface's driver */ |
@@ -1385,7 +1442,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1385 | if (driver == NULL || driver->ioctl == NULL) { | 1442 | if (driver == NULL || driver->ioctl == NULL) { |
1386 | retval = -ENOTTY; | 1443 | retval = -ENOTTY; |
1387 | } else { | 1444 | } else { |
1388 | retval = driver->ioctl (intf, ctl->ioctl_code, buf); | 1445 | retval = driver->ioctl(intf, ctl->ioctl_code, buf); |
1389 | if (retval == -ENOIOCTLCMD) | 1446 | if (retval == -ENOIOCTLCMD) |
1390 | retval = -ENOTTY; | 1447 | retval = -ENOTTY; |
1391 | } | 1448 | } |
@@ -1393,9 +1450,9 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) | |||
1393 | 1450 | ||
1394 | /* cleanup and return */ | 1451 | /* cleanup and return */ |
1395 | if (retval >= 0 | 1452 | if (retval >= 0 |
1396 | && (_IOC_DIR (ctl->ioctl_code) & _IOC_READ) != 0 | 1453 | && (_IOC_DIR(ctl->ioctl_code) & _IOC_READ) != 0 |
1397 | && size > 0 | 1454 | && size > 0 |
1398 | && copy_to_user (ctl->data, buf, size) != 0) | 1455 | && copy_to_user(ctl->data, buf, size) != 0) |
1399 | retval = -EFAULT; | 1456 | retval = -EFAULT; |
1400 | 1457 | ||
1401 | kfree(buf); | 1458 | kfree(buf); |
@@ -1406,7 +1463,7 @@ static int proc_ioctl_default(struct dev_state *ps, void __user *arg) | |||
1406 | { | 1463 | { |
1407 | struct usbdevfs_ioctl ctrl; | 1464 | struct usbdevfs_ioctl ctrl; |
1408 | 1465 | ||
1409 | if (copy_from_user(&ctrl, arg, sizeof (ctrl))) | 1466 | if (copy_from_user(&ctrl, arg, sizeof(ctrl))) |
1410 | return -EFAULT; | 1467 | return -EFAULT; |
1411 | return proc_ioctl(ps, &ctrl); | 1468 | return proc_ioctl(ps, &ctrl); |
1412 | } | 1469 | } |
@@ -1434,7 +1491,8 @@ static int proc_ioctl_compat(struct dev_state *ps, compat_uptr_t arg) | |||
1434 | * are assuming that somehow the configuration has been prevented from | 1491 | * are assuming that somehow the configuration has been prevented from |
1435 | * changing. But there's no mechanism to ensure that... | 1492 | * changing. But there's no mechanism to ensure that... |
1436 | */ | 1493 | */ |
1437 | static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 1494 | static int usbdev_ioctl(struct inode *inode, struct file *file, |
1495 | unsigned int cmd, unsigned long arg) | ||
1438 | { | 1496 | { |
1439 | struct dev_state *ps = file->private_data; | 1497 | struct dev_state *ps = file->private_data; |
1440 | struct usb_device *dev = ps->dev; | 1498 | struct usb_device *dev = ps->dev; |
@@ -1577,7 +1635,8 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
1577 | } | 1635 | } |
1578 | 1636 | ||
1579 | /* No kernel lock - fine */ | 1637 | /* No kernel lock - fine */ |
1580 | static unsigned int usbdev_poll(struct file *file, struct poll_table_struct *wait) | 1638 | static unsigned int usbdev_poll(struct file *file, |
1639 | struct poll_table_struct *wait) | ||
1581 | { | 1640 | { |
1582 | struct dev_state *ps = file->private_data; | 1641 | struct dev_state *ps = file->private_data; |
1583 | unsigned int mask = 0; | 1642 | unsigned int mask = 0; |
@@ -1648,7 +1707,7 @@ int __init usb_devio_init(void) | |||
1648 | int retval; | 1707 | int retval; |
1649 | 1708 | ||
1650 | retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, | 1709 | retval = register_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX, |
1651 | "usb_device"); | 1710 | "usb_device"); |
1652 | if (retval) { | 1711 | if (retval) { |
1653 | err("unable to register minors for usb_device"); | 1712 | err("unable to register minors for usb_device"); |
1654 | goto out; | 1713 | goto out; |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 7c3aaa9c5402..801b6f142fa7 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -202,10 +202,10 @@ static int usb_probe_interface(struct device *dev) | |||
202 | intf = to_usb_interface(dev); | 202 | intf = to_usb_interface(dev); |
203 | udev = interface_to_usbdev(intf); | 203 | udev = interface_to_usbdev(intf); |
204 | 204 | ||
205 | if (udev->authorized == 0) { | 205 | if (udev->authorized == 0) { |
206 | dev_err(&intf->dev, "Device is not authorized for usage\n"); | 206 | dev_err(&intf->dev, "Device is not authorized for usage\n"); |
207 | return -ENODEV; | 207 | return -ENODEV; |
208 | } | 208 | } |
209 | 209 | ||
210 | id = usb_match_id(intf, driver->id_table); | 210 | id = usb_match_id(intf, driver->id_table); |
211 | if (!id) | 211 | if (!id) |
@@ -299,7 +299,7 @@ static int usb_unbind_interface(struct device *dev) | |||
299 | * lock. | 299 | * lock. |
300 | */ | 300 | */ |
301 | int usb_driver_claim_interface(struct usb_driver *driver, | 301 | int usb_driver_claim_interface(struct usb_driver *driver, |
302 | struct usb_interface *iface, void* priv) | 302 | struct usb_interface *iface, void *priv) |
303 | { | 303 | { |
304 | struct device *dev = &iface->dev; | 304 | struct device *dev = &iface->dev; |
305 | struct usb_device *udev = interface_to_usbdev(iface); | 305 | struct usb_device *udev = interface_to_usbdev(iface); |
@@ -325,7 +325,7 @@ int usb_driver_claim_interface(struct usb_driver *driver, | |||
325 | 325 | ||
326 | return retval; | 326 | return retval; |
327 | } | 327 | } |
328 | EXPORT_SYMBOL(usb_driver_claim_interface); | 328 | EXPORT_SYMBOL_GPL(usb_driver_claim_interface); |
329 | 329 | ||
330 | /** | 330 | /** |
331 | * usb_driver_release_interface - unbind a driver from an interface | 331 | * usb_driver_release_interface - unbind a driver from an interface |
@@ -370,7 +370,7 @@ void usb_driver_release_interface(struct usb_driver *driver, | |||
370 | iface->needs_remote_wakeup = 0; | 370 | iface->needs_remote_wakeup = 0; |
371 | usb_pm_unlock(udev); | 371 | usb_pm_unlock(udev); |
372 | } | 372 | } |
373 | EXPORT_SYMBOL(usb_driver_release_interface); | 373 | EXPORT_SYMBOL_GPL(usb_driver_release_interface); |
374 | 374 | ||
375 | /* returns 0 if no match, 1 if match */ | 375 | /* returns 0 if no match, 1 if match */ |
376 | int usb_match_device(struct usb_device *dev, const struct usb_device_id *id) | 376 | int usb_match_device(struct usb_device *dev, const struct usb_device_id *id) |
@@ -398,7 +398,7 @@ int usb_match_device(struct usb_device *dev, const struct usb_device_id *id) | |||
398 | return 0; | 398 | return 0; |
399 | 399 | ||
400 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && | 400 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && |
401 | (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) | 401 | (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) |
402 | return 0; | 402 | return 0; |
403 | 403 | ||
404 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && | 404 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && |
@@ -534,15 +534,15 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface, | |||
534 | id->driver_info is the way to create an entry that | 534 | id->driver_info is the way to create an entry that |
535 | indicates that the driver want to examine every | 535 | indicates that the driver want to examine every |
536 | device and interface. */ | 536 | device and interface. */ |
537 | for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass || | 537 | for (; id->idVendor || id->idProduct || id->bDeviceClass || |
538 | id->driver_info; id++) { | 538 | id->bInterfaceClass || id->driver_info; id++) { |
539 | if (usb_match_one_id(interface, id)) | 539 | if (usb_match_one_id(interface, id)) |
540 | return id; | 540 | return id; |
541 | } | 541 | } |
542 | 542 | ||
543 | return NULL; | 543 | return NULL; |
544 | } | 544 | } |
545 | EXPORT_SYMBOL_GPL_FUTURE(usb_match_id); | 545 | EXPORT_SYMBOL_GPL(usb_match_id); |
546 | 546 | ||
547 | static int usb_device_match(struct device *dev, struct device_driver *drv) | 547 | static int usb_device_match(struct device *dev, struct device_driver *drv) |
548 | { | 548 | { |
@@ -586,7 +586,7 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
586 | struct usb_device *usb_dev; | 586 | struct usb_device *usb_dev; |
587 | 587 | ||
588 | /* driver is often null here; dev_dbg() would oops */ | 588 | /* driver is often null here; dev_dbg() would oops */ |
589 | pr_debug ("usb %s: uevent\n", dev->bus_id); | 589 | pr_debug("usb %s: uevent\n", dev->bus_id); |
590 | 590 | ||
591 | if (is_usb_device(dev)) | 591 | if (is_usb_device(dev)) |
592 | usb_dev = to_usb_device(dev); | 592 | usb_dev = to_usb_device(dev); |
@@ -596,11 +596,11 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
596 | } | 596 | } |
597 | 597 | ||
598 | if (usb_dev->devnum < 0) { | 598 | if (usb_dev->devnum < 0) { |
599 | pr_debug ("usb %s: already deleted?\n", dev->bus_id); | 599 | pr_debug("usb %s: already deleted?\n", dev->bus_id); |
600 | return -ENODEV; | 600 | return -ENODEV; |
601 | } | 601 | } |
602 | if (!usb_dev->bus) { | 602 | if (!usb_dev->bus) { |
603 | pr_debug ("usb %s: bus removed?\n", dev->bus_id); | 603 | pr_debug("usb %s: bus removed?\n", dev->bus_id); |
604 | return -ENODEV; | 604 | return -ENODEV; |
605 | } | 605 | } |
606 | 606 | ||
@@ -745,7 +745,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner, | |||
745 | 745 | ||
746 | return retval; | 746 | return retval; |
747 | } | 747 | } |
748 | EXPORT_SYMBOL_GPL_FUTURE(usb_register_driver); | 748 | EXPORT_SYMBOL_GPL(usb_register_driver); |
749 | 749 | ||
750 | /** | 750 | /** |
751 | * usb_deregister - unregister a USB interface driver | 751 | * usb_deregister - unregister a USB interface driver |
@@ -769,7 +769,7 @@ void usb_deregister(struct usb_driver *driver) | |||
769 | 769 | ||
770 | usbfs_update_special(); | 770 | usbfs_update_special(); |
771 | } | 771 | } |
772 | EXPORT_SYMBOL_GPL_FUTURE(usb_deregister); | 772 | EXPORT_SYMBOL_GPL(usb_deregister); |
773 | 773 | ||
774 | #ifdef CONFIG_PM | 774 | #ifdef CONFIG_PM |
775 | 775 | ||
@@ -854,8 +854,10 @@ static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg) | |||
854 | dev_err(&intf->dev, "%s error %d\n", | 854 | dev_err(&intf->dev, "%s error %d\n", |
855 | "suspend", status); | 855 | "suspend", status); |
856 | } else { | 856 | } else { |
857 | // FIXME else if there's no suspend method, disconnect... | 857 | /* |
858 | // Not possible if auto_pm is set... | 858 | * FIXME else if there's no suspend method, disconnect... |
859 | * Not possible if auto_pm is set... | ||
860 | */ | ||
859 | dev_warn(&intf->dev, "no suspend for driver %s?\n", | 861 | dev_warn(&intf->dev, "no suspend for driver %s?\n", |
860 | driver->name); | 862 | driver->name); |
861 | mark_quiesced(intf); | 863 | mark_quiesced(intf); |
@@ -894,7 +896,7 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume) | |||
894 | dev_err(&intf->dev, "%s error %d\n", | 896 | dev_err(&intf->dev, "%s error %d\n", |
895 | "reset_resume", status); | 897 | "reset_resume", status); |
896 | } else { | 898 | } else { |
897 | // status = -EOPNOTSUPP; | 899 | /* status = -EOPNOTSUPP; */ |
898 | dev_warn(&intf->dev, "no %s for driver %s?\n", | 900 | dev_warn(&intf->dev, "no %s for driver %s?\n", |
899 | "reset_resume", driver->name); | 901 | "reset_resume", driver->name); |
900 | } | 902 | } |
@@ -905,7 +907,7 @@ static int usb_resume_interface(struct usb_interface *intf, int reset_resume) | |||
905 | dev_err(&intf->dev, "%s error %d\n", | 907 | dev_err(&intf->dev, "%s error %d\n", |
906 | "resume", status); | 908 | "resume", status); |
907 | } else { | 909 | } else { |
908 | // status = -EOPNOTSUPP; | 910 | /* status = -EOPNOTSUPP; */ |
909 | dev_warn(&intf->dev, "no %s for driver %s?\n", | 911 | dev_warn(&intf->dev, "no %s for driver %s?\n", |
910 | "resume", driver->name); | 912 | "resume", driver->name); |
911 | } | 913 | } |
@@ -1175,7 +1177,7 @@ static int usb_resume_both(struct usb_device *udev) | |||
1175 | * so if a root hub's controller is suspended | 1177 | * so if a root hub's controller is suspended |
1176 | * then we're stuck. */ | 1178 | * then we're stuck. */ |
1177 | status = usb_resume_device(udev); | 1179 | status = usb_resume_device(udev); |
1178 | } | 1180 | } |
1179 | } else { | 1181 | } else { |
1180 | 1182 | ||
1181 | /* Needed for setting udev->dev.power.power_state.event, | 1183 | /* Needed for setting udev->dev.power.power_state.event, |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 5d860bc9b421..8133c99c6c5c 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -204,7 +204,7 @@ int usb_register_dev(struct usb_interface *intf, | |||
204 | exit: | 204 | exit: |
205 | return retval; | 205 | return retval; |
206 | } | 206 | } |
207 | EXPORT_SYMBOL(usb_register_dev); | 207 | EXPORT_SYMBOL_GPL(usb_register_dev); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * usb_deregister_dev - deregister a USB device's dynamic minor. | 210 | * usb_deregister_dev - deregister a USB device's dynamic minor. |
@@ -245,4 +245,4 @@ void usb_deregister_dev(struct usb_interface *intf, | |||
245 | intf->minor = -1; | 245 | intf->minor = -1; |
246 | destroy_usb_class(); | 246 | destroy_usb_class(); |
247 | } | 247 | } |
248 | EXPORT_SYMBOL(usb_deregister_dev); | 248 | EXPORT_SYMBOL_GPL(usb_deregister_dev); |
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 3fb9af80cbf4..84760ddbc332 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * (C) Copyright David Brownell 2000-2002 | 2 | * (C) Copyright David Brownell 2000-2002 |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU General Public License as published by the | 5 | * under the terms of the GNU General Public License as published by the |
6 | * Free Software Foundation; either version 2 of the License, or (at your | 6 | * Free Software Foundation; either version 2 of the License, or (at your |
@@ -55,7 +55,7 @@ | |||
55 | * | 55 | * |
56 | * Store this function in the HCD's struct pci_driver as probe(). | 56 | * Store this function in the HCD's struct pci_driver as probe(). |
57 | */ | 57 | */ |
58 | int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) | 58 | int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) |
59 | { | 59 | { |
60 | struct hc_driver *driver; | 60 | struct hc_driver *driver; |
61 | struct usb_hcd *hcd; | 61 | struct usb_hcd *hcd; |
@@ -64,66 +64,71 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
64 | if (usb_disabled()) | 64 | if (usb_disabled()) |
65 | return -ENODEV; | 65 | return -ENODEV; |
66 | 66 | ||
67 | if (!id || !(driver = (struct hc_driver *) id->driver_data)) | 67 | if (!id) |
68 | return -EINVAL; | ||
69 | driver = (struct hc_driver *)id->driver_data; | ||
70 | if (!driver) | ||
68 | return -EINVAL; | 71 | return -EINVAL; |
69 | 72 | ||
70 | if (pci_enable_device (dev) < 0) | 73 | if (pci_enable_device(dev) < 0) |
71 | return -ENODEV; | 74 | return -ENODEV; |
72 | dev->current_state = PCI_D0; | 75 | dev->current_state = PCI_D0; |
73 | dev->dev.power.power_state = PMSG_ON; | 76 | dev->dev.power.power_state = PMSG_ON; |
74 | 77 | ||
75 | if (!dev->irq) { | 78 | if (!dev->irq) { |
76 | dev_err (&dev->dev, | 79 | dev_err(&dev->dev, |
77 | "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", | 80 | "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", |
78 | pci_name(dev)); | 81 | pci_name(dev)); |
79 | retval = -ENODEV; | 82 | retval = -ENODEV; |
80 | goto err1; | 83 | goto err1; |
81 | } | 84 | } |
82 | 85 | ||
83 | hcd = usb_create_hcd (driver, &dev->dev, pci_name(dev)); | 86 | hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev)); |
84 | if (!hcd) { | 87 | if (!hcd) { |
85 | retval = -ENOMEM; | 88 | retval = -ENOMEM; |
86 | goto err1; | 89 | goto err1; |
87 | } | 90 | } |
88 | 91 | ||
89 | if (driver->flags & HCD_MEMORY) { // EHCI, OHCI | 92 | if (driver->flags & HCD_MEMORY) { |
90 | hcd->rsrc_start = pci_resource_start (dev, 0); | 93 | /* EHCI, OHCI */ |
91 | hcd->rsrc_len = pci_resource_len (dev, 0); | 94 | hcd->rsrc_start = pci_resource_start(dev, 0); |
92 | if (!request_mem_region (hcd->rsrc_start, hcd->rsrc_len, | 95 | hcd->rsrc_len = pci_resource_len(dev, 0); |
96 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
93 | driver->description)) { | 97 | driver->description)) { |
94 | dev_dbg (&dev->dev, "controller already in use\n"); | 98 | dev_dbg(&dev->dev, "controller already in use\n"); |
95 | retval = -EBUSY; | 99 | retval = -EBUSY; |
96 | goto err2; | 100 | goto err2; |
97 | } | 101 | } |
98 | hcd->regs = ioremap_nocache (hcd->rsrc_start, hcd->rsrc_len); | 102 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); |
99 | if (hcd->regs == NULL) { | 103 | if (hcd->regs == NULL) { |
100 | dev_dbg (&dev->dev, "error mapping memory\n"); | 104 | dev_dbg(&dev->dev, "error mapping memory\n"); |
101 | retval = -EFAULT; | 105 | retval = -EFAULT; |
102 | goto err3; | 106 | goto err3; |
103 | } | 107 | } |
104 | 108 | ||
105 | } else { // UHCI | 109 | } else { |
110 | /* UHCI */ | ||
106 | int region; | 111 | int region; |
107 | 112 | ||
108 | for (region = 0; region < PCI_ROM_RESOURCE; region++) { | 113 | for (region = 0; region < PCI_ROM_RESOURCE; region++) { |
109 | if (!(pci_resource_flags (dev, region) & | 114 | if (!(pci_resource_flags(dev, region) & |
110 | IORESOURCE_IO)) | 115 | IORESOURCE_IO)) |
111 | continue; | 116 | continue; |
112 | 117 | ||
113 | hcd->rsrc_start = pci_resource_start (dev, region); | 118 | hcd->rsrc_start = pci_resource_start(dev, region); |
114 | hcd->rsrc_len = pci_resource_len (dev, region); | 119 | hcd->rsrc_len = pci_resource_len(dev, region); |
115 | if (request_region (hcd->rsrc_start, hcd->rsrc_len, | 120 | if (request_region(hcd->rsrc_start, hcd->rsrc_len, |
116 | driver->description)) | 121 | driver->description)) |
117 | break; | 122 | break; |
118 | } | 123 | } |
119 | if (region == PCI_ROM_RESOURCE) { | 124 | if (region == PCI_ROM_RESOURCE) { |
120 | dev_dbg (&dev->dev, "no i/o regions available\n"); | 125 | dev_dbg(&dev->dev, "no i/o regions available\n"); |
121 | retval = -EBUSY; | 126 | retval = -EBUSY; |
122 | goto err1; | 127 | goto err1; |
123 | } | 128 | } |
124 | } | 129 | } |
125 | 130 | ||
126 | pci_set_master (dev); | 131 | pci_set_master(dev); |
127 | 132 | ||
128 | retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); | 133 | retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); |
129 | if (retval != 0) | 134 | if (retval != 0) |
@@ -132,19 +137,19 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
132 | 137 | ||
133 | err4: | 138 | err4: |
134 | if (driver->flags & HCD_MEMORY) { | 139 | if (driver->flags & HCD_MEMORY) { |
135 | iounmap (hcd->regs); | 140 | iounmap(hcd->regs); |
136 | err3: | 141 | err3: |
137 | release_mem_region (hcd->rsrc_start, hcd->rsrc_len); | 142 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
138 | } else | 143 | } else |
139 | release_region (hcd->rsrc_start, hcd->rsrc_len); | 144 | release_region(hcd->rsrc_start, hcd->rsrc_len); |
140 | err2: | 145 | err2: |
141 | usb_put_hcd (hcd); | 146 | usb_put_hcd(hcd); |
142 | err1: | 147 | err1: |
143 | pci_disable_device (dev); | 148 | pci_disable_device(dev); |
144 | dev_err (&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); | 149 | dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval); |
145 | return retval; | 150 | return retval; |
146 | } | 151 | } |
147 | EXPORT_SYMBOL (usb_hcd_pci_probe); | 152 | EXPORT_SYMBOL_GPL(usb_hcd_pci_probe); |
148 | 153 | ||
149 | 154 | ||
150 | /* may be called without controller electrically present */ | 155 | /* may be called without controller electrically present */ |
@@ -161,7 +166,7 @@ EXPORT_SYMBOL (usb_hcd_pci_probe); | |||
161 | * | 166 | * |
162 | * Store this function in the HCD's struct pci_driver as remove(). | 167 | * Store this function in the HCD's struct pci_driver as remove(). |
163 | */ | 168 | */ |
164 | void usb_hcd_pci_remove (struct pci_dev *dev) | 169 | void usb_hcd_pci_remove(struct pci_dev *dev) |
165 | { | 170 | { |
166 | struct usb_hcd *hcd; | 171 | struct usb_hcd *hcd; |
167 | 172 | ||
@@ -169,17 +174,17 @@ void usb_hcd_pci_remove (struct pci_dev *dev) | |||
169 | if (!hcd) | 174 | if (!hcd) |
170 | return; | 175 | return; |
171 | 176 | ||
172 | usb_remove_hcd (hcd); | 177 | usb_remove_hcd(hcd); |
173 | if (hcd->driver->flags & HCD_MEMORY) { | 178 | if (hcd->driver->flags & HCD_MEMORY) { |
174 | iounmap (hcd->regs); | 179 | iounmap(hcd->regs); |
175 | release_mem_region (hcd->rsrc_start, hcd->rsrc_len); | 180 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
176 | } else { | 181 | } else { |
177 | release_region (hcd->rsrc_start, hcd->rsrc_len); | 182 | release_region(hcd->rsrc_start, hcd->rsrc_len); |
178 | } | 183 | } |
179 | usb_put_hcd (hcd); | 184 | usb_put_hcd(hcd); |
180 | pci_disable_device(dev); | 185 | pci_disable_device(dev); |
181 | } | 186 | } |
182 | EXPORT_SYMBOL (usb_hcd_pci_remove); | 187 | EXPORT_SYMBOL_GPL(usb_hcd_pci_remove); |
183 | 188 | ||
184 | 189 | ||
185 | #ifdef CONFIG_PM | 190 | #ifdef CONFIG_PM |
@@ -191,7 +196,7 @@ EXPORT_SYMBOL (usb_hcd_pci_remove); | |||
191 | * | 196 | * |
192 | * Store this function in the HCD's struct pci_driver as suspend(). | 197 | * Store this function in the HCD's struct pci_driver as suspend(). |
193 | */ | 198 | */ |
194 | int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | 199 | int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message) |
195 | { | 200 | { |
196 | struct usb_hcd *hcd; | 201 | struct usb_hcd *hcd; |
197 | int retval = 0; | 202 | int retval = 0; |
@@ -246,12 +251,18 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | |||
246 | 251 | ||
247 | /* no DMA or IRQs except when HC is active */ | 252 | /* no DMA or IRQs except when HC is active */ |
248 | if (dev->current_state == PCI_D0) { | 253 | if (dev->current_state == PCI_D0) { |
249 | pci_save_state (dev); | 254 | pci_save_state(dev); |
250 | pci_disable_device (dev); | 255 | pci_disable_device(dev); |
256 | } | ||
257 | |||
258 | if (message.event == PM_EVENT_FREEZE || | ||
259 | message.event == PM_EVENT_PRETHAW) { | ||
260 | dev_dbg(hcd->self.controller, "--> no state change\n"); | ||
261 | goto done; | ||
251 | } | 262 | } |
252 | 263 | ||
253 | if (!has_pci_pm) { | 264 | if (!has_pci_pm) { |
254 | dev_dbg (hcd->self.controller, "--> PCI D0/legacy\n"); | 265 | dev_dbg(hcd->self.controller, "--> PCI D0/legacy\n"); |
255 | goto done; | 266 | goto done; |
256 | } | 267 | } |
257 | 268 | ||
@@ -260,30 +271,30 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | |||
260 | * PCI_D3 (but not PCI_D1 or PCI_D2) is allowed to reset | 271 | * PCI_D3 (but not PCI_D1 or PCI_D2) is allowed to reset |
261 | * some device state (e.g. as part of clock reinit). | 272 | * some device state (e.g. as part of clock reinit). |
262 | */ | 273 | */ |
263 | retval = pci_set_power_state (dev, PCI_D3hot); | 274 | retval = pci_set_power_state(dev, PCI_D3hot); |
264 | suspend_report_result(pci_set_power_state, retval); | 275 | suspend_report_result(pci_set_power_state, retval); |
265 | if (retval == 0) { | 276 | if (retval == 0) { |
266 | int wake = device_can_wakeup(&hcd->self.root_hub->dev); | 277 | int wake = device_can_wakeup(&hcd->self.root_hub->dev); |
267 | 278 | ||
268 | wake = wake && device_may_wakeup(hcd->self.controller); | 279 | wake = wake && device_may_wakeup(hcd->self.controller); |
269 | 280 | ||
270 | dev_dbg (hcd->self.controller, "--> PCI D3%s\n", | 281 | dev_dbg(hcd->self.controller, "--> PCI D3%s\n", |
271 | wake ? "/wakeup" : ""); | 282 | wake ? "/wakeup" : ""); |
272 | 283 | ||
273 | /* Ignore these return values. We rely on pci code to | 284 | /* Ignore these return values. We rely on pci code to |
274 | * reject requests the hardware can't implement, rather | 285 | * reject requests the hardware can't implement, rather |
275 | * than coding the same thing. | 286 | * than coding the same thing. |
276 | */ | 287 | */ |
277 | (void) pci_enable_wake (dev, PCI_D3hot, wake); | 288 | (void) pci_enable_wake(dev, PCI_D3hot, wake); |
278 | (void) pci_enable_wake (dev, PCI_D3cold, wake); | 289 | (void) pci_enable_wake(dev, PCI_D3cold, wake); |
279 | } else { | 290 | } else { |
280 | dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", | 291 | dev_dbg(&dev->dev, "PCI D3 suspend fail, %d\n", |
281 | retval); | 292 | retval); |
282 | (void) usb_hcd_pci_resume (dev); | 293 | (void) usb_hcd_pci_resume(dev); |
283 | } | 294 | } |
284 | 295 | ||
285 | } else if (hcd->state != HC_STATE_HALT) { | 296 | } else if (hcd->state != HC_STATE_HALT) { |
286 | dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", | 297 | dev_dbg(hcd->self.controller, "hcd state %d; not suspended\n", |
287 | hcd->state); | 298 | hcd->state); |
288 | WARN_ON(1); | 299 | WARN_ON(1); |
289 | retval = -EINVAL; | 300 | retval = -EINVAL; |
@@ -298,7 +309,7 @@ done: | |||
298 | if (machine_is(powermac)) { | 309 | if (machine_is(powermac)) { |
299 | struct device_node *of_node; | 310 | struct device_node *of_node; |
300 | 311 | ||
301 | of_node = pci_device_to_OF_node (dev); | 312 | of_node = pci_device_to_OF_node(dev); |
302 | if (of_node) | 313 | if (of_node) |
303 | pmac_call_feature(PMAC_FTR_USB_ENABLE, | 314 | pmac_call_feature(PMAC_FTR_USB_ENABLE, |
304 | of_node, 0, 0); | 315 | of_node, 0, 0); |
@@ -308,7 +319,7 @@ done: | |||
308 | 319 | ||
309 | return retval; | 320 | return retval; |
310 | } | 321 | } |
311 | EXPORT_SYMBOL (usb_hcd_pci_suspend); | 322 | EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend); |
312 | 323 | ||
313 | /** | 324 | /** |
314 | * usb_hcd_pci_resume - power management resume of a PCI-based HCD | 325 | * usb_hcd_pci_resume - power management resume of a PCI-based HCD |
@@ -316,14 +327,14 @@ EXPORT_SYMBOL (usb_hcd_pci_suspend); | |||
316 | * | 327 | * |
317 | * Store this function in the HCD's struct pci_driver as resume(). | 328 | * Store this function in the HCD's struct pci_driver as resume(). |
318 | */ | 329 | */ |
319 | int usb_hcd_pci_resume (struct pci_dev *dev) | 330 | int usb_hcd_pci_resume(struct pci_dev *dev) |
320 | { | 331 | { |
321 | struct usb_hcd *hcd; | 332 | struct usb_hcd *hcd; |
322 | int retval; | 333 | int retval; |
323 | 334 | ||
324 | hcd = pci_get_drvdata(dev); | 335 | hcd = pci_get_drvdata(dev); |
325 | if (hcd->state != HC_STATE_SUSPENDED) { | 336 | if (hcd->state != HC_STATE_SUSPENDED) { |
326 | dev_dbg (hcd->self.controller, | 337 | dev_dbg(hcd->self.controller, |
327 | "can't resume, not suspended!\n"); | 338 | "can't resume, not suspended!\n"); |
328 | return 0; | 339 | return 0; |
329 | } | 340 | } |
@@ -333,9 +344,9 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
333 | if (machine_is(powermac)) { | 344 | if (machine_is(powermac)) { |
334 | struct device_node *of_node; | 345 | struct device_node *of_node; |
335 | 346 | ||
336 | of_node = pci_device_to_OF_node (dev); | 347 | of_node = pci_device_to_OF_node(dev); |
337 | if (of_node) | 348 | if (of_node) |
338 | pmac_call_feature (PMAC_FTR_USB_ENABLE, | 349 | pmac_call_feature(PMAC_FTR_USB_ENABLE, |
339 | of_node, 0, 1); | 350 | of_node, 0, 1); |
340 | } | 351 | } |
341 | #endif | 352 | #endif |
@@ -374,8 +385,8 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
374 | } | 385 | } |
375 | #endif | 386 | #endif |
376 | /* yes, ignore these results too... */ | 387 | /* yes, ignore these results too... */ |
377 | (void) pci_enable_wake (dev, dev->current_state, 0); | 388 | (void) pci_enable_wake(dev, dev->current_state, 0); |
378 | (void) pci_enable_wake (dev, PCI_D3cold, 0); | 389 | (void) pci_enable_wake(dev, PCI_D3cold, 0); |
379 | } else { | 390 | } else { |
380 | /* Same basic cases: clean (powered/not), dirty */ | 391 | /* Same basic cases: clean (powered/not), dirty */ |
381 | dev_dbg(hcd->self.controller, "PCI legacy resume\n"); | 392 | dev_dbg(hcd->self.controller, "PCI legacy resume\n"); |
@@ -386,14 +397,14 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
386 | * but that won't re-enable bus mastering. Yet pci_disable_device() | 397 | * but that won't re-enable bus mastering. Yet pci_disable_device() |
387 | * explicitly disables bus mastering... | 398 | * explicitly disables bus mastering... |
388 | */ | 399 | */ |
389 | retval = pci_enable_device (dev); | 400 | retval = pci_enable_device(dev); |
390 | if (retval < 0) { | 401 | if (retval < 0) { |
391 | dev_err (hcd->self.controller, | 402 | dev_err(hcd->self.controller, |
392 | "can't re-enable after resume, %d!\n", retval); | 403 | "can't re-enable after resume, %d!\n", retval); |
393 | return retval; | 404 | return retval; |
394 | } | 405 | } |
395 | pci_set_master (dev); | 406 | pci_set_master(dev); |
396 | pci_restore_state (dev); | 407 | pci_restore_state(dev); |
397 | 408 | ||
398 | dev->dev.power.power_state = PMSG_ON; | 409 | dev->dev.power.power_state = PMSG_ON; |
399 | 410 | ||
@@ -402,15 +413,15 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
402 | if (hcd->driver->resume) { | 413 | if (hcd->driver->resume) { |
403 | retval = hcd->driver->resume(hcd); | 414 | retval = hcd->driver->resume(hcd); |
404 | if (retval) { | 415 | if (retval) { |
405 | dev_err (hcd->self.controller, | 416 | dev_err(hcd->self.controller, |
406 | "PCI post-resume error %d!\n", retval); | 417 | "PCI post-resume error %d!\n", retval); |
407 | usb_hc_died (hcd); | 418 | usb_hc_died(hcd); |
408 | } | 419 | } |
409 | } | 420 | } |
410 | 421 | ||
411 | return retval; | 422 | return retval; |
412 | } | 423 | } |
413 | EXPORT_SYMBOL (usb_hcd_pci_resume); | 424 | EXPORT_SYMBOL_GPL(usb_hcd_pci_resume); |
414 | 425 | ||
415 | #endif /* CONFIG_PM */ | 426 | #endif /* CONFIG_PM */ |
416 | 427 | ||
@@ -418,7 +429,7 @@ EXPORT_SYMBOL (usb_hcd_pci_resume); | |||
418 | * usb_hcd_pci_shutdown - shutdown host controller | 429 | * usb_hcd_pci_shutdown - shutdown host controller |
419 | * @dev: USB Host Controller being shutdown | 430 | * @dev: USB Host Controller being shutdown |
420 | */ | 431 | */ |
421 | void usb_hcd_pci_shutdown (struct pci_dev *dev) | 432 | void usb_hcd_pci_shutdown(struct pci_dev *dev) |
422 | { | 433 | { |
423 | struct usb_hcd *hcd; | 434 | struct usb_hcd *hcd; |
424 | 435 | ||
@@ -429,5 +440,5 @@ void usb_hcd_pci_shutdown (struct pci_dev *dev) | |||
429 | if (hcd->driver->shutdown) | 440 | if (hcd->driver->shutdown) |
430 | hcd->driver->shutdown(hcd); | 441 | hcd->driver->shutdown(hcd); |
431 | } | 442 | } |
432 | EXPORT_SYMBOL (usb_hcd_pci_shutdown); | 443 | EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown); |
433 | 444 | ||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index d5ed3fa9e304..e52ed1663b3c 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
36 | #include <asm/irq.h> | 36 | #include <asm/irq.h> |
37 | #include <asm/byteorder.h> | 37 | #include <asm/byteorder.h> |
38 | #include <asm/unaligned.h> | ||
38 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
39 | #include <linux/workqueue.h> | 40 | #include <linux/workqueue.h> |
40 | 41 | ||
@@ -131,8 +132,8 @@ static const u8 usb2_rh_dev_descriptor [18] = { | |||
131 | 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ | 132 | 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ |
132 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ | 133 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ |
133 | 134 | ||
134 | 0x00, 0x00, /* __le16 idVendor; */ | 135 | 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ |
135 | 0x00, 0x00, /* __le16 idProduct; */ | 136 | 0x02, 0x00, /* __le16 idProduct; device 0x0002 */ |
136 | KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ | 137 | KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ |
137 | 138 | ||
138 | 0x03, /* __u8 iManufacturer; */ | 139 | 0x03, /* __u8 iManufacturer; */ |
@@ -154,8 +155,8 @@ static const u8 usb11_rh_dev_descriptor [18] = { | |||
154 | 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ | 155 | 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ |
155 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ | 156 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ |
156 | 157 | ||
157 | 0x00, 0x00, /* __le16 idVendor; */ | 158 | 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */ |
158 | 0x00, 0x00, /* __le16 idProduct; */ | 159 | 0x01, 0x00, /* __le16 idProduct; device 0x0001 */ |
159 | KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ | 160 | KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ |
160 | 161 | ||
161 | 0x03, /* __u8 iManufacturer; */ | 162 | 0x03, /* __u8 iManufacturer; */ |
@@ -807,13 +808,13 @@ static int usb_register_bus(struct usb_bus *bus) | |||
807 | } | 808 | } |
808 | set_bit (busnum, busmap.busmap); | 809 | set_bit (busnum, busmap.busmap); |
809 | bus->busnum = busnum; | 810 | bus->busnum = busnum; |
810 | bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0), | 811 | |
811 | bus->controller, "usb_host%d", | 812 | bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0), |
812 | busnum); | 813 | "usb_host%d", busnum); |
813 | result = PTR_ERR(bus->class_dev); | 814 | result = PTR_ERR(bus->dev); |
814 | if (IS_ERR(bus->class_dev)) | 815 | if (IS_ERR(bus->dev)) |
815 | goto error_create_class_dev; | 816 | goto error_create_class_dev; |
816 | class_set_devdata(bus->class_dev, bus); | 817 | dev_set_drvdata(bus->dev, bus); |
817 | 818 | ||
818 | /* Add it to the local list of buses */ | 819 | /* Add it to the local list of buses */ |
819 | list_add (&bus->bus_list, &usb_bus_list); | 820 | list_add (&bus->bus_list, &usb_bus_list); |
@@ -857,7 +858,7 @@ static void usb_deregister_bus (struct usb_bus *bus) | |||
857 | 858 | ||
858 | clear_bit (bus->busnum, busmap.busmap); | 859 | clear_bit (bus->busnum, busmap.busmap); |
859 | 860 | ||
860 | class_device_unregister(bus->class_dev); | 861 | device_unregister(bus->dev); |
861 | } | 862 | } |
862 | 863 | ||
863 | /** | 864 | /** |
@@ -970,7 +971,7 @@ long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount) | |||
970 | return -1; | 971 | return -1; |
971 | } | 972 | } |
972 | } | 973 | } |
973 | EXPORT_SYMBOL (usb_calc_bus_time); | 974 | EXPORT_SYMBOL_GPL(usb_calc_bus_time); |
974 | 975 | ||
975 | 976 | ||
976 | /*-------------------------------------------------------------------------*/ | 977 | /*-------------------------------------------------------------------------*/ |
@@ -1112,48 +1113,177 @@ void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb) | |||
1112 | } | 1113 | } |
1113 | EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep); | 1114 | EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep); |
1114 | 1115 | ||
1115 | static void map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) | 1116 | /* |
1117 | * Some usb host controllers can only perform dma using a small SRAM area. | ||
1118 | * The usb core itself is however optimized for host controllers that can dma | ||
1119 | * using regular system memory - like pci devices doing bus mastering. | ||
1120 | * | ||
1121 | * To support host controllers with limited dma capabilites we provide dma | ||
1122 | * bounce buffers. This feature can be enabled using the HCD_LOCAL_MEM flag. | ||
1123 | * For this to work properly the host controller code must first use the | ||
1124 | * function dma_declare_coherent_memory() to point out which memory area | ||
1125 | * that should be used for dma allocations. | ||
1126 | * | ||
1127 | * The HCD_LOCAL_MEM flag then tells the usb code to allocate all data for | ||
1128 | * dma using dma_alloc_coherent() which in turn allocates from the memory | ||
1129 | * area pointed out with dma_declare_coherent_memory(). | ||
1130 | * | ||
1131 | * So, to summarize... | ||
1132 | * | ||
1133 | * - We need "local" memory, canonical example being | ||
1134 | * a small SRAM on a discrete controller being the | ||
1135 | * only memory that the controller can read ... | ||
1136 | * (a) "normal" kernel memory is no good, and | ||
1137 | * (b) there's not enough to share | ||
1138 | * | ||
1139 | * - The only *portable* hook for such stuff in the | ||
1140 | * DMA framework is dma_declare_coherent_memory() | ||
1141 | * | ||
1142 | * - So we use that, even though the primary requirement | ||
1143 | * is that the memory be "local" (hence addressible | ||
1144 | * by that device), not "coherent". | ||
1145 | * | ||
1146 | */ | ||
1147 | |||
1148 | static int hcd_alloc_coherent(struct usb_bus *bus, | ||
1149 | gfp_t mem_flags, dma_addr_t *dma_handle, | ||
1150 | void **vaddr_handle, size_t size, | ||
1151 | enum dma_data_direction dir) | ||
1152 | { | ||
1153 | unsigned char *vaddr; | ||
1154 | |||
1155 | vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr), | ||
1156 | mem_flags, dma_handle); | ||
1157 | if (!vaddr) | ||
1158 | return -ENOMEM; | ||
1159 | |||
1160 | /* | ||
1161 | * Store the virtual address of the buffer at the end | ||
1162 | * of the allocated dma buffer. The size of the buffer | ||
1163 | * may be uneven so use unaligned functions instead | ||
1164 | * of just rounding up. It makes sense to optimize for | ||
1165 | * memory footprint over access speed since the amount | ||
1166 | * of memory available for dma may be limited. | ||
1167 | */ | ||
1168 | put_unaligned((unsigned long)*vaddr_handle, | ||
1169 | (unsigned long *)(vaddr + size)); | ||
1170 | |||
1171 | if (dir == DMA_TO_DEVICE) | ||
1172 | memcpy(vaddr, *vaddr_handle, size); | ||
1173 | |||
1174 | *vaddr_handle = vaddr; | ||
1175 | return 0; | ||
1176 | } | ||
1177 | |||
1178 | static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle, | ||
1179 | void **vaddr_handle, size_t size, | ||
1180 | enum dma_data_direction dir) | ||
1181 | { | ||
1182 | unsigned char *vaddr = *vaddr_handle; | ||
1183 | |||
1184 | vaddr = (void *)get_unaligned((unsigned long *)(vaddr + size)); | ||
1185 | |||
1186 | if (dir == DMA_FROM_DEVICE) | ||
1187 | memcpy(vaddr, *vaddr_handle, size); | ||
1188 | |||
1189 | hcd_buffer_free(bus, size + sizeof(vaddr), *vaddr_handle, *dma_handle); | ||
1190 | |||
1191 | *vaddr_handle = vaddr; | ||
1192 | *dma_handle = 0; | ||
1193 | } | ||
1194 | |||
1195 | static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, | ||
1196 | gfp_t mem_flags) | ||
1116 | { | 1197 | { |
1198 | enum dma_data_direction dir; | ||
1199 | int ret = 0; | ||
1200 | |||
1117 | /* Map the URB's buffers for DMA access. | 1201 | /* Map the URB's buffers for DMA access. |
1118 | * Lower level HCD code should use *_dma exclusively, | 1202 | * Lower level HCD code should use *_dma exclusively, |
1119 | * unless it uses pio or talks to another transport. | 1203 | * unless it uses pio or talks to another transport. |
1120 | */ | 1204 | */ |
1121 | if (hcd->self.uses_dma && !is_root_hub(urb->dev)) { | 1205 | if (is_root_hub(urb->dev)) |
1122 | if (usb_endpoint_xfer_control(&urb->ep->desc) | 1206 | return 0; |
1123 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) | 1207 | |
1124 | urb->setup_dma = dma_map_single ( | 1208 | if (usb_endpoint_xfer_control(&urb->ep->desc) |
1209 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) { | ||
1210 | if (hcd->self.uses_dma) | ||
1211 | urb->setup_dma = dma_map_single( | ||
1125 | hcd->self.controller, | 1212 | hcd->self.controller, |
1126 | urb->setup_packet, | 1213 | urb->setup_packet, |
1127 | sizeof (struct usb_ctrlrequest), | 1214 | sizeof(struct usb_ctrlrequest), |
1215 | DMA_TO_DEVICE); | ||
1216 | else if (hcd->driver->flags & HCD_LOCAL_MEM) | ||
1217 | ret = hcd_alloc_coherent( | ||
1218 | urb->dev->bus, mem_flags, | ||
1219 | &urb->setup_dma, | ||
1220 | (void **)&urb->setup_packet, | ||
1221 | sizeof(struct usb_ctrlrequest), | ||
1128 | DMA_TO_DEVICE); | 1222 | DMA_TO_DEVICE); |
1129 | if (urb->transfer_buffer_length != 0 | 1223 | } |
1130 | && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) | 1224 | |
1225 | dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | ||
1226 | if (ret == 0 && urb->transfer_buffer_length != 0 | ||
1227 | && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { | ||
1228 | if (hcd->self.uses_dma) | ||
1131 | urb->transfer_dma = dma_map_single ( | 1229 | urb->transfer_dma = dma_map_single ( |
1132 | hcd->self.controller, | 1230 | hcd->self.controller, |
1133 | urb->transfer_buffer, | 1231 | urb->transfer_buffer, |
1134 | urb->transfer_buffer_length, | 1232 | urb->transfer_buffer_length, |
1135 | usb_urb_dir_in(urb) | 1233 | dir); |
1136 | ? DMA_FROM_DEVICE | 1234 | else if (hcd->driver->flags & HCD_LOCAL_MEM) { |
1137 | : DMA_TO_DEVICE); | 1235 | ret = hcd_alloc_coherent( |
1236 | urb->dev->bus, mem_flags, | ||
1237 | &urb->transfer_dma, | ||
1238 | &urb->transfer_buffer, | ||
1239 | urb->transfer_buffer_length, | ||
1240 | dir); | ||
1241 | |||
1242 | if (ret && usb_endpoint_xfer_control(&urb->ep->desc) | ||
1243 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) | ||
1244 | hcd_free_coherent(urb->dev->bus, | ||
1245 | &urb->setup_dma, | ||
1246 | (void **)&urb->setup_packet, | ||
1247 | sizeof(struct usb_ctrlrequest), | ||
1248 | DMA_TO_DEVICE); | ||
1249 | } | ||
1138 | } | 1250 | } |
1251 | return ret; | ||
1139 | } | 1252 | } |
1140 | 1253 | ||
1141 | static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) | 1254 | static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) |
1142 | { | 1255 | { |
1143 | if (hcd->self.uses_dma && !is_root_hub(urb->dev)) { | 1256 | enum dma_data_direction dir; |
1144 | if (usb_endpoint_xfer_control(&urb->ep->desc) | 1257 | |
1145 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) | 1258 | if (is_root_hub(urb->dev)) |
1259 | return; | ||
1260 | |||
1261 | if (usb_endpoint_xfer_control(&urb->ep->desc) | ||
1262 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) { | ||
1263 | if (hcd->self.uses_dma) | ||
1146 | dma_unmap_single(hcd->self.controller, urb->setup_dma, | 1264 | dma_unmap_single(hcd->self.controller, urb->setup_dma, |
1147 | sizeof(struct usb_ctrlrequest), | 1265 | sizeof(struct usb_ctrlrequest), |
1148 | DMA_TO_DEVICE); | 1266 | DMA_TO_DEVICE); |
1149 | if (urb->transfer_buffer_length != 0 | 1267 | else if (hcd->driver->flags & HCD_LOCAL_MEM) |
1150 | && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) | 1268 | hcd_free_coherent(urb->dev->bus, &urb->setup_dma, |
1269 | (void **)&urb->setup_packet, | ||
1270 | sizeof(struct usb_ctrlrequest), | ||
1271 | DMA_TO_DEVICE); | ||
1272 | } | ||
1273 | |||
1274 | dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | ||
1275 | if (urb->transfer_buffer_length != 0 | ||
1276 | && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { | ||
1277 | if (hcd->self.uses_dma) | ||
1151 | dma_unmap_single(hcd->self.controller, | 1278 | dma_unmap_single(hcd->self.controller, |
1152 | urb->transfer_dma, | 1279 | urb->transfer_dma, |
1153 | urb->transfer_buffer_length, | 1280 | urb->transfer_buffer_length, |
1154 | usb_urb_dir_in(urb) | 1281 | dir); |
1155 | ? DMA_FROM_DEVICE | 1282 | else if (hcd->driver->flags & HCD_LOCAL_MEM) |
1156 | : DMA_TO_DEVICE); | 1283 | hcd_free_coherent(urb->dev->bus, &urb->transfer_dma, |
1284 | &urb->transfer_buffer, | ||
1285 | urb->transfer_buffer_length, | ||
1286 | dir); | ||
1157 | } | 1287 | } |
1158 | } | 1288 | } |
1159 | 1289 | ||
@@ -1185,7 +1315,12 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) | |||
1185 | * URBs must be submitted in process context with interrupts | 1315 | * URBs must be submitted in process context with interrupts |
1186 | * enabled. | 1316 | * enabled. |
1187 | */ | 1317 | */ |
1188 | map_urb_for_dma(hcd, urb); | 1318 | status = map_urb_for_dma(hcd, urb, mem_flags); |
1319 | if (unlikely(status)) { | ||
1320 | usbmon_urb_submit_error(&hcd->self, urb, status); | ||
1321 | goto error; | ||
1322 | } | ||
1323 | |||
1189 | if (is_root_hub(urb->dev)) | 1324 | if (is_root_hub(urb->dev)) |
1190 | status = rh_urb_enqueue(hcd, urb); | 1325 | status = rh_urb_enqueue(hcd, urb); |
1191 | else | 1326 | else |
@@ -1194,6 +1329,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) | |||
1194 | if (unlikely(status)) { | 1329 | if (unlikely(status)) { |
1195 | usbmon_urb_submit_error(&hcd->self, urb, status); | 1330 | usbmon_urb_submit_error(&hcd->self, urb, status); |
1196 | unmap_urb_for_dma(hcd, urb); | 1331 | unmap_urb_for_dma(hcd, urb); |
1332 | error: | ||
1197 | urb->hcpriv = NULL; | 1333 | urb->hcpriv = NULL; |
1198 | INIT_LIST_HEAD(&urb->urb_list); | 1334 | INIT_LIST_HEAD(&urb->urb_list); |
1199 | atomic_dec(&urb->use_count); | 1335 | atomic_dec(&urb->use_count); |
@@ -1291,7 +1427,7 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1291 | wake_up (&usb_kill_urb_queue); | 1427 | wake_up (&usb_kill_urb_queue); |
1292 | usb_put_urb (urb); | 1428 | usb_put_urb (urb); |
1293 | } | 1429 | } |
1294 | EXPORT_SYMBOL (usb_hcd_giveback_urb); | 1430 | EXPORT_SYMBOL_GPL(usb_hcd_giveback_urb); |
1295 | 1431 | ||
1296 | /*-------------------------------------------------------------------------*/ | 1432 | /*-------------------------------------------------------------------------*/ |
1297 | 1433 | ||
@@ -1531,7 +1667,7 @@ int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num) | |||
1531 | mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10)); | 1667 | mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10)); |
1532 | return status; | 1668 | return status; |
1533 | } | 1669 | } |
1534 | EXPORT_SYMBOL (usb_bus_start_enum); | 1670 | EXPORT_SYMBOL_GPL(usb_bus_start_enum); |
1535 | 1671 | ||
1536 | #endif | 1672 | #endif |
1537 | 1673 | ||
@@ -1638,7 +1774,7 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, | |||
1638 | "USB Host Controller"; | 1774 | "USB Host Controller"; |
1639 | return hcd; | 1775 | return hcd; |
1640 | } | 1776 | } |
1641 | EXPORT_SYMBOL (usb_create_hcd); | 1777 | EXPORT_SYMBOL_GPL(usb_create_hcd); |
1642 | 1778 | ||
1643 | static void hcd_release (struct kref *kref) | 1779 | static void hcd_release (struct kref *kref) |
1644 | { | 1780 | { |
@@ -1653,14 +1789,14 @@ struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd) | |||
1653 | kref_get (&hcd->kref); | 1789 | kref_get (&hcd->kref); |
1654 | return hcd; | 1790 | return hcd; |
1655 | } | 1791 | } |
1656 | EXPORT_SYMBOL (usb_get_hcd); | 1792 | EXPORT_SYMBOL_GPL(usb_get_hcd); |
1657 | 1793 | ||
1658 | void usb_put_hcd (struct usb_hcd *hcd) | 1794 | void usb_put_hcd (struct usb_hcd *hcd) |
1659 | { | 1795 | { |
1660 | if (hcd) | 1796 | if (hcd) |
1661 | kref_put (&hcd->kref, hcd_release); | 1797 | kref_put (&hcd->kref, hcd_release); |
1662 | } | 1798 | } |
1663 | EXPORT_SYMBOL (usb_put_hcd); | 1799 | EXPORT_SYMBOL_GPL(usb_put_hcd); |
1664 | 1800 | ||
1665 | /** | 1801 | /** |
1666 | * usb_add_hcd - finish generic HCD structure initialization and register | 1802 | * usb_add_hcd - finish generic HCD structure initialization and register |
@@ -1786,7 +1922,7 @@ err_register_bus: | |||
1786 | hcd_buffer_destroy(hcd); | 1922 | hcd_buffer_destroy(hcd); |
1787 | return retval; | 1923 | return retval; |
1788 | } | 1924 | } |
1789 | EXPORT_SYMBOL (usb_add_hcd); | 1925 | EXPORT_SYMBOL_GPL(usb_add_hcd); |
1790 | 1926 | ||
1791 | /** | 1927 | /** |
1792 | * usb_remove_hcd - shutdown processing for generic HCDs | 1928 | * usb_remove_hcd - shutdown processing for generic HCDs |
@@ -1828,7 +1964,7 @@ void usb_remove_hcd(struct usb_hcd *hcd) | |||
1828 | usb_deregister_bus(&hcd->self); | 1964 | usb_deregister_bus(&hcd->self); |
1829 | hcd_buffer_destroy(hcd); | 1965 | hcd_buffer_destroy(hcd); |
1830 | } | 1966 | } |
1831 | EXPORT_SYMBOL (usb_remove_hcd); | 1967 | EXPORT_SYMBOL_GPL(usb_remove_hcd); |
1832 | 1968 | ||
1833 | void | 1969 | void |
1834 | usb_hcd_platform_shutdown(struct platform_device* dev) | 1970 | usb_hcd_platform_shutdown(struct platform_device* dev) |
@@ -1838,7 +1974,7 @@ usb_hcd_platform_shutdown(struct platform_device* dev) | |||
1838 | if (hcd->driver->shutdown) | 1974 | if (hcd->driver->shutdown) |
1839 | hcd->driver->shutdown(hcd); | 1975 | hcd->driver->shutdown(hcd); |
1840 | } | 1976 | } |
1841 | EXPORT_SYMBOL (usb_hcd_platform_shutdown); | 1977 | EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown); |
1842 | 1978 | ||
1843 | /*-------------------------------------------------------------------------*/ | 1979 | /*-------------------------------------------------------------------------*/ |
1844 | 1980 | ||
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 98e24194a4ab..2d1c3d5e47b8 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
@@ -125,7 +125,7 @@ struct usb_hcd { | |||
125 | 125 | ||
126 | /* more shared queuing code would be good; it should support | 126 | /* more shared queuing code would be good; it should support |
127 | * smarter scheduling, handle transaction translators, etc; | 127 | * smarter scheduling, handle transaction translators, etc; |
128 | * input size of periodic table to an interrupt scheduler. | 128 | * input size of periodic table to an interrupt scheduler. |
129 | * (ohci 32, uhci 1024, ehci 256/512/1024). | 129 | * (ohci 32, uhci 1024, ehci 256/512/1024). |
130 | */ | 130 | */ |
131 | 131 | ||
@@ -133,16 +133,16 @@ struct usb_hcd { | |||
133 | * this structure. | 133 | * this structure. |
134 | */ | 134 | */ |
135 | unsigned long hcd_priv[0] | 135 | unsigned long hcd_priv[0] |
136 | __attribute__ ((aligned (sizeof(unsigned long)))); | 136 | __attribute__ ((aligned(sizeof(unsigned long)))); |
137 | }; | 137 | }; |
138 | 138 | ||
139 | /* 2.4 does this a bit differently ... */ | 139 | /* 2.4 does this a bit differently ... */ |
140 | static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd) | 140 | static inline struct usb_bus *hcd_to_bus(struct usb_hcd *hcd) |
141 | { | 141 | { |
142 | return &hcd->self; | 142 | return &hcd->self; |
143 | } | 143 | } |
144 | 144 | ||
145 | static inline struct usb_hcd *bus_to_hcd (struct usb_bus *bus) | 145 | static inline struct usb_hcd *bus_to_hcd(struct usb_bus *bus) |
146 | { | 146 | { |
147 | return container_of(bus, struct usb_hcd, self); | 147 | return container_of(bus, struct usb_hcd, self); |
148 | } | 148 | } |
@@ -165,6 +165,7 @@ struct hc_driver { | |||
165 | 165 | ||
166 | int flags; | 166 | int flags; |
167 | #define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ | 167 | #define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ |
168 | #define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */ | ||
168 | #define HCD_USB11 0x0010 /* USB 1.1 */ | 169 | #define HCD_USB11 0x0010 /* USB 1.1 */ |
169 | #define HCD_USB2 0x0020 /* USB 2.0 */ | 170 | #define HCD_USB2 0x0020 /* USB 2.0 */ |
170 | 171 | ||
@@ -201,15 +202,18 @@ struct hc_driver { | |||
201 | struct usb_host_endpoint *ep); | 202 | struct usb_host_endpoint *ep); |
202 | 203 | ||
203 | /* root hub support */ | 204 | /* root hub support */ |
204 | int (*hub_status_data) (struct usb_hcd *hcd, char *buf); | 205 | int (*hub_status_data) (struct usb_hcd *hcd, char *buf); |
205 | int (*hub_control) (struct usb_hcd *hcd, | 206 | int (*hub_control) (struct usb_hcd *hcd, |
206 | u16 typeReq, u16 wValue, u16 wIndex, | 207 | u16 typeReq, u16 wValue, u16 wIndex, |
207 | char *buf, u16 wLength); | 208 | char *buf, u16 wLength); |
208 | int (*bus_suspend)(struct usb_hcd *); | 209 | int (*bus_suspend)(struct usb_hcd *); |
209 | int (*bus_resume)(struct usb_hcd *); | 210 | int (*bus_resume)(struct usb_hcd *); |
210 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); | 211 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); |
211 | void (*hub_irq_enable)(struct usb_hcd *); | 212 | void (*hub_irq_enable)(struct usb_hcd *); |
212 | /* Needed only if port-change IRQs are level-triggered */ | 213 | /* Needed only if port-change IRQs are level-triggered */ |
214 | |||
215 | /* force handover of high-speed port to full-speed companion */ | ||
216 | void (*relinquish_port)(struct usb_hcd *, int); | ||
213 | }; | 217 | }; |
214 | 218 | ||
215 | extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); | 219 | extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); |
@@ -217,56 +221,56 @@ extern int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, | |||
217 | int status); | 221 | int status); |
218 | extern void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb); | 222 | extern void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb); |
219 | 223 | ||
220 | extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags); | 224 | extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags); |
221 | extern int usb_hcd_unlink_urb (struct urb *urb, int status); | 225 | extern int usb_hcd_unlink_urb(struct urb *urb, int status); |
222 | extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, | 226 | extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, |
223 | int status); | 227 | int status); |
224 | extern void usb_hcd_flush_endpoint(struct usb_device *udev, | 228 | extern void usb_hcd_flush_endpoint(struct usb_device *udev, |
225 | struct usb_host_endpoint *ep); | 229 | struct usb_host_endpoint *ep); |
226 | extern void usb_hcd_disable_endpoint(struct usb_device *udev, | 230 | extern void usb_hcd_disable_endpoint(struct usb_device *udev, |
227 | struct usb_host_endpoint *ep); | 231 | struct usb_host_endpoint *ep); |
228 | extern int usb_hcd_get_frame_number (struct usb_device *udev); | 232 | extern int usb_hcd_get_frame_number(struct usb_device *udev); |
229 | 233 | ||
230 | extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, | 234 | extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver, |
231 | struct device *dev, char *bus_name); | 235 | struct device *dev, char *bus_name); |
232 | extern struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd); | 236 | extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd); |
233 | extern void usb_put_hcd (struct usb_hcd *hcd); | 237 | extern void usb_put_hcd(struct usb_hcd *hcd); |
234 | extern int usb_add_hcd(struct usb_hcd *hcd, | 238 | extern int usb_add_hcd(struct usb_hcd *hcd, |
235 | unsigned int irqnum, unsigned long irqflags); | 239 | unsigned int irqnum, unsigned long irqflags); |
236 | extern void usb_remove_hcd(struct usb_hcd *hcd); | 240 | extern void usb_remove_hcd(struct usb_hcd *hcd); |
237 | 241 | ||
238 | struct platform_device; | 242 | struct platform_device; |
239 | extern void usb_hcd_platform_shutdown(struct platform_device* dev); | 243 | extern void usb_hcd_platform_shutdown(struct platform_device *dev); |
240 | 244 | ||
241 | #ifdef CONFIG_PCI | 245 | #ifdef CONFIG_PCI |
242 | struct pci_dev; | 246 | struct pci_dev; |
243 | struct pci_device_id; | 247 | struct pci_device_id; |
244 | extern int usb_hcd_pci_probe (struct pci_dev *dev, | 248 | extern int usb_hcd_pci_probe(struct pci_dev *dev, |
245 | const struct pci_device_id *id); | 249 | const struct pci_device_id *id); |
246 | extern void usb_hcd_pci_remove (struct pci_dev *dev); | 250 | extern void usb_hcd_pci_remove(struct pci_dev *dev); |
247 | 251 | ||
248 | #ifdef CONFIG_PM | 252 | #ifdef CONFIG_PM |
249 | extern int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t state); | 253 | extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t state); |
250 | extern int usb_hcd_pci_resume (struct pci_dev *dev); | 254 | extern int usb_hcd_pci_resume(struct pci_dev *dev); |
251 | #endif /* CONFIG_PM */ | 255 | #endif /* CONFIG_PM */ |
252 | 256 | ||
253 | extern void usb_hcd_pci_shutdown (struct pci_dev *dev); | 257 | extern void usb_hcd_pci_shutdown(struct pci_dev *dev); |
254 | 258 | ||
255 | #endif /* CONFIG_PCI */ | 259 | #endif /* CONFIG_PCI */ |
256 | 260 | ||
257 | /* pci-ish (pdev null is ok) buffer alloc/mapping support */ | 261 | /* pci-ish (pdev null is ok) buffer alloc/mapping support */ |
258 | int hcd_buffer_create (struct usb_hcd *hcd); | 262 | int hcd_buffer_create(struct usb_hcd *hcd); |
259 | void hcd_buffer_destroy (struct usb_hcd *hcd); | 263 | void hcd_buffer_destroy(struct usb_hcd *hcd); |
260 | 264 | ||
261 | void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, | 265 | void *hcd_buffer_alloc(struct usb_bus *bus, size_t size, |
262 | gfp_t mem_flags, dma_addr_t *dma); | 266 | gfp_t mem_flags, dma_addr_t *dma); |
263 | void hcd_buffer_free (struct usb_bus *bus, size_t size, | 267 | void hcd_buffer_free(struct usb_bus *bus, size_t size, |
264 | void *addr, dma_addr_t dma); | 268 | void *addr, dma_addr_t dma); |
265 | 269 | ||
266 | /* generic bus glue, needed for host controllers that don't use PCI */ | 270 | /* generic bus glue, needed for host controllers that don't use PCI */ |
267 | extern irqreturn_t usb_hcd_irq (int irq, void *__hcd); | 271 | extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); |
268 | 272 | ||
269 | extern void usb_hc_died (struct usb_hcd *hcd); | 273 | extern void usb_hc_died(struct usb_hcd *hcd); |
270 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); | 274 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); |
271 | 275 | ||
272 | /* -------------------------------------------------------------------------- */ | 276 | /* -------------------------------------------------------------------------- */ |
@@ -319,9 +323,9 @@ extern void usb_destroy_configuration(struct usb_device *dev); | |||
319 | * Generic bandwidth allocation constants/support | 323 | * Generic bandwidth allocation constants/support |
320 | */ | 324 | */ |
321 | #define FRAME_TIME_USECS 1000L | 325 | #define FRAME_TIME_USECS 1000L |
322 | #define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */ | 326 | #define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */ |
323 | /* Trying not to use worst-case bit-stuffing | 327 | /* Trying not to use worst-case bit-stuffing |
324 | of (7/6 * 8 * bytecount) = 9.33 * bytecount */ | 328 | * of (7/6 * 8 * bytecount) = 9.33 * bytecount */ |
325 | /* bytecount = data payload byte count */ | 329 | /* bytecount = data payload byte count */ |
326 | 330 | ||
327 | #define NS_TO_US(ns) ((ns + 500L) / 1000L) | 331 | #define NS_TO_US(ns) ((ns + 500L) / 1000L) |
@@ -333,9 +337,9 @@ extern void usb_destroy_configuration(struct usb_device *dev); | |||
333 | */ | 337 | */ |
334 | #define BW_HOST_DELAY 1000L /* nanoseconds */ | 338 | #define BW_HOST_DELAY 1000L /* nanoseconds */ |
335 | #define BW_HUB_LS_SETUP 333L /* nanoseconds */ | 339 | #define BW_HUB_LS_SETUP 333L /* nanoseconds */ |
336 | /* 4 full-speed bit times (est.) */ | 340 | /* 4 full-speed bit times (est.) */ |
337 | 341 | ||
338 | #define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */ | 342 | #define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */ |
339 | #define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L) | 343 | #define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L) |
340 | #define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L) | 344 | #define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L) |
341 | 345 | ||
@@ -345,16 +349,16 @@ extern void usb_destroy_configuration(struct usb_device *dev); | |||
345 | * to preallocate bandwidth) | 349 | * to preallocate bandwidth) |
346 | */ | 350 | */ |
347 | #define USB2_HOST_DELAY 5 /* nsec, guess */ | 351 | #define USB2_HOST_DELAY 5 /* nsec, guess */ |
348 | #define HS_NSECS(bytes) ( ((55 * 8 * 2083) \ | 352 | #define HS_NSECS(bytes) (((55 * 8 * 2083) \ |
349 | + (2083UL * (3 + BitTime(bytes))))/1000 \ | 353 | + (2083UL * (3 + BitTime(bytes))))/1000 \ |
350 | + USB2_HOST_DELAY) | 354 | + USB2_HOST_DELAY) |
351 | #define HS_NSECS_ISO(bytes) ( ((38 * 8 * 2083) \ | 355 | #define HS_NSECS_ISO(bytes) (((38 * 8 * 2083) \ |
352 | + (2083UL * (3 + BitTime(bytes))))/1000 \ | 356 | + (2083UL * (3 + BitTime(bytes))))/1000 \ |
353 | + USB2_HOST_DELAY) | 357 | + USB2_HOST_DELAY) |
354 | #define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes)) | 358 | #define HS_USECS(bytes) NS_TO_US (HS_NSECS(bytes)) |
355 | #define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes)) | 359 | #define HS_USECS_ISO(bytes) NS_TO_US (HS_NSECS_ISO(bytes)) |
356 | 360 | ||
357 | extern long usb_calc_bus_time (int speed, int is_input, | 361 | extern long usb_calc_bus_time(int speed, int is_input, |
358 | int isoc, int bytecount); | 362 | int isoc, int bytecount); |
359 | 363 | ||
360 | /*-------------------------------------------------------------------------*/ | 364 | /*-------------------------------------------------------------------------*/ |
@@ -370,16 +374,16 @@ extern struct list_head usb_bus_list; | |||
370 | extern struct mutex usb_bus_list_lock; | 374 | extern struct mutex usb_bus_list_lock; |
371 | extern wait_queue_head_t usb_kill_urb_queue; | 375 | extern wait_queue_head_t usb_kill_urb_queue; |
372 | 376 | ||
373 | extern void usb_enable_root_hub_irq (struct usb_bus *bus); | 377 | extern void usb_enable_root_hub_irq(struct usb_bus *bus); |
374 | 378 | ||
375 | extern int usb_find_interface_driver (struct usb_device *dev, | 379 | extern int usb_find_interface_driver(struct usb_device *dev, |
376 | struct usb_interface *interface); | 380 | struct usb_interface *interface); |
377 | 381 | ||
378 | #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) | 382 | #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) |
379 | 383 | ||
380 | #ifdef CONFIG_PM | 384 | #ifdef CONFIG_PM |
381 | extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); | 385 | extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); |
382 | extern void usb_root_hub_lost_power (struct usb_device *rhdev); | 386 | extern void usb_root_hub_lost_power(struct usb_device *rhdev); |
383 | extern int hcd_bus_suspend(struct usb_device *rhdev); | 387 | extern int hcd_bus_suspend(struct usb_device *rhdev); |
384 | extern int hcd_bus_resume(struct usb_device *rhdev); | 388 | extern int hcd_bus_resume(struct usb_device *rhdev); |
385 | #else | 389 | #else |
@@ -399,13 +403,13 @@ static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) | |||
399 | * these are expected to be called from the USB core/hub thread | 403 | * these are expected to be called from the USB core/hub thread |
400 | * with the kernel lock held | 404 | * with the kernel lock held |
401 | */ | 405 | */ |
402 | extern void usbfs_update_special (void); | 406 | extern void usbfs_update_special(void); |
403 | extern int usbfs_init(void); | 407 | extern int usbfs_init(void); |
404 | extern void usbfs_cleanup(void); | 408 | extern void usbfs_cleanup(void); |
405 | 409 | ||
406 | #else /* CONFIG_USB_DEVICEFS */ | 410 | #else /* CONFIG_USB_DEVICEFS */ |
407 | 411 | ||
408 | static inline void usbfs_update_special (void) {} | 412 | static inline void usbfs_update_special(void) {} |
409 | static inline int usbfs_init(void) { return 0; } | 413 | static inline int usbfs_init(void) { return 0; } |
410 | static inline void usbfs_cleanup(void) { } | 414 | static inline void usbfs_cleanup(void) { } |
411 | 415 | ||
@@ -460,7 +464,7 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, | |||
460 | /*-------------------------------------------------------------------------*/ | 464 | /*-------------------------------------------------------------------------*/ |
461 | 465 | ||
462 | /* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */ | 466 | /* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */ |
463 | // bleech -- resurfaced in 2.4.11 or 2.4.12 | 467 | /* bleech -- resurfaced in 2.4.11 or 2.4.12 */ |
464 | #define bitmap DeviceRemovable | 468 | #define bitmap DeviceRemovable |
465 | 469 | ||
466 | 470 | ||
@@ -468,8 +472,8 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, | |||
468 | 472 | ||
469 | /* random stuff */ | 473 | /* random stuff */ |
470 | 474 | ||
471 | #define RUN_CONTEXT (in_irq () ? "in_irq" \ | 475 | #define RUN_CONTEXT (in_irq() ? "in_irq" \ |
472 | : (in_interrupt () ? "in_interrupt" : "can sleep")) | 476 | : (in_interrupt() ? "in_interrupt" : "can sleep")) |
473 | 477 | ||
474 | 478 | ||
475 | /* This rwsem is for use only by the hub driver and ehci-hcd. | 479 | /* This rwsem is for use only by the hub driver and ehci-hcd. |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index b04d232d4c65..68fc5219ca15 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -37,6 +37,13 @@ | |||
37 | #define USB_PERSIST 0 | 37 | #define USB_PERSIST 0 |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | /* if we are in debug mode, always announce new devices */ | ||
41 | #ifdef DEBUG | ||
42 | #ifndef CONFIG_USB_ANNOUNCE_NEW_DEVICES | ||
43 | #define CONFIG_USB_ANNOUNCE_NEW_DEVICES | ||
44 | #endif | ||
45 | #endif | ||
46 | |||
40 | struct usb_hub { | 47 | struct usb_hub { |
41 | struct device *intfdev; /* the "interface" device */ | 48 | struct device *intfdev; /* the "interface" device */ |
42 | struct usb_device *hdev; | 49 | struct usb_device *hdev; |
@@ -487,6 +494,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe) | |||
487 | schedule_work (&tt->kevent); | 494 | schedule_work (&tt->kevent); |
488 | spin_unlock_irqrestore (&tt->lock, flags); | 495 | spin_unlock_irqrestore (&tt->lock, flags); |
489 | } | 496 | } |
497 | EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); | ||
490 | 498 | ||
491 | static void hub_power_on(struct usb_hub *hub) | 499 | static void hub_power_on(struct usb_hub *hub) |
492 | { | 500 | { |
@@ -1027,8 +1035,10 @@ static void recursively_mark_NOTATTACHED(struct usb_device *udev) | |||
1027 | if (udev->children[i]) | 1035 | if (udev->children[i]) |
1028 | recursively_mark_NOTATTACHED(udev->children[i]); | 1036 | recursively_mark_NOTATTACHED(udev->children[i]); |
1029 | } | 1037 | } |
1030 | if (udev->state == USB_STATE_SUSPENDED) | 1038 | if (udev->state == USB_STATE_SUSPENDED) { |
1031 | udev->discon_suspended = 1; | 1039 | udev->discon_suspended = 1; |
1040 | udev->active_duration -= jiffies; | ||
1041 | } | ||
1032 | udev->state = USB_STATE_NOTATTACHED; | 1042 | udev->state = USB_STATE_NOTATTACHED; |
1033 | } | 1043 | } |
1034 | 1044 | ||
@@ -1077,6 +1087,12 @@ void usb_set_device_state(struct usb_device *udev, | |||
1077 | else | 1087 | else |
1078 | device_init_wakeup(&udev->dev, 0); | 1088 | device_init_wakeup(&udev->dev, 0); |
1079 | } | 1089 | } |
1090 | if (udev->state == USB_STATE_SUSPENDED && | ||
1091 | new_state != USB_STATE_SUSPENDED) | ||
1092 | udev->active_duration -= jiffies; | ||
1093 | else if (new_state == USB_STATE_SUSPENDED && | ||
1094 | udev->state != USB_STATE_SUSPENDED) | ||
1095 | udev->active_duration += jiffies; | ||
1080 | udev->state = new_state; | 1096 | udev->state = new_state; |
1081 | } else | 1097 | } else |
1082 | recursively_mark_NOTATTACHED(udev); | 1098 | recursively_mark_NOTATTACHED(udev); |
@@ -1207,7 +1223,7 @@ void usb_disconnect(struct usb_device **pdev) | |||
1207 | put_device(&udev->dev); | 1223 | put_device(&udev->dev); |
1208 | } | 1224 | } |
1209 | 1225 | ||
1210 | #ifdef DEBUG | 1226 | #ifdef CONFIG_USB_ANNOUNCE_NEW_DEVICES |
1211 | static void show_string(struct usb_device *udev, char *id, char *string) | 1227 | static void show_string(struct usb_device *udev, char *id, char *string) |
1212 | { | 1228 | { |
1213 | if (!string) | 1229 | if (!string) |
@@ -1215,12 +1231,24 @@ static void show_string(struct usb_device *udev, char *id, char *string) | |||
1215 | dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); | 1231 | dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); |
1216 | } | 1232 | } |
1217 | 1233 | ||
1234 | static void announce_device(struct usb_device *udev) | ||
1235 | { | ||
1236 | dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n", | ||
1237 | le16_to_cpu(udev->descriptor.idVendor), | ||
1238 | le16_to_cpu(udev->descriptor.idProduct)); | ||
1239 | dev_info(&udev->dev, "New USB device strings: Mfr=%d, Product=%d, " | ||
1240 | "SerialNumber=%d\n", | ||
1241 | udev->descriptor.iManufacturer, | ||
1242 | udev->descriptor.iProduct, | ||
1243 | udev->descriptor.iSerialNumber); | ||
1244 | show_string(udev, "Product", udev->product); | ||
1245 | show_string(udev, "Manufacturer", udev->manufacturer); | ||
1246 | show_string(udev, "SerialNumber", udev->serial); | ||
1247 | } | ||
1218 | #else | 1248 | #else |
1219 | static inline void show_string(struct usb_device *udev, char *id, char *string) | 1249 | static inline void announce_device(struct usb_device *udev) { } |
1220 | {} | ||
1221 | #endif | 1250 | #endif |
1222 | 1251 | ||
1223 | |||
1224 | #ifdef CONFIG_USB_OTG | 1252 | #ifdef CONFIG_USB_OTG |
1225 | #include "otg_whitelist.h" | 1253 | #include "otg_whitelist.h" |
1226 | #endif | 1254 | #endif |
@@ -1390,14 +1418,7 @@ int usb_new_device(struct usb_device *udev) | |||
1390 | } | 1418 | } |
1391 | 1419 | ||
1392 | /* Tell the world! */ | 1420 | /* Tell the world! */ |
1393 | dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, " | 1421 | announce_device(udev); |
1394 | "SerialNumber=%d\n", | ||
1395 | udev->descriptor.iManufacturer, | ||
1396 | udev->descriptor.iProduct, | ||
1397 | udev->descriptor.iSerialNumber); | ||
1398 | show_string(udev, "Product", udev->product); | ||
1399 | show_string(udev, "Manufacturer", udev->manufacturer); | ||
1400 | show_string(udev, "SerialNumber", udev->serial); | ||
1401 | return err; | 1422 | return err; |
1402 | 1423 | ||
1403 | fail: | 1424 | fail: |
@@ -2482,6 +2503,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
2482 | { | 2503 | { |
2483 | struct usb_device *hdev = hub->hdev; | 2504 | struct usb_device *hdev = hub->hdev; |
2484 | struct device *hub_dev = hub->intfdev; | 2505 | struct device *hub_dev = hub->intfdev; |
2506 | struct usb_hcd *hcd = bus_to_hcd(hdev->bus); | ||
2485 | u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); | 2507 | u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); |
2486 | int status, i; | 2508 | int status, i; |
2487 | 2509 | ||
@@ -2645,6 +2667,8 @@ loop: | |||
2645 | 2667 | ||
2646 | done: | 2668 | done: |
2647 | hub_port_disable(hub, port1, 1); | 2669 | hub_port_disable(hub, port1, 1); |
2670 | if (hcd->driver->relinquish_port && !hub->hdev->parent) | ||
2671 | hcd->driver->relinquish_port(hcd, port1); | ||
2648 | } | 2672 | } |
2649 | 2673 | ||
2650 | static void hub_events(void) | 2674 | static void hub_events(void) |
@@ -2946,7 +2970,7 @@ static int config_descriptors_changed(struct usb_device *udev) | |||
2946 | if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) | 2970 | if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) |
2947 | len = le16_to_cpu(udev->config[index].desc.wTotalLength); | 2971 | len = le16_to_cpu(udev->config[index].desc.wTotalLength); |
2948 | } | 2972 | } |
2949 | buf = kmalloc (len, GFP_KERNEL); | 2973 | buf = kmalloc(len, GFP_NOIO); |
2950 | if (buf == NULL) { | 2974 | if (buf == NULL) { |
2951 | dev_err(&udev->dev, "no mem to re-read configs after reset\n"); | 2975 | dev_err(&udev->dev, "no mem to re-read configs after reset\n"); |
2952 | /* assume the worst */ | 2976 | /* assume the worst */ |
@@ -3093,7 +3117,7 @@ re_enumerate: | |||
3093 | hub_port_logical_disconnect(parent_hub, port1); | 3117 | hub_port_logical_disconnect(parent_hub, port1); |
3094 | return -ENODEV; | 3118 | return -ENODEV; |
3095 | } | 3119 | } |
3096 | EXPORT_SYMBOL(usb_reset_device); | 3120 | EXPORT_SYMBOL_GPL(usb_reset_device); |
3097 | 3121 | ||
3098 | /** | 3122 | /** |
3099 | * usb_reset_composite_device - warn interface drivers and perform a USB port reset | 3123 | * usb_reset_composite_device - warn interface drivers and perform a USB port reset |
@@ -3110,16 +3134,12 @@ EXPORT_SYMBOL(usb_reset_device); | |||
3110 | * this from a driver probe() routine after downloading new firmware. | 3134 | * this from a driver probe() routine after downloading new firmware. |
3111 | * For calls that might not occur during probe(), drivers should lock | 3135 | * For calls that might not occur during probe(), drivers should lock |
3112 | * the device using usb_lock_device_for_reset(). | 3136 | * the device using usb_lock_device_for_reset(). |
3113 | * | ||
3114 | * The interface locks are acquired during the pre_reset stage and released | ||
3115 | * during the post_reset stage. However if iface is not NULL and is | ||
3116 | * currently being probed, we assume that the caller already owns its | ||
3117 | * lock. | ||
3118 | */ | 3137 | */ |
3119 | int usb_reset_composite_device(struct usb_device *udev, | 3138 | int usb_reset_composite_device(struct usb_device *udev, |
3120 | struct usb_interface *iface) | 3139 | struct usb_interface *iface) |
3121 | { | 3140 | { |
3122 | int ret; | 3141 | int ret; |
3142 | int i; | ||
3123 | struct usb_host_config *config = udev->actconfig; | 3143 | struct usb_host_config *config = udev->actconfig; |
3124 | 3144 | ||
3125 | if (udev->state == USB_STATE_NOTATTACHED || | 3145 | if (udev->state == USB_STATE_NOTATTACHED || |
@@ -3136,16 +3156,11 @@ int usb_reset_composite_device(struct usb_device *udev, | |||
3136 | iface = NULL; | 3156 | iface = NULL; |
3137 | 3157 | ||
3138 | if (config) { | 3158 | if (config) { |
3139 | int i; | ||
3140 | struct usb_interface *cintf; | ||
3141 | struct usb_driver *drv; | ||
3142 | |||
3143 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { | 3159 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { |
3144 | cintf = config->interface[i]; | 3160 | struct usb_interface *cintf = config->interface[i]; |
3145 | if (cintf != iface) | 3161 | struct usb_driver *drv; |
3146 | down(&cintf->dev.sem); | 3162 | |
3147 | if (device_is_registered(&cintf->dev) && | 3163 | if (cintf->dev.driver) { |
3148 | cintf->dev.driver) { | ||
3149 | drv = to_usb_driver(cintf->dev.driver); | 3164 | drv = to_usb_driver(cintf->dev.driver); |
3150 | if (drv->pre_reset) | 3165 | if (drv->pre_reset) |
3151 | (drv->pre_reset)(cintf); | 3166 | (drv->pre_reset)(cintf); |
@@ -3157,25 +3172,20 @@ int usb_reset_composite_device(struct usb_device *udev, | |||
3157 | ret = usb_reset_device(udev); | 3172 | ret = usb_reset_device(udev); |
3158 | 3173 | ||
3159 | if (config) { | 3174 | if (config) { |
3160 | int i; | ||
3161 | struct usb_interface *cintf; | ||
3162 | struct usb_driver *drv; | ||
3163 | |||
3164 | for (i = config->desc.bNumInterfaces - 1; i >= 0; --i) { | 3175 | for (i = config->desc.bNumInterfaces - 1; i >= 0; --i) { |
3165 | cintf = config->interface[i]; | 3176 | struct usb_interface *cintf = config->interface[i]; |
3166 | if (device_is_registered(&cintf->dev) && | 3177 | struct usb_driver *drv; |
3167 | cintf->dev.driver) { | 3178 | |
3179 | if (cintf->dev.driver) { | ||
3168 | drv = to_usb_driver(cintf->dev.driver); | 3180 | drv = to_usb_driver(cintf->dev.driver); |
3169 | if (drv->post_reset) | 3181 | if (drv->post_reset) |
3170 | (drv->post_reset)(cintf); | 3182 | (drv->post_reset)(cintf); |
3171 | /* FIXME: Unbind if post_reset returns an error or isn't defined */ | 3183 | /* FIXME: Unbind if post_reset returns an error or isn't defined */ |
3172 | } | 3184 | } |
3173 | if (cintf != iface) | ||
3174 | up(&cintf->dev.sem); | ||
3175 | } | 3185 | } |
3176 | } | 3186 | } |
3177 | 3187 | ||
3178 | usb_autosuspend_device(udev); | 3188 | usb_autosuspend_device(udev); |
3179 | return ret; | 3189 | return ret; |
3180 | } | 3190 | } |
3181 | EXPORT_SYMBOL(usb_reset_composite_device); | 3191 | EXPORT_SYMBOL_GPL(usb_reset_composite_device); |
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index cf9559c6c9b6..1551aed65e05 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h | |||
@@ -55,16 +55,16 @@ | |||
55 | #define USB_PORT_FEAT_TEST 21 | 55 | #define USB_PORT_FEAT_TEST 21 |
56 | #define USB_PORT_FEAT_INDICATOR 22 | 56 | #define USB_PORT_FEAT_INDICATOR 22 |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * Hub Status and Hub Change results | 59 | * Hub Status and Hub Change results |
60 | * See USB 2.0 spec Table 11-19 and Table 11-20 | 60 | * See USB 2.0 spec Table 11-19 and Table 11-20 |
61 | */ | 61 | */ |
62 | struct usb_port_status { | 62 | struct usb_port_status { |
63 | __le16 wPortStatus; | 63 | __le16 wPortStatus; |
64 | __le16 wPortChange; | 64 | __le16 wPortChange; |
65 | } __attribute__ ((packed)); | 65 | } __attribute__ ((packed)); |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * wPortStatus bit field | 68 | * wPortStatus bit field |
69 | * See USB 2.0 spec Table 11-21 | 69 | * See USB 2.0 spec Table 11-21 |
70 | */ | 70 | */ |
@@ -81,7 +81,7 @@ struct usb_port_status { | |||
81 | #define USB_PORT_STAT_INDICATOR 0x1000 | 81 | #define USB_PORT_STAT_INDICATOR 0x1000 |
82 | /* bits 13 to 15 are reserved */ | 82 | /* bits 13 to 15 are reserved */ |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * wPortChange bit field | 85 | * wPortChange bit field |
86 | * See USB 2.0 spec Table 11-22 | 86 | * See USB 2.0 spec Table 11-22 |
87 | * Bits 0 to 4 shown, bits 5 to 15 are reserved | 87 | * Bits 0 to 4 shown, bits 5 to 15 are reserved |
@@ -93,7 +93,7 @@ struct usb_port_status { | |||
93 | #define USB_PORT_STAT_C_RESET 0x0010 | 93 | #define USB_PORT_STAT_C_RESET 0x0010 |
94 | 94 | ||
95 | /* | 95 | /* |
96 | * wHubCharacteristics (masks) | 96 | * wHubCharacteristics (masks) |
97 | * See USB 2.0 spec Table 11-13, offset 3 | 97 | * See USB 2.0 spec Table 11-13, offset 3 |
98 | */ | 98 | */ |
99 | #define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */ | 99 | #define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */ |
@@ -119,8 +119,8 @@ struct usb_hub_status { | |||
119 | #define HUB_CHANGE_OVERCURRENT 0x0002 | 119 | #define HUB_CHANGE_OVERCURRENT 0x0002 |
120 | 120 | ||
121 | 121 | ||
122 | /* | 122 | /* |
123 | * Hub descriptor | 123 | * Hub descriptor |
124 | * See USB 2.0 spec Table 11-13 | 124 | * See USB 2.0 spec Table 11-13 |
125 | */ | 125 | */ |
126 | 126 | ||
@@ -134,7 +134,7 @@ struct usb_hub_descriptor { | |||
134 | __le16 wHubCharacteristics; | 134 | __le16 wHubCharacteristics; |
135 | __u8 bPwrOn2PwrGood; | 135 | __u8 bPwrOn2PwrGood; |
136 | __u8 bHubContrCurrent; | 136 | __u8 bHubContrCurrent; |
137 | /* add 1 bit for hub status change; round to bytes */ | 137 | /* add 1 bit for hub status change; round to bytes */ |
138 | __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; | 138 | __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; |
139 | __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; | 139 | __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; |
140 | } __attribute__ ((packed)); | 140 | } __attribute__ ((packed)); |
@@ -190,6 +190,6 @@ struct usb_tt_clear { | |||
190 | u16 devinfo; | 190 | u16 devinfo; |
191 | }; | 191 | }; |
192 | 192 | ||
193 | extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe); | 193 | extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe); |
194 | 194 | ||
195 | #endif /* __LINUX_HUB_H */ | 195 | #endif /* __LINUX_HUB_H */ |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index cd4f11157280..83a373e9cc36 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
@@ -38,10 +38,15 @@ | |||
38 | #include <linux/usbdevice_fs.h> | 38 | #include <linux/usbdevice_fs.h> |
39 | #include <linux/parser.h> | 39 | #include <linux/parser.h> |
40 | #include <linux/notifier.h> | 40 | #include <linux/notifier.h> |
41 | #include <linux/seq_file.h> | ||
41 | #include <asm/byteorder.h> | 42 | #include <asm/byteorder.h> |
42 | #include "usb.h" | 43 | #include "usb.h" |
43 | #include "hcd.h" | 44 | #include "hcd.h" |
44 | 45 | ||
46 | #define USBFS_DEFAULT_DEVMODE (S_IWUSR | S_IRUGO) | ||
47 | #define USBFS_DEFAULT_BUSMODE (S_IXUGO | S_IRUGO) | ||
48 | #define USBFS_DEFAULT_LISTMODE S_IRUGO | ||
49 | |||
45 | static struct super_operations usbfs_ops; | 50 | static struct super_operations usbfs_ops; |
46 | static const struct file_operations default_file_operations; | 51 | static const struct file_operations default_file_operations; |
47 | static struct vfsmount *usbfs_mount; | 52 | static struct vfsmount *usbfs_mount; |
@@ -57,9 +62,33 @@ static uid_t listuid; /* = 0 */ | |||
57 | static gid_t devgid; /* = 0 */ | 62 | static gid_t devgid; /* = 0 */ |
58 | static gid_t busgid; /* = 0 */ | 63 | static gid_t busgid; /* = 0 */ |
59 | static gid_t listgid; /* = 0 */ | 64 | static gid_t listgid; /* = 0 */ |
60 | static umode_t devmode = S_IWUSR | S_IRUGO; | 65 | static umode_t devmode = USBFS_DEFAULT_DEVMODE; |
61 | static umode_t busmode = S_IXUGO | S_IRUGO; | 66 | static umode_t busmode = USBFS_DEFAULT_BUSMODE; |
62 | static umode_t listmode = S_IRUGO; | 67 | static umode_t listmode = USBFS_DEFAULT_LISTMODE; |
68 | |||
69 | static int usbfs_show_options(struct seq_file *seq, struct vfsmount *mnt) | ||
70 | { | ||
71 | if (devuid != 0) | ||
72 | seq_printf(seq, ",devuid=%u", devuid); | ||
73 | if (devgid != 0) | ||
74 | seq_printf(seq, ",devgid=%u", devgid); | ||
75 | if (devmode != USBFS_DEFAULT_DEVMODE) | ||
76 | seq_printf(seq, ",devmode=%o", devmode); | ||
77 | if (busuid != 0) | ||
78 | seq_printf(seq, ",busuid=%u", busuid); | ||
79 | if (busgid != 0) | ||
80 | seq_printf(seq, ",busgid=%u", busgid); | ||
81 | if (busmode != USBFS_DEFAULT_BUSMODE) | ||
82 | seq_printf(seq, ",busmode=%o", busmode); | ||
83 | if (listuid != 0) | ||
84 | seq_printf(seq, ",listuid=%u", listuid); | ||
85 | if (listgid != 0) | ||
86 | seq_printf(seq, ",listgid=%u", listgid); | ||
87 | if (listmode != USBFS_DEFAULT_LISTMODE) | ||
88 | seq_printf(seq, ",listmode=%o", listmode); | ||
89 | |||
90 | return 0; | ||
91 | } | ||
63 | 92 | ||
64 | enum { | 93 | enum { |
65 | Opt_devuid, Opt_devgid, Opt_devmode, | 94 | Opt_devuid, Opt_devgid, Opt_devmode, |
@@ -93,9 +122,9 @@ static int parse_options(struct super_block *s, char *data) | |||
93 | devgid = 0; | 122 | devgid = 0; |
94 | busgid = 0; | 123 | busgid = 0; |
95 | listgid = 0; | 124 | listgid = 0; |
96 | devmode = S_IWUSR | S_IRUGO; | 125 | devmode = USBFS_DEFAULT_DEVMODE; |
97 | busmode = S_IXUGO | S_IRUGO; | 126 | busmode = USBFS_DEFAULT_BUSMODE; |
98 | listmode = S_IRUGO; | 127 | listmode = USBFS_DEFAULT_LISTMODE; |
99 | 128 | ||
100 | while ((p = strsep(&data, ",")) != NULL) { | 129 | while ((p = strsep(&data, ",")) != NULL) { |
101 | substring_t args[MAX_OPT_ARGS]; | 130 | substring_t args[MAX_OPT_ARGS]; |
@@ -418,6 +447,7 @@ static struct super_operations usbfs_ops = { | |||
418 | .statfs = simple_statfs, | 447 | .statfs = simple_statfs, |
419 | .drop_inode = generic_delete_inode, | 448 | .drop_inode = generic_delete_inode, |
420 | .remount_fs = remount, | 449 | .remount_fs = remount, |
450 | .show_options = usbfs_show_options, | ||
421 | }; | 451 | }; |
422 | 452 | ||
423 | static int usbfs_fill_super(struct super_block *sb, void *data, int silent) | 453 | static int usbfs_fill_super(struct super_block *sb, void *data, int silent) |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index fcd40ecbeecc..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 | ||
@@ -147,7 +151,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u | |||
147 | 151 | ||
148 | return ret; | 152 | return ret; |
149 | } | 153 | } |
150 | 154 | EXPORT_SYMBOL_GPL(usb_control_msg); | |
151 | 155 | ||
152 | /** | 156 | /** |
153 | * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion | 157 | * usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion |
@@ -155,9 +159,11 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u | |||
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; |
@@ -238,29 +244,30 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, | |||
238 | 244 | ||
239 | return usb_start_wait_urb(urb, timeout, actual_length); | 245 | return usb_start_wait_urb(urb, timeout, actual_length); |
240 | } | 246 | } |
247 | EXPORT_SYMBOL_GPL(usb_bulk_msg); | ||
241 | 248 | ||
242 | /*-------------------------------------------------------------------*/ | 249 | /*-------------------------------------------------------------------*/ |
243 | 250 | ||
244 | static void sg_clean (struct usb_sg_request *io) | 251 | static void sg_clean(struct usb_sg_request *io) |
245 | { | 252 | { |
246 | if (io->urbs) { | 253 | if (io->urbs) { |
247 | while (io->entries--) | 254 | while (io->entries--) |
248 | usb_free_urb (io->urbs [io->entries]); | 255 | usb_free_urb(io->urbs [io->entries]); |
249 | kfree (io->urbs); | 256 | kfree(io->urbs); |
250 | io->urbs = NULL; | 257 | io->urbs = NULL; |
251 | } | 258 | } |
252 | if (io->dev->dev.dma_mask != NULL) | 259 | if (io->dev->dev.dma_mask != NULL) |
253 | usb_buffer_unmap_sg (io->dev, usb_pipein(io->pipe), | 260 | usb_buffer_unmap_sg(io->dev, usb_pipein(io->pipe), |
254 | io->sg, io->nents); | 261 | io->sg, io->nents); |
255 | io->dev = NULL; | 262 | io->dev = NULL; |
256 | } | 263 | } |
257 | 264 | ||
258 | static void sg_complete (struct urb *urb) | 265 | static void sg_complete(struct urb *urb) |
259 | { | 266 | { |
260 | struct usb_sg_request *io = urb->context; | 267 | struct usb_sg_request *io = urb->context; |
261 | int status = urb->status; | 268 | int status = urb->status; |
262 | 269 | ||
263 | spin_lock (&io->lock); | 270 | spin_lock(&io->lock); |
264 | 271 | ||
265 | /* 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 |
266 | * reports, until the completion callback (this!) returns. That lets | 273 | * reports, until the completion callback (this!) returns. That lets |
@@ -276,13 +283,13 @@ static void sg_complete (struct urb *urb) | |||
276 | && (io->status != -ECONNRESET | 283 | && (io->status != -ECONNRESET |
277 | || status != -ECONNRESET) | 284 | || status != -ECONNRESET) |
278 | && urb->actual_length) { | 285 | && urb->actual_length) { |
279 | dev_err (io->dev->bus->controller, | 286 | dev_err(io->dev->bus->controller, |
280 | "dev %s ep%d%s scatterlist error %d/%d\n", | 287 | "dev %s ep%d%s scatterlist error %d/%d\n", |
281 | io->dev->devpath, | 288 | io->dev->devpath, |
282 | usb_endpoint_num(&urb->ep->desc), | 289 | usb_endpoint_num(&urb->ep->desc), |
283 | usb_urb_dir_in(urb) ? "in" : "out", | 290 | usb_urb_dir_in(urb) ? "in" : "out", |
284 | status, io->status); | 291 | status, io->status); |
285 | // BUG (); | 292 | /* BUG (); */ |
286 | } | 293 | } |
287 | 294 | ||
288 | if (io->status == 0 && status && status != -ECONNRESET) { | 295 | if (io->status == 0 && status && status != -ECONNRESET) { |
@@ -294,22 +301,22 @@ static void sg_complete (struct urb *urb) | |||
294 | * unlink pending urbs so they won't rx/tx bad data. | 301 | * unlink pending urbs so they won't rx/tx bad data. |
295 | * careful: unlink can sometimes be synchronous... | 302 | * careful: unlink can sometimes be synchronous... |
296 | */ | 303 | */ |
297 | spin_unlock (&io->lock); | 304 | spin_unlock(&io->lock); |
298 | for (i = 0, found = 0; i < io->entries; i++) { | 305 | for (i = 0, found = 0; i < io->entries; i++) { |
299 | if (!io->urbs [i] || !io->urbs [i]->dev) | 306 | if (!io->urbs [i] || !io->urbs [i]->dev) |
300 | continue; | 307 | continue; |
301 | if (found) { | 308 | if (found) { |
302 | retval = usb_unlink_urb (io->urbs [i]); | 309 | retval = usb_unlink_urb(io->urbs [i]); |
303 | if (retval != -EINPROGRESS && | 310 | if (retval != -EINPROGRESS && |
304 | retval != -ENODEV && | 311 | retval != -ENODEV && |
305 | retval != -EBUSY) | 312 | retval != -EBUSY) |
306 | dev_err (&io->dev->dev, | 313 | dev_err(&io->dev->dev, |
307 | "%s, unlink --> %d\n", | 314 | "%s, unlink --> %d\n", |
308 | __FUNCTION__, retval); | 315 | __FUNCTION__, retval); |
309 | } else if (urb == io->urbs [i]) | 316 | } else if (urb == io->urbs [i]) |
310 | found = 1; | 317 | found = 1; |
311 | } | 318 | } |
312 | spin_lock (&io->lock); | 319 | spin_lock(&io->lock); |
313 | } | 320 | } |
314 | urb->dev = NULL; | 321 | urb->dev = NULL; |
315 | 322 | ||
@@ -317,9 +324,9 @@ static void sg_complete (struct urb *urb) | |||
317 | io->bytes += urb->actual_length; | 324 | io->bytes += urb->actual_length; |
318 | io->count--; | 325 | io->count--; |
319 | if (!io->count) | 326 | if (!io->count) |
320 | complete (&io->complete); | 327 | complete(&io->complete); |
321 | 328 | ||
322 | spin_unlock (&io->lock); | 329 | spin_unlock(&io->lock); |
323 | } | 330 | } |
324 | 331 | ||
325 | 332 | ||
@@ -348,28 +355,21 @@ static void sg_complete (struct urb *urb) | |||
348 | * 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 |
349 | * usb_sg_wait() is called. | 356 | * usb_sg_wait() is called. |
350 | */ | 357 | */ |
351 | int usb_sg_init ( | 358 | int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, |
352 | struct usb_sg_request *io, | 359 | unsigned pipe, unsigned period, struct scatterlist *sg, |
353 | struct usb_device *dev, | 360 | int nents, size_t length, gfp_t mem_flags) |
354 | unsigned pipe, | ||
355 | unsigned period, | ||
356 | struct scatterlist *sg, | ||
357 | int nents, | ||
358 | size_t length, | ||
359 | gfp_t mem_flags | ||
360 | ) | ||
361 | { | 361 | { |
362 | int i; | 362 | int i; |
363 | int urb_flags; | 363 | int urb_flags; |
364 | int dma; | 364 | int dma; |
365 | 365 | ||
366 | if (!io || !dev || !sg | 366 | if (!io || !dev || !sg |
367 | || usb_pipecontrol (pipe) | 367 | || usb_pipecontrol(pipe) |
368 | || usb_pipeisoc (pipe) | 368 | || usb_pipeisoc(pipe) |
369 | || nents <= 0) | 369 | || nents <= 0) |
370 | return -EINVAL; | 370 | return -EINVAL; |
371 | 371 | ||
372 | spin_lock_init (&io->lock); | 372 | spin_lock_init(&io->lock); |
373 | io->dev = dev; | 373 | io->dev = dev; |
374 | io->pipe = pipe; | 374 | io->pipe = pipe; |
375 | io->sg = sg; | 375 | io->sg = sg; |
@@ -381,7 +381,7 @@ int usb_sg_init ( | |||
381 | dma = (dev->dev.dma_mask != NULL); | 381 | dma = (dev->dev.dma_mask != NULL); |
382 | if (dma) | 382 | if (dma) |
383 | io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), | 383 | io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), |
384 | sg, nents); | 384 | sg, nents); |
385 | else | 385 | else |
386 | io->entries = nents; | 386 | io->entries = nents; |
387 | 387 | ||
@@ -390,30 +390,30 @@ int usb_sg_init ( | |||
390 | return io->entries; | 390 | return io->entries; |
391 | 391 | ||
392 | io->count = io->entries; | 392 | io->count = io->entries; |
393 | io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags); | 393 | io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags); |
394 | if (!io->urbs) | 394 | if (!io->urbs) |
395 | goto nomem; | 395 | goto nomem; |
396 | 396 | ||
397 | urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; | 397 | urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; |
398 | if (usb_pipein (pipe)) | 398 | if (usb_pipein(pipe)) |
399 | urb_flags |= URB_SHORT_NOT_OK; | 399 | urb_flags |= URB_SHORT_NOT_OK; |
400 | 400 | ||
401 | for (i = 0; i < io->entries; i++) { | 401 | for (i = 0; i < io->entries; i++) { |
402 | unsigned len; | 402 | unsigned len; |
403 | 403 | ||
404 | io->urbs [i] = usb_alloc_urb (0, mem_flags); | 404 | io->urbs[i] = usb_alloc_urb(0, mem_flags); |
405 | if (!io->urbs [i]) { | 405 | if (!io->urbs[i]) { |
406 | io->entries = i; | 406 | io->entries = i; |
407 | goto nomem; | 407 | goto nomem; |
408 | } | 408 | } |
409 | 409 | ||
410 | io->urbs [i]->dev = NULL; | 410 | io->urbs[i]->dev = NULL; |
411 | io->urbs [i]->pipe = pipe; | 411 | io->urbs[i]->pipe = pipe; |
412 | io->urbs [i]->interval = period; | 412 | io->urbs[i]->interval = period; |
413 | io->urbs [i]->transfer_flags = urb_flags; | 413 | io->urbs[i]->transfer_flags = urb_flags; |
414 | 414 | ||
415 | io->urbs [i]->complete = sg_complete; | 415 | io->urbs[i]->complete = sg_complete; |
416 | io->urbs [i]->context = io; | 416 | io->urbs[i]->context = io; |
417 | 417 | ||
418 | /* | 418 | /* |
419 | * Some systems need to revert to PIO when DMA is temporarily | 419 | * Some systems need to revert to PIO when DMA is temporarily |
@@ -432,8 +432,8 @@ int usb_sg_init ( | |||
432 | * to prevent stale pointers and to help spot bugs. | 432 | * to prevent stale pointers and to help spot bugs. |
433 | */ | 433 | */ |
434 | if (dma) { | 434 | if (dma) { |
435 | io->urbs [i]->transfer_dma = sg_dma_address (sg + i); | 435 | io->urbs[i]->transfer_dma = sg_dma_address(sg + i); |
436 | len = sg_dma_len (sg + i); | 436 | len = sg_dma_len(sg + i); |
437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) | 437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) |
438 | io->urbs[i]->transfer_buffer = NULL; | 438 | io->urbs[i]->transfer_buffer = NULL; |
439 | #else | 439 | #else |
@@ -441,31 +441,31 @@ int usb_sg_init ( | |||
441 | #endif | 441 | #endif |
442 | } else { | 442 | } else { |
443 | /* hc may use _only_ transfer_buffer */ | 443 | /* hc may use _only_ transfer_buffer */ |
444 | io->urbs [i]->transfer_buffer = sg_virt(&sg[i]); | 444 | io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); |
445 | len = sg [i].length; | 445 | len = sg[i].length; |
446 | } | 446 | } |
447 | 447 | ||
448 | if (length) { | 448 | if (length) { |
449 | len = min_t (unsigned, len, length); | 449 | len = min_t(unsigned, len, length); |
450 | length -= len; | 450 | length -= len; |
451 | if (length == 0) | 451 | if (length == 0) |
452 | io->entries = i + 1; | 452 | io->entries = i + 1; |
453 | } | 453 | } |
454 | io->urbs [i]->transfer_buffer_length = len; | 454 | io->urbs[i]->transfer_buffer_length = len; |
455 | } | 455 | } |
456 | io->urbs [--i]->transfer_flags &= ~URB_NO_INTERRUPT; | 456 | io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; |
457 | 457 | ||
458 | /* transaction state */ | 458 | /* transaction state */ |
459 | io->status = 0; | 459 | io->status = 0; |
460 | io->bytes = 0; | 460 | io->bytes = 0; |
461 | init_completion (&io->complete); | 461 | init_completion(&io->complete); |
462 | return 0; | 462 | return 0; |
463 | 463 | ||
464 | nomem: | 464 | nomem: |
465 | sg_clean (io); | 465 | sg_clean(io); |
466 | return -ENOMEM; | 466 | return -ENOMEM; |
467 | } | 467 | } |
468 | 468 | EXPORT_SYMBOL_GPL(usb_sg_init); | |
469 | 469 | ||
470 | /** | 470 | /** |
471 | * usb_sg_wait - synchronously execute scatter/gather request | 471 | * usb_sg_wait - synchronously execute scatter/gather request |
@@ -506,31 +506,32 @@ nomem: | |||
506 | * speed interrupt endpoints, which allow at most one packet per millisecond, | 506 | * speed interrupt endpoints, which allow at most one packet per millisecond, |
507 | * of at most 8 or 64 bytes (respectively). | 507 | * of at most 8 or 64 bytes (respectively). |
508 | */ | 508 | */ |
509 | void usb_sg_wait (struct usb_sg_request *io) | 509 | void usb_sg_wait(struct usb_sg_request *io) |
510 | { | 510 | { |
511 | int i, entries = io->entries; | 511 | int i; |
512 | int entries = io->entries; | ||
512 | 513 | ||
513 | /* queue the urbs. */ | 514 | /* queue the urbs. */ |
514 | spin_lock_irq (&io->lock); | 515 | spin_lock_irq(&io->lock); |
515 | i = 0; | 516 | i = 0; |
516 | while (i < entries && !io->status) { | 517 | while (i < entries && !io->status) { |
517 | int retval; | 518 | int retval; |
518 | 519 | ||
519 | io->urbs [i]->dev = io->dev; | 520 | io->urbs[i]->dev = io->dev; |
520 | retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC); | 521 | retval = usb_submit_urb(io->urbs [i], GFP_ATOMIC); |
521 | 522 | ||
522 | /* after we submit, let completions or cancelations fire; | 523 | /* after we submit, let completions or cancelations fire; |
523 | * we handshake using io->status. | 524 | * we handshake using io->status. |
524 | */ | 525 | */ |
525 | spin_unlock_irq (&io->lock); | 526 | spin_unlock_irq(&io->lock); |
526 | switch (retval) { | 527 | switch (retval) { |
527 | /* maybe we retrying will recover */ | 528 | /* maybe we retrying will recover */ |
528 | case -ENXIO: // hc didn't queue this one | 529 | case -ENXIO: /* hc didn't queue this one */ |
529 | case -EAGAIN: | 530 | case -EAGAIN: |
530 | case -ENOMEM: | 531 | case -ENOMEM: |
531 | io->urbs[i]->dev = NULL; | 532 | io->urbs[i]->dev = NULL; |
532 | retval = 0; | 533 | retval = 0; |
533 | yield (); | 534 | yield(); |
534 | break; | 535 | break; |
535 | 536 | ||
536 | /* no error? continue immediately. | 537 | /* no error? continue immediately. |
@@ -541,34 +542,35 @@ void usb_sg_wait (struct usb_sg_request *io) | |||
541 | */ | 542 | */ |
542 | case 0: | 543 | case 0: |
543 | ++i; | 544 | ++i; |
544 | cpu_relax (); | 545 | cpu_relax(); |
545 | break; | 546 | break; |
546 | 547 | ||
547 | /* fail any uncompleted urbs */ | 548 | /* fail any uncompleted urbs */ |
548 | default: | 549 | default: |
549 | io->urbs [i]->dev = NULL; | 550 | io->urbs[i]->dev = NULL; |
550 | io->urbs [i]->status = retval; | 551 | io->urbs[i]->status = retval; |
551 | dev_dbg (&io->dev->dev, "%s, submit --> %d\n", | 552 | dev_dbg(&io->dev->dev, "%s, submit --> %d\n", |
552 | __FUNCTION__, retval); | 553 | __FUNCTION__, retval); |
553 | usb_sg_cancel (io); | 554 | usb_sg_cancel(io); |
554 | } | 555 | } |
555 | spin_lock_irq (&io->lock); | 556 | spin_lock_irq(&io->lock); |
556 | if (retval && (io->status == 0 || io->status == -ECONNRESET)) | 557 | if (retval && (io->status == 0 || io->status == -ECONNRESET)) |
557 | io->status = retval; | 558 | io->status = retval; |
558 | } | 559 | } |
559 | io->count -= entries - i; | 560 | io->count -= entries - i; |
560 | if (io->count == 0) | 561 | if (io->count == 0) |
561 | complete (&io->complete); | 562 | complete(&io->complete); |
562 | spin_unlock_irq (&io->lock); | 563 | spin_unlock_irq(&io->lock); |
563 | 564 | ||
564 | /* OK, yes, this could be packaged as non-blocking. | 565 | /* OK, yes, this could be packaged as non-blocking. |
565 | * So could the submit loop above ... but it's easier to | 566 | * So could the submit loop above ... but it's easier to |
566 | * solve neither problem than to solve both! | 567 | * solve neither problem than to solve both! |
567 | */ | 568 | */ |
568 | wait_for_completion (&io->complete); | 569 | wait_for_completion(&io->complete); |
569 | 570 | ||
570 | sg_clean (io); | 571 | sg_clean(io); |
571 | } | 572 | } |
573 | EXPORT_SYMBOL_GPL(usb_sg_wait); | ||
572 | 574 | ||
573 | /** | 575 | /** |
574 | * usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait() | 576 | * usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait() |
@@ -578,32 +580,33 @@ void usb_sg_wait (struct usb_sg_request *io) | |||
578 | * 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, |
579 | * so that call just frees resources allocated to the request. | 581 | * so that call just frees resources allocated to the request. |
580 | */ | 582 | */ |
581 | void usb_sg_cancel (struct usb_sg_request *io) | 583 | void usb_sg_cancel(struct usb_sg_request *io) |
582 | { | 584 | { |
583 | unsigned long flags; | 585 | unsigned long flags; |
584 | 586 | ||
585 | spin_lock_irqsave (&io->lock, flags); | 587 | spin_lock_irqsave(&io->lock, flags); |
586 | 588 | ||
587 | /* shut everything down, if it didn't already */ | 589 | /* shut everything down, if it didn't already */ |
588 | if (!io->status) { | 590 | if (!io->status) { |
589 | int i; | 591 | int i; |
590 | 592 | ||
591 | io->status = -ECONNRESET; | 593 | io->status = -ECONNRESET; |
592 | spin_unlock (&io->lock); | 594 | spin_unlock(&io->lock); |
593 | for (i = 0; i < io->entries; i++) { | 595 | for (i = 0; i < io->entries; i++) { |
594 | int retval; | 596 | int retval; |
595 | 597 | ||
596 | if (!io->urbs [i]->dev) | 598 | if (!io->urbs [i]->dev) |
597 | continue; | 599 | continue; |
598 | retval = usb_unlink_urb (io->urbs [i]); | 600 | retval = usb_unlink_urb(io->urbs [i]); |
599 | if (retval != -EINPROGRESS && retval != -EBUSY) | 601 | if (retval != -EINPROGRESS && retval != -EBUSY) |
600 | dev_warn (&io->dev->dev, "%s, unlink --> %d\n", | 602 | dev_warn(&io->dev->dev, "%s, unlink --> %d\n", |
601 | __FUNCTION__, retval); | 603 | __FUNCTION__, retval); |
602 | } | 604 | } |
603 | spin_lock (&io->lock); | 605 | spin_lock(&io->lock); |
604 | } | 606 | } |
605 | spin_unlock_irqrestore (&io->lock, flags); | 607 | spin_unlock_irqrestore(&io->lock, flags); |
606 | } | 608 | } |
609 | EXPORT_SYMBOL_GPL(usb_sg_cancel); | ||
607 | 610 | ||
608 | /*-------------------------------------------------------------------*/ | 611 | /*-------------------------------------------------------------------*/ |
609 | 612 | ||
@@ -629,12 +632,13 @@ void usb_sg_cancel (struct usb_sg_request *io) | |||
629 | * 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 |
630 | * returned by the underlying usb_control_msg() call. | 633 | * returned by the underlying usb_control_msg() call. |
631 | */ | 634 | */ |
632 | 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) | ||
633 | { | 637 | { |
634 | int i; | 638 | int i; |
635 | int result; | 639 | int result; |
636 | 640 | ||
637 | memset(buf,0,size); // Make sure we parse really received data | 641 | memset(buf, 0, size); /* Make sure we parse really received data */ |
638 | 642 | ||
639 | for (i = 0; i < 3; ++i) { | 643 | for (i = 0; i < 3; ++i) { |
640 | /* retry on length 0 or error; some devices are flakey */ | 644 | /* retry on length 0 or error; some devices are flakey */ |
@@ -652,6 +656,7 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char | |||
652 | } | 656 | } |
653 | return result; | 657 | return result; |
654 | } | 658 | } |
659 | EXPORT_SYMBOL_GPL(usb_get_descriptor); | ||
655 | 660 | ||
656 | /** | 661 | /** |
657 | * usb_get_string - gets a string descriptor | 662 | * usb_get_string - gets a string descriptor |
@@ -708,7 +713,7 @@ static void usb_try_string_workarounds(unsigned char *buf, int *length) | |||
708 | } | 713 | } |
709 | 714 | ||
710 | 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, |
711 | unsigned int index, unsigned char *buf) | 716 | unsigned int index, unsigned char *buf) |
712 | { | 717 | { |
713 | int rc; | 718 | int rc; |
714 | 719 | ||
@@ -751,7 +756,7 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid, | |||
751 | * @buf: where to put the string | 756 | * @buf: where to put the string |
752 | * @size: how big is "buf"? | 757 | * @size: how big is "buf"? |
753 | * Context: !in_interrupt () | 758 | * Context: !in_interrupt () |
754 | * | 759 | * |
755 | * This converts the UTF-16LE encoded strings returned by devices, from | 760 | * This converts the UTF-16LE encoded strings returned by devices, from |
756 | * 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 |
757 | * 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 |
@@ -787,23 +792,23 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | |||
787 | if (!dev->have_langid) { | 792 | if (!dev->have_langid) { |
788 | err = usb_string_sub(dev, 0, 0, tbuf); | 793 | err = usb_string_sub(dev, 0, 0, tbuf); |
789 | if (err < 0) { | 794 | if (err < 0) { |
790 | dev_err (&dev->dev, | 795 | dev_err(&dev->dev, |
791 | "string descriptor 0 read error: %d\n", | 796 | "string descriptor 0 read error: %d\n", |
792 | err); | 797 | err); |
793 | goto errout; | 798 | goto errout; |
794 | } else if (err < 4) { | 799 | } else if (err < 4) { |
795 | dev_err (&dev->dev, "string descriptor 0 too short\n"); | 800 | dev_err(&dev->dev, "string descriptor 0 too short\n"); |
796 | err = -EINVAL; | 801 | err = -EINVAL; |
797 | goto errout; | 802 | goto errout; |
798 | } else { | 803 | } else { |
799 | dev->have_langid = 1; | 804 | dev->have_langid = 1; |
800 | dev->string_langid = tbuf[2] | (tbuf[3]<< 8); | 805 | dev->string_langid = tbuf[2] | (tbuf[3] << 8); |
801 | /* always use the first langid listed */ | 806 | /* always use the first langid listed */ |
802 | dev_dbg (&dev->dev, "default language 0x%04x\n", | 807 | dev_dbg(&dev->dev, "default language 0x%04x\n", |
803 | dev->string_langid); | 808 | dev->string_langid); |
804 | } | 809 | } |
805 | } | 810 | } |
806 | 811 | ||
807 | err = usb_string_sub(dev, dev->string_langid, index, tbuf); | 812 | err = usb_string_sub(dev, dev->string_langid, index, tbuf); |
808 | if (err < 0) | 813 | if (err < 0) |
809 | goto errout; | 814 | goto errout; |
@@ -821,12 +826,15 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | |||
821 | err = idx; | 826 | err = idx; |
822 | 827 | ||
823 | if (tbuf[1] != USB_DT_STRING) | 828 | if (tbuf[1] != USB_DT_STRING) |
824 | 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); | ||
825 | 832 | ||
826 | errout: | 833 | errout: |
827 | kfree(tbuf); | 834 | kfree(tbuf); |
828 | return err; | 835 | return err; |
829 | } | 836 | } |
837 | EXPORT_SYMBOL_GPL(usb_string); | ||
830 | 838 | ||
831 | /** | 839 | /** |
832 | * usb_cache_string - read a string descriptor and cache it for later use | 840 | * usb_cache_string - read a string descriptor and cache it for later use |
@@ -842,9 +850,15 @@ char *usb_cache_string(struct usb_device *udev, int index) | |||
842 | char *smallbuf = NULL; | 850 | char *smallbuf = NULL; |
843 | int len; | 851 | int len; |
844 | 852 | ||
845 | if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) { | 853 | if (index <= 0) |
846 | if ((len = usb_string(udev, index, buf, 256)) > 0) { | 854 | return NULL; |
847 | 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) | ||
848 | return buf; | 862 | return buf; |
849 | memcpy(smallbuf, buf, len); | 863 | memcpy(smallbuf, buf, len); |
850 | } | 864 | } |
@@ -883,7 +897,7 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size) | |||
883 | return -ENOMEM; | 897 | return -ENOMEM; |
884 | 898 | ||
885 | ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); | 899 | ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); |
886 | if (ret >= 0) | 900 | if (ret >= 0) |
887 | memcpy(&dev->descriptor, desc, size); | 901 | memcpy(&dev->descriptor, desc, size); |
888 | kfree(desc); | 902 | kfree(desc); |
889 | return ret; | 903 | return ret; |
@@ -927,6 +941,7 @@ int usb_get_status(struct usb_device *dev, int type, int target, void *data) | |||
927 | kfree(status); | 941 | kfree(status); |
928 | return ret; | 942 | return ret; |
929 | } | 943 | } |
944 | EXPORT_SYMBOL_GPL(usb_get_status); | ||
930 | 945 | ||
931 | /** | 946 | /** |
932 | * usb_clear_halt - tells device to clear endpoint halt/stall condition | 947 | * usb_clear_halt - tells device to clear endpoint halt/stall condition |
@@ -955,8 +970,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe) | |||
955 | { | 970 | { |
956 | int result; | 971 | int result; |
957 | int endp = usb_pipeendpoint(pipe); | 972 | int endp = usb_pipeendpoint(pipe); |
958 | 973 | ||
959 | if (usb_pipein (pipe)) | 974 | if (usb_pipein(pipe)) |
960 | endp |= USB_DIR_IN; | 975 | endp |= USB_DIR_IN; |
961 | 976 | ||
962 | /* 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 |
@@ -985,6 +1000,7 @@ int usb_clear_halt(struct usb_device *dev, int pipe) | |||
985 | 1000 | ||
986 | return 0; | 1001 | return 0; |
987 | } | 1002 | } |
1003 | EXPORT_SYMBOL_GPL(usb_clear_halt); | ||
988 | 1004 | ||
989 | /** | 1005 | /** |
990 | * usb_disable_endpoint -- Disable an endpoint by address | 1006 | * usb_disable_endpoint -- Disable an endpoint by address |
@@ -1038,7 +1054,7 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf) | |||
1038 | } | 1054 | } |
1039 | } | 1055 | } |
1040 | 1056 | ||
1041 | /* | 1057 | /** |
1042 | * usb_disable_device - Disable all the endpoints for a USB device | 1058 | * usb_disable_device - Disable all the endpoints for a USB device |
1043 | * @dev: the device whose endpoints are being disabled | 1059 | * @dev: the device whose endpoints are being disabled |
1044 | * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. | 1060 | * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. |
@@ -1053,7 +1069,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1053 | int i; | 1069 | int i; |
1054 | 1070 | ||
1055 | dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, | 1071 | dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, |
1056 | skip_ep0 ? "non-ep0" : "all"); | 1072 | skip_ep0 ? "non-ep0" : "all"); |
1057 | for (i = skip_ep0; i < 16; ++i) { | 1073 | for (i = skip_ep0; i < 16; ++i) { |
1058 | usb_disable_endpoint(dev, i); | 1074 | usb_disable_endpoint(dev, i); |
1059 | usb_disable_endpoint(dev, i + USB_DIR_IN); | 1075 | usb_disable_endpoint(dev, i + USB_DIR_IN); |
@@ -1071,17 +1087,17 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1071 | interface = dev->actconfig->interface[i]; | 1087 | interface = dev->actconfig->interface[i]; |
1072 | if (!device_is_registered(&interface->dev)) | 1088 | if (!device_is_registered(&interface->dev)) |
1073 | continue; | 1089 | continue; |
1074 | dev_dbg (&dev->dev, "unregistering interface %s\n", | 1090 | dev_dbg(&dev->dev, "unregistering interface %s\n", |
1075 | interface->dev.bus_id); | 1091 | interface->dev.bus_id); |
1076 | usb_remove_sysfs_intf_files(interface); | 1092 | usb_remove_sysfs_intf_files(interface); |
1077 | device_del (&interface->dev); | 1093 | device_del(&interface->dev); |
1078 | } | 1094 | } |
1079 | 1095 | ||
1080 | /* Now that the interfaces are unbound, nobody should | 1096 | /* Now that the interfaces are unbound, nobody should |
1081 | * try to access them. | 1097 | * try to access them. |
1082 | */ | 1098 | */ |
1083 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { | 1099 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { |
1084 | put_device (&dev->actconfig->interface[i]->dev); | 1100 | put_device(&dev->actconfig->interface[i]->dev); |
1085 | dev->actconfig->interface[i] = NULL; | 1101 | dev->actconfig->interface[i] = NULL; |
1086 | } | 1102 | } |
1087 | dev->actconfig = NULL; | 1103 | dev->actconfig = NULL; |
@@ -1090,8 +1106,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1090 | } | 1106 | } |
1091 | } | 1107 | } |
1092 | 1108 | ||
1093 | 1109 | /** | |
1094 | /* | ||
1095 | * usb_enable_endpoint - Enable an endpoint for USB communications | 1110 | * usb_enable_endpoint - Enable an endpoint for USB communications |
1096 | * @dev: the device whose interface is being enabled | 1111 | * @dev: the device whose interface is being enabled |
1097 | * @ep: the endpoint | 1112 | * @ep: the endpoint |
@@ -1116,7 +1131,7 @@ void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep) | |||
1116 | ep->enabled = 1; | 1131 | ep->enabled = 1; |
1117 | } | 1132 | } |
1118 | 1133 | ||
1119 | /* | 1134 | /** |
1120 | * usb_enable_interface - Enable all the endpoints for an interface | 1135 | * usb_enable_interface - Enable all the endpoints for an interface |
1121 | * @dev: the device whose interface is being enabled | 1136 | * @dev: the device whose interface is being enabled |
1122 | * @intf: pointer to the interface descriptor | 1137 | * @intf: pointer to the interface descriptor |
@@ -1172,6 +1187,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1172 | struct usb_host_interface *alt; | 1187 | struct usb_host_interface *alt; |
1173 | int ret; | 1188 | int ret; |
1174 | int manual = 0; | 1189 | int manual = 0; |
1190 | unsigned int epaddr; | ||
1191 | unsigned int pipe; | ||
1175 | 1192 | ||
1176 | if (dev->state == USB_STATE_SUSPENDED) | 1193 | if (dev->state == USB_STATE_SUSPENDED) |
1177 | return -EHOSTUNREACH; | 1194 | return -EHOSTUNREACH; |
@@ -1226,11 +1243,11 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1226 | int i; | 1243 | int i; |
1227 | 1244 | ||
1228 | for (i = 0; i < alt->desc.bNumEndpoints; i++) { | 1245 | for (i = 0; i < alt->desc.bNumEndpoints; i++) { |
1229 | unsigned int epaddr = | 1246 | epaddr = alt->endpoint[i].desc.bEndpointAddress; |
1230 | alt->endpoint[i].desc.bEndpointAddress; | 1247 | pipe = __create_pipe(dev, |
1231 | unsigned int pipe = | 1248 | USB_ENDPOINT_NUMBER_MASK & epaddr) | |
1232 | __create_pipe(dev, USB_ENDPOINT_NUMBER_MASK & epaddr) | 1249 | (usb_endpoint_out(epaddr) ? |
1233 | | (usb_endpoint_out(epaddr) ? USB_DIR_OUT : USB_DIR_IN); | 1250 | USB_DIR_OUT : USB_DIR_IN); |
1234 | 1251 | ||
1235 | usb_clear_halt(dev, pipe); | 1252 | usb_clear_halt(dev, pipe); |
1236 | } | 1253 | } |
@@ -1253,6 +1270,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1253 | 1270 | ||
1254 | return 0; | 1271 | return 0; |
1255 | } | 1272 | } |
1273 | EXPORT_SYMBOL_GPL(usb_set_interface); | ||
1256 | 1274 | ||
1257 | /** | 1275 | /** |
1258 | * usb_reset_configuration - lightweight device reset | 1276 | * usb_reset_configuration - lightweight device reset |
@@ -1328,6 +1346,7 @@ int usb_reset_configuration(struct usb_device *dev) | |||
1328 | } | 1346 | } |
1329 | return 0; | 1347 | return 0; |
1330 | } | 1348 | } |
1349 | EXPORT_SYMBOL_GPL(usb_reset_configuration); | ||
1331 | 1350 | ||
1332 | static void usb_release_interface(struct device *dev) | 1351 | static void usb_release_interface(struct device *dev) |
1333 | { | 1352 | { |
@@ -1357,7 +1376,8 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
1357 | return -ENOMEM; | 1376 | return -ENOMEM; |
1358 | 1377 | ||
1359 | if (add_uevent_var(env, | 1378 | if (add_uevent_var(env, |
1360 | "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", | ||
1361 | le16_to_cpu(usb_dev->descriptor.idVendor), | 1381 | le16_to_cpu(usb_dev->descriptor.idVendor), |
1362 | le16_to_cpu(usb_dev->descriptor.idProduct), | 1382 | le16_to_cpu(usb_dev->descriptor.idProduct), |
1363 | le16_to_cpu(usb_dev->descriptor.bcdDevice), | 1383 | le16_to_cpu(usb_dev->descriptor.bcdDevice), |
@@ -1387,8 +1407,8 @@ struct device_type usb_if_device_type = { | |||
1387 | }; | 1407 | }; |
1388 | 1408 | ||
1389 | 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, |
1390 | struct usb_host_config *config, | 1410 | struct usb_host_config *config, |
1391 | u8 inum) | 1411 | u8 inum) |
1392 | { | 1412 | { |
1393 | struct usb_interface_assoc_descriptor *retval = NULL; | 1413 | struct usb_interface_assoc_descriptor *retval = NULL; |
1394 | struct usb_interface_assoc_descriptor *intf_assoc; | 1414 | struct usb_interface_assoc_descriptor *intf_assoc; |
@@ -1415,7 +1435,6 @@ static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, | |||
1415 | return retval; | 1435 | return retval; |
1416 | } | 1436 | } |
1417 | 1437 | ||
1418 | |||
1419 | /* | 1438 | /* |
1420 | * usb_set_configuration - Makes a particular device setting be current | 1439 | * usb_set_configuration - Makes a particular device setting be current |
1421 | * @dev: the device whose configuration is being updated | 1440 | * @dev: the device whose configuration is being updated |
@@ -1533,12 +1552,12 @@ free_interfaces: | |||
1533 | * getting rid of old interfaces means unbinding their drivers. | 1552 | * getting rid of old interfaces means unbinding their drivers. |
1534 | */ | 1553 | */ |
1535 | if (dev->state != USB_STATE_ADDRESS) | 1554 | if (dev->state != USB_STATE_ADDRESS) |
1536 | usb_disable_device (dev, 1); // Skip ep0 | 1555 | usb_disable_device(dev, 1); /* Skip ep0 */ |
1537 | |||
1538 | if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
1539 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | ||
1540 | NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) { | ||
1541 | 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) { | ||
1542 | /* 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? |
1543 | * The device is probably useless now anyway. | 1562 | * The device is probably useless now anyway. |
1544 | */ | 1563 | */ |
@@ -1585,11 +1604,11 @@ free_interfaces: | |||
1585 | intf->dev.bus = &usb_bus_type; | 1604 | intf->dev.bus = &usb_bus_type; |
1586 | intf->dev.type = &usb_if_device_type; | 1605 | intf->dev.type = &usb_if_device_type; |
1587 | intf->dev.dma_mask = dev->dev.dma_mask; | 1606 | intf->dev.dma_mask = dev->dev.dma_mask; |
1588 | device_initialize (&intf->dev); | 1607 | device_initialize(&intf->dev); |
1589 | mark_quiesced(intf); | 1608 | mark_quiesced(intf); |
1590 | sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d", | 1609 | sprintf(&intf->dev.bus_id[0], "%d-%s:%d.%d", |
1591 | dev->bus->busnum, dev->devpath, | 1610 | dev->bus->busnum, dev->devpath, |
1592 | configuration, alt->desc.bInterfaceNumber); | 1611 | configuration, alt->desc.bInterfaceNumber); |
1593 | } | 1612 | } |
1594 | kfree(new_interfaces); | 1613 | kfree(new_interfaces); |
1595 | 1614 | ||
@@ -1605,11 +1624,11 @@ free_interfaces: | |||
1605 | for (i = 0; i < nintf; ++i) { | 1624 | for (i = 0; i < nintf; ++i) { |
1606 | struct usb_interface *intf = cp->interface[i]; | 1625 | struct usb_interface *intf = cp->interface[i]; |
1607 | 1626 | ||
1608 | dev_dbg (&dev->dev, | 1627 | dev_dbg(&dev->dev, |
1609 | "adding %s (config #%d, interface %d)\n", | 1628 | "adding %s (config #%d, interface %d)\n", |
1610 | intf->dev.bus_id, configuration, | 1629 | intf->dev.bus_id, configuration, |
1611 | intf->cur_altsetting->desc.bInterfaceNumber); | 1630 | intf->cur_altsetting->desc.bInterfaceNumber); |
1612 | ret = device_add (&intf->dev); | 1631 | ret = device_add(&intf->dev); |
1613 | if (ret != 0) { | 1632 | if (ret != 0) { |
1614 | dev_err(&dev->dev, "device_add(%s) --> %d\n", | 1633 | dev_err(&dev->dev, "device_add(%s) --> %d\n", |
1615 | intf->dev.bus_id, ret); | 1634 | intf->dev.bus_id, ret); |
@@ -1677,22 +1696,3 @@ int usb_driver_set_configuration(struct usb_device *udev, int config) | |||
1677 | return 0; | 1696 | return 0; |
1678 | } | 1697 | } |
1679 | EXPORT_SYMBOL_GPL(usb_driver_set_configuration); | 1698 | EXPORT_SYMBOL_GPL(usb_driver_set_configuration); |
1680 | |||
1681 | // synchronous request completion model | ||
1682 | EXPORT_SYMBOL(usb_control_msg); | ||
1683 | EXPORT_SYMBOL(usb_bulk_msg); | ||
1684 | |||
1685 | EXPORT_SYMBOL(usb_sg_init); | ||
1686 | EXPORT_SYMBOL(usb_sg_cancel); | ||
1687 | EXPORT_SYMBOL(usb_sg_wait); | ||
1688 | |||
1689 | // synchronous control message convenience routines | ||
1690 | EXPORT_SYMBOL(usb_get_descriptor); | ||
1691 | EXPORT_SYMBOL(usb_get_status); | ||
1692 | EXPORT_SYMBOL(usb_string); | ||
1693 | |||
1694 | // synchronous calls that also maintain usbcore state | ||
1695 | EXPORT_SYMBOL(usb_clear_halt); | ||
1696 | EXPORT_SYMBOL(usb_reset_configuration); | ||
1697 | EXPORT_SYMBOL(usb_set_interface); | ||
1698 | |||
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c index 6b36897ca151..7542dce3f5a1 100644 --- a/drivers/usb/core/notify.c +++ b/drivers/usb/core/notify.c | |||
@@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(usb_register_notify); | |||
33 | * usb_unregister_notify - unregister a notifier callback | 33 | * usb_unregister_notify - unregister a notifier callback |
34 | * @nb: pointer to the notifier block for the callback events. | 34 | * @nb: pointer to the notifier block for the callback events. |
35 | * | 35 | * |
36 | * usb_register_notifier() must have been previously called for this function | 36 | * usb_register_notify() must have been previously called for this function |
37 | * to work properly. | 37 | * to work properly. |
38 | */ | 38 | */ |
39 | void usb_unregister_notify(struct notifier_block *nb) | 39 | void usb_unregister_notify(struct notifier_block *nb) |
diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h index 7f31a495a25d..e8cdce571bb1 100644 --- a/drivers/usb/core/otg_whitelist.h +++ b/drivers/usb/core/otg_whitelist.h | |||
@@ -14,7 +14,7 @@ | |||
14 | * mostly use of USB_DEVICE() or USB_DEVICE_VER() entries.. | 14 | * mostly use of USB_DEVICE() or USB_DEVICE_VER() entries.. |
15 | * | 15 | * |
16 | * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING! | 16 | * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING! |
17 | */ | 17 | */ |
18 | 18 | ||
19 | static struct usb_device_id whitelist_table [] = { | 19 | static struct usb_device_id whitelist_table [] = { |
20 | 20 | ||
@@ -55,7 +55,7 @@ static int is_targeted(struct usb_device *dev) | |||
55 | return 1; | 55 | return 1; |
56 | 56 | ||
57 | /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ | 57 | /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ |
58 | if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && | 58 | if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && |
59 | le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) | 59 | le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) |
60 | return 0; | 60 | return 0; |
61 | 61 | ||
@@ -86,7 +86,7 @@ static int is_targeted(struct usb_device *dev) | |||
86 | continue; | 86 | continue; |
87 | 87 | ||
88 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && | 88 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && |
89 | (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) | 89 | (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass)) |
90 | continue; | 90 | continue; |
91 | 91 | ||
92 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && | 92 | if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 32bd130b1eed..a37ccbd1e007 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -72,7 +72,7 @@ set_bConfigurationValue(struct device *dev, struct device_attribute *attr, | |||
72 | return (value < 0) ? value : count; | 72 | return (value < 0) ? value : count; |
73 | } | 73 | } |
74 | 74 | ||
75 | static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, | 75 | static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, |
76 | show_bConfigurationValue, set_bConfigurationValue); | 76 | show_bConfigurationValue, set_bConfigurationValue); |
77 | 77 | ||
78 | /* String fields */ | 78 | /* String fields */ |
@@ -249,6 +249,41 @@ static void remove_persist_attributes(struct device *dev) | |||
249 | #ifdef CONFIG_USB_SUSPEND | 249 | #ifdef CONFIG_USB_SUSPEND |
250 | 250 | ||
251 | static ssize_t | 251 | static ssize_t |
252 | show_connected_duration(struct device *dev, struct device_attribute *attr, | ||
253 | char *buf) | ||
254 | { | ||
255 | struct usb_device *udev = to_usb_device(dev); | ||
256 | |||
257 | return sprintf(buf, "%u\n", | ||
258 | jiffies_to_msecs(jiffies - udev->connect_time)); | ||
259 | } | ||
260 | |||
261 | static DEVICE_ATTR(connected_duration, S_IRUGO, show_connected_duration, NULL); | ||
262 | |||
263 | /* | ||
264 | * If the device is resumed, the last time the device was suspended has | ||
265 | * been pre-subtracted from active_duration. We add the current time to | ||
266 | * get the duration that the device was actually active. | ||
267 | * | ||
268 | * If the device is suspended, the active_duration is up-to-date. | ||
269 | */ | ||
270 | static ssize_t | ||
271 | show_active_duration(struct device *dev, struct device_attribute *attr, | ||
272 | char *buf) | ||
273 | { | ||
274 | struct usb_device *udev = to_usb_device(dev); | ||
275 | int duration; | ||
276 | |||
277 | if (udev->state != USB_STATE_SUSPENDED) | ||
278 | duration = jiffies_to_msecs(jiffies + udev->active_duration); | ||
279 | else | ||
280 | duration = jiffies_to_msecs(udev->active_duration); | ||
281 | return sprintf(buf, "%u\n", duration); | ||
282 | } | ||
283 | |||
284 | static DEVICE_ATTR(active_duration, S_IRUGO, show_active_duration, NULL); | ||
285 | |||
286 | static ssize_t | ||
252 | show_autosuspend(struct device *dev, struct device_attribute *attr, char *buf) | 287 | show_autosuspend(struct device *dev, struct device_attribute *attr, char *buf) |
253 | { | 288 | { |
254 | struct usb_device *udev = to_usb_device(dev); | 289 | struct usb_device *udev = to_usb_device(dev); |
@@ -365,6 +400,14 @@ static int add_power_attributes(struct device *dev) | |||
365 | rc = sysfs_add_file_to_group(&dev->kobj, | 400 | rc = sysfs_add_file_to_group(&dev->kobj, |
366 | &dev_attr_level.attr, | 401 | &dev_attr_level.attr, |
367 | power_group); | 402 | power_group); |
403 | if (rc == 0) | ||
404 | rc = sysfs_add_file_to_group(&dev->kobj, | ||
405 | &dev_attr_connected_duration.attr, | ||
406 | power_group); | ||
407 | if (rc == 0) | ||
408 | rc = sysfs_add_file_to_group(&dev->kobj, | ||
409 | &dev_attr_active_duration.attr, | ||
410 | power_group); | ||
368 | } | 411 | } |
369 | return rc; | 412 | return rc; |
370 | } | 413 | } |
@@ -372,6 +415,12 @@ static int add_power_attributes(struct device *dev) | |||
372 | static void remove_power_attributes(struct device *dev) | 415 | static void remove_power_attributes(struct device *dev) |
373 | { | 416 | { |
374 | sysfs_remove_file_from_group(&dev->kobj, | 417 | sysfs_remove_file_from_group(&dev->kobj, |
418 | &dev_attr_active_duration.attr, | ||
419 | power_group); | ||
420 | sysfs_remove_file_from_group(&dev->kobj, | ||
421 | &dev_attr_connected_duration.attr, | ||
422 | power_group); | ||
423 | sysfs_remove_file_from_group(&dev->kobj, | ||
375 | &dev_attr_level.attr, | 424 | &dev_attr_level.attr, |
376 | power_group); | 425 | power_group); |
377 | sysfs_remove_file_from_group(&dev->kobj, | 426 | sysfs_remove_file_from_group(&dev->kobj, |
@@ -601,21 +650,21 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev) | |||
601 | /* Interface Accociation Descriptor fields */ | 650 | /* Interface Accociation Descriptor fields */ |
602 | #define usb_intf_assoc_attr(field, format_string) \ | 651 | #define usb_intf_assoc_attr(field, format_string) \ |
603 | static ssize_t \ | 652 | static ssize_t \ |
604 | show_iad_##field (struct device *dev, struct device_attribute *attr, \ | 653 | show_iad_##field(struct device *dev, struct device_attribute *attr, \ |
605 | char *buf) \ | 654 | char *buf) \ |
606 | { \ | 655 | { \ |
607 | struct usb_interface *intf = to_usb_interface (dev); \ | 656 | struct usb_interface *intf = to_usb_interface(dev); \ |
608 | \ | 657 | \ |
609 | return sprintf (buf, format_string, \ | 658 | return sprintf(buf, format_string, \ |
610 | intf->intf_assoc->field); \ | 659 | intf->intf_assoc->field); \ |
611 | } \ | 660 | } \ |
612 | static DEVICE_ATTR(iad_##field, S_IRUGO, show_iad_##field, NULL); | 661 | static DEVICE_ATTR(iad_##field, S_IRUGO, show_iad_##field, NULL); |
613 | 662 | ||
614 | usb_intf_assoc_attr (bFirstInterface, "%02x\n") | 663 | usb_intf_assoc_attr(bFirstInterface, "%02x\n") |
615 | usb_intf_assoc_attr (bInterfaceCount, "%02d\n") | 664 | usb_intf_assoc_attr(bInterfaceCount, "%02d\n") |
616 | usb_intf_assoc_attr (bFunctionClass, "%02x\n") | 665 | usb_intf_assoc_attr(bFunctionClass, "%02x\n") |
617 | usb_intf_assoc_attr (bFunctionSubClass, "%02x\n") | 666 | usb_intf_assoc_attr(bFunctionSubClass, "%02x\n") |
618 | usb_intf_assoc_attr (bFunctionProtocol, "%02x\n") | 667 | usb_intf_assoc_attr(bFunctionProtocol, "%02x\n") |
619 | 668 | ||
620 | /* Interface fields */ | 669 | /* Interface fields */ |
621 | #define usb_intf_attr(field, format_string) \ | 670 | #define usb_intf_attr(field, format_string) \ |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index d05ead20081c..9d7e63292c01 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -42,6 +42,7 @@ void usb_init_urb(struct urb *urb) | |||
42 | INIT_LIST_HEAD(&urb->anchor_list); | 42 | INIT_LIST_HEAD(&urb->anchor_list); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | EXPORT_SYMBOL_GPL(usb_init_urb); | ||
45 | 46 | ||
46 | /** | 47 | /** |
47 | * usb_alloc_urb - creates a new urb for a USB driver to use | 48 | * usb_alloc_urb - creates a new urb for a USB driver to use |
@@ -73,6 +74,7 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) | |||
73 | usb_init_urb(urb); | 74 | usb_init_urb(urb); |
74 | return urb; | 75 | return urb; |
75 | } | 76 | } |
77 | EXPORT_SYMBOL_GPL(usb_alloc_urb); | ||
76 | 78 | ||
77 | /** | 79 | /** |
78 | * usb_free_urb - frees the memory used by a urb when all users of it are finished | 80 | * usb_free_urb - frees the memory used by a urb when all users of it are finished |
@@ -89,6 +91,7 @@ void usb_free_urb(struct urb *urb) | |||
89 | if (urb) | 91 | if (urb) |
90 | kref_put(&urb->kref, urb_destroy); | 92 | kref_put(&urb->kref, urb_destroy); |
91 | } | 93 | } |
94 | EXPORT_SYMBOL_GPL(usb_free_urb); | ||
92 | 95 | ||
93 | /** | 96 | /** |
94 | * usb_get_urb - increments the reference count of the urb | 97 | * usb_get_urb - increments the reference count of the urb |
@@ -100,12 +103,13 @@ void usb_free_urb(struct urb *urb) | |||
100 | * | 103 | * |
101 | * A pointer to the urb with the incremented reference counter is returned. | 104 | * A pointer to the urb with the incremented reference counter is returned. |
102 | */ | 105 | */ |
103 | struct urb * usb_get_urb(struct urb *urb) | 106 | struct urb *usb_get_urb(struct urb *urb) |
104 | { | 107 | { |
105 | if (urb) | 108 | if (urb) |
106 | kref_get(&urb->kref); | 109 | kref_get(&urb->kref); |
107 | return urb; | 110 | return urb; |
108 | } | 111 | } |
112 | EXPORT_SYMBOL_GPL(usb_get_urb); | ||
109 | 113 | ||
110 | /** | 114 | /** |
111 | * usb_anchor_urb - anchors an URB while it is processed | 115 | * usb_anchor_urb - anchors an URB while it is processed |
@@ -172,7 +176,7 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb); | |||
172 | * describing that request to the USB subsystem. Request completion will | 176 | * describing that request to the USB subsystem. Request completion will |
173 | * be indicated later, asynchronously, by calling the completion handler. | 177 | * be indicated later, asynchronously, by calling the completion handler. |
174 | * The three types of completion are success, error, and unlink | 178 | * The three types of completion are success, error, and unlink |
175 | * (a software-induced fault, also called "request cancellation"). | 179 | * (a software-induced fault, also called "request cancellation"). |
176 | * | 180 | * |
177 | * URBs may be submitted in interrupt context. | 181 | * URBs may be submitted in interrupt context. |
178 | * | 182 | * |
@@ -255,7 +259,7 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb); | |||
255 | * semaphores), or | 259 | * semaphores), or |
256 | * (c) current->state != TASK_RUNNING, this is the case only after | 260 | * (c) current->state != TASK_RUNNING, this is the case only after |
257 | * you've changed it. | 261 | * you've changed it. |
258 | * | 262 | * |
259 | * GFP_NOIO is used in the block io path and error handling of storage | 263 | * GFP_NOIO is used in the block io path and error handling of storage |
260 | * devices. | 264 | * devices. |
261 | * | 265 | * |
@@ -284,7 +288,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
284 | 288 | ||
285 | if (!urb || urb->hcpriv || !urb->complete) | 289 | if (!urb || urb->hcpriv || !urb->complete) |
286 | return -EINVAL; | 290 | return -EINVAL; |
287 | if (!(dev = urb->dev) || dev->state < USB_STATE_DEFAULT) | 291 | dev = urb->dev; |
292 | if ((!dev) || (dev->state < USB_STATE_DEFAULT)) | ||
288 | return -ENODEV; | 293 | return -ENODEV; |
289 | 294 | ||
290 | /* For now, get the endpoint from the pipe. Eventually drivers | 295 | /* For now, get the endpoint from the pipe. Eventually drivers |
@@ -347,11 +352,11 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
347 | max *= mult; | 352 | max *= mult; |
348 | } | 353 | } |
349 | 354 | ||
350 | if (urb->number_of_packets <= 0) | 355 | if (urb->number_of_packets <= 0) |
351 | return -EINVAL; | 356 | return -EINVAL; |
352 | for (n = 0; n < urb->number_of_packets; n++) { | 357 | for (n = 0; n < urb->number_of_packets; n++) { |
353 | len = urb->iso_frame_desc[n].length; | 358 | len = urb->iso_frame_desc[n].length; |
354 | if (len < 0 || len > max) | 359 | if (len < 0 || len > max) |
355 | return -EMSGSIZE; | 360 | return -EMSGSIZE; |
356 | urb->iso_frame_desc[n].status = -EXDEV; | 361 | urb->iso_frame_desc[n].status = -EXDEV; |
357 | urb->iso_frame_desc[n].actual_length = 0; | 362 | urb->iso_frame_desc[n].actual_length = 0; |
@@ -416,7 +421,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
416 | /* too big? */ | 421 | /* too big? */ |
417 | switch (dev->speed) { | 422 | switch (dev->speed) { |
418 | case USB_SPEED_HIGH: /* units are microframes */ | 423 | case USB_SPEED_HIGH: /* units are microframes */ |
419 | // NOTE usb handles 2^15 | 424 | /* NOTE usb handles 2^15 */ |
420 | if (urb->interval > (1024 * 8)) | 425 | if (urb->interval > (1024 * 8)) |
421 | urb->interval = 1024 * 8; | 426 | urb->interval = 1024 * 8; |
422 | max = 1024 * 8; | 427 | max = 1024 * 8; |
@@ -426,12 +431,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
426 | if (xfertype == USB_ENDPOINT_XFER_INT) { | 431 | if (xfertype == USB_ENDPOINT_XFER_INT) { |
427 | if (urb->interval > 255) | 432 | if (urb->interval > 255) |
428 | return -EINVAL; | 433 | return -EINVAL; |
429 | // NOTE ohci only handles up to 32 | 434 | /* NOTE ohci only handles up to 32 */ |
430 | max = 128; | 435 | max = 128; |
431 | } else { | 436 | } else { |
432 | if (urb->interval > 1024) | 437 | if (urb->interval > 1024) |
433 | urb->interval = 1024; | 438 | urb->interval = 1024; |
434 | // NOTE usb and ohci handle up to 2^15 | 439 | /* NOTE usb and ohci handle up to 2^15 */ |
435 | max = 1024; | 440 | max = 1024; |
436 | } | 441 | } |
437 | break; | 442 | break; |
@@ -444,6 +449,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
444 | 449 | ||
445 | return usb_hcd_submit_urb(urb, mem_flags); | 450 | return usb_hcd_submit_urb(urb, mem_flags); |
446 | } | 451 | } |
452 | EXPORT_SYMBOL_GPL(usb_submit_urb); | ||
447 | 453 | ||
448 | /*-------------------------------------------------------------------*/ | 454 | /*-------------------------------------------------------------------*/ |
449 | 455 | ||
@@ -514,6 +520,7 @@ int usb_unlink_urb(struct urb *urb) | |||
514 | return -EIDRM; | 520 | return -EIDRM; |
515 | return usb_hcd_unlink_urb(urb, -ECONNRESET); | 521 | return usb_hcd_unlink_urb(urb, -ECONNRESET); |
516 | } | 522 | } |
523 | EXPORT_SYMBOL_GPL(usb_unlink_urb); | ||
517 | 524 | ||
518 | /** | 525 | /** |
519 | * usb_kill_urb - cancel a transfer request and wait for it to finish | 526 | * usb_kill_urb - cancel a transfer request and wait for it to finish |
@@ -553,6 +560,7 @@ void usb_kill_urb(struct urb *urb) | |||
553 | --urb->reject; | 560 | --urb->reject; |
554 | mutex_unlock(&reject_mutex); | 561 | mutex_unlock(&reject_mutex); |
555 | } | 562 | } |
563 | EXPORT_SYMBOL_GPL(usb_kill_urb); | ||
556 | 564 | ||
557 | /** | 565 | /** |
558 | * usb_kill_anchored_urbs - cancel transfer requests en masse | 566 | * usb_kill_anchored_urbs - cancel transfer requests en masse |
@@ -567,7 +575,8 @@ void usb_kill_anchored_urbs(struct usb_anchor *anchor) | |||
567 | 575 | ||
568 | spin_lock_irq(&anchor->lock); | 576 | spin_lock_irq(&anchor->lock); |
569 | while (!list_empty(&anchor->urb_list)) { | 577 | while (!list_empty(&anchor->urb_list)) { |
570 | victim = list_entry(anchor->urb_list.prev, struct urb, anchor_list); | 578 | victim = list_entry(anchor->urb_list.prev, struct urb, |
579 | anchor_list); | ||
571 | /* we must make sure the URB isn't freed before we kill it*/ | 580 | /* we must make sure the URB isn't freed before we kill it*/ |
572 | usb_get_urb(victim); | 581 | usb_get_urb(victim); |
573 | spin_unlock_irq(&anchor->lock); | 582 | spin_unlock_irq(&anchor->lock); |
@@ -595,11 +604,3 @@ int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, | |||
595 | msecs_to_jiffies(timeout)); | 604 | msecs_to_jiffies(timeout)); |
596 | } | 605 | } |
597 | EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); | 606 | EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout); |
598 | |||
599 | EXPORT_SYMBOL(usb_init_urb); | ||
600 | EXPORT_SYMBOL(usb_alloc_urb); | ||
601 | EXPORT_SYMBOL(usb_free_urb); | ||
602 | EXPORT_SYMBOL(usb_get_urb); | ||
603 | EXPORT_SYMBOL(usb_submit_urb); | ||
604 | EXPORT_SYMBOL(usb_unlink_urb); | ||
605 | EXPORT_SYMBOL(usb_kill_urb); | ||
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 8f142370103d..4e984060c984 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -96,6 +96,7 @@ struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev, | |||
96 | 96 | ||
97 | return NULL; | 97 | return NULL; |
98 | } | 98 | } |
99 | EXPORT_SYMBOL_GPL(usb_ifnum_to_if); | ||
99 | 100 | ||
100 | /** | 101 | /** |
101 | * usb_altnum_to_altsetting - get the altsetting structure with a given | 102 | * usb_altnum_to_altsetting - get the altsetting structure with a given |
@@ -115,8 +116,9 @@ struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev, | |||
115 | * Don't call this function unless you are bound to the intf interface | 116 | * Don't call this function unless you are bound to the intf interface |
116 | * or you have locked the device! | 117 | * or you have locked the device! |
117 | */ | 118 | */ |
118 | struct usb_host_interface *usb_altnum_to_altsetting(const struct usb_interface *intf, | 119 | struct usb_host_interface *usb_altnum_to_altsetting( |
119 | unsigned int altnum) | 120 | const struct usb_interface *intf, |
121 | unsigned int altnum) | ||
120 | { | 122 | { |
121 | int i; | 123 | int i; |
122 | 124 | ||
@@ -126,13 +128,14 @@ struct usb_host_interface *usb_altnum_to_altsetting(const struct usb_interface * | |||
126 | } | 128 | } |
127 | return NULL; | 129 | return NULL; |
128 | } | 130 | } |
131 | EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting); | ||
129 | 132 | ||
130 | struct find_interface_arg { | 133 | struct find_interface_arg { |
131 | int minor; | 134 | int minor; |
132 | struct usb_interface *interface; | 135 | struct usb_interface *interface; |
133 | }; | 136 | }; |
134 | 137 | ||
135 | static int __find_interface(struct device * dev, void * data) | 138 | static int __find_interface(struct device *dev, void *data) |
136 | { | 139 | { |
137 | struct find_interface_arg *arg = data; | 140 | struct find_interface_arg *arg = data; |
138 | struct usb_interface *intf; | 141 | struct usb_interface *intf; |
@@ -154,7 +157,7 @@ static int __find_interface(struct device * dev, void * data) | |||
154 | * @drv: the driver whose current configuration is considered | 157 | * @drv: the driver whose current configuration is considered |
155 | * @minor: the minor number of the desired device | 158 | * @minor: the minor number of the desired device |
156 | * | 159 | * |
157 | * This walks the driver device list and returns a pointer to the interface | 160 | * This walks the driver device list and returns a pointer to the interface |
158 | * with the matching minor. Note, this only works for devices that share the | 161 | * with the matching minor. Note, this only works for devices that share the |
159 | * USB major number. | 162 | * USB major number. |
160 | */ | 163 | */ |
@@ -170,6 +173,7 @@ struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) | |||
170 | __find_interface); | 173 | __find_interface); |
171 | return argb.interface; | 174 | return argb.interface; |
172 | } | 175 | } |
176 | EXPORT_SYMBOL_GPL(usb_find_interface); | ||
173 | 177 | ||
174 | /** | 178 | /** |
175 | * usb_release_dev - free a usb device structure when all users of it are finished. | 179 | * usb_release_dev - free a usb device structure when all users of it are finished. |
@@ -230,7 +234,7 @@ static int ksuspend_usb_init(void) | |||
230 | * singlethreaded. Its job doesn't justify running on more | 234 | * singlethreaded. Its job doesn't justify running on more |
231 | * than one CPU. | 235 | * than one CPU. |
232 | */ | 236 | */ |
233 | ksuspend_usb_wq = create_freezeable_workqueue("ksuspend_usbd"); | 237 | ksuspend_usb_wq = create_singlethread_workqueue("ksuspend_usbd"); |
234 | if (!ksuspend_usb_wq) | 238 | if (!ksuspend_usb_wq) |
235 | return -ENOMEM; | 239 | return -ENOMEM; |
236 | return 0; | 240 | return 0; |
@@ -269,8 +273,8 @@ static unsigned usb_bus_is_wusb(struct usb_bus *bus) | |||
269 | * | 273 | * |
270 | * This call may not be used in a non-sleeping context. | 274 | * This call may not be used in a non-sleeping context. |
271 | */ | 275 | */ |
272 | struct usb_device * | 276 | struct usb_device *usb_alloc_dev(struct usb_device *parent, |
273 | usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) | 277 | struct usb_bus *bus, unsigned port1) |
274 | { | 278 | { |
275 | struct usb_device *dev; | 279 | struct usb_device *dev; |
276 | struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self); | 280 | struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self); |
@@ -339,6 +343,8 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) | |||
339 | mutex_init(&dev->pm_mutex); | 343 | mutex_init(&dev->pm_mutex); |
340 | INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); | 344 | INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); |
341 | dev->autosuspend_delay = usb_autosuspend_delay * HZ; | 345 | dev->autosuspend_delay = usb_autosuspend_delay * HZ; |
346 | dev->connect_time = jiffies; | ||
347 | dev->active_duration = -jiffies; | ||
342 | #endif | 348 | #endif |
343 | if (root_hub) /* Root hub always ok [and always wired] */ | 349 | if (root_hub) /* Root hub always ok [and always wired] */ |
344 | dev->authorized = 1; | 350 | dev->authorized = 1; |
@@ -367,6 +373,7 @@ struct usb_device *usb_get_dev(struct usb_device *dev) | |||
367 | get_device(&dev->dev); | 373 | get_device(&dev->dev); |
368 | return dev; | 374 | return dev; |
369 | } | 375 | } |
376 | EXPORT_SYMBOL_GPL(usb_get_dev); | ||
370 | 377 | ||
371 | /** | 378 | /** |
372 | * usb_put_dev - release a use of the usb device structure | 379 | * usb_put_dev - release a use of the usb device structure |
@@ -380,6 +387,7 @@ void usb_put_dev(struct usb_device *dev) | |||
380 | if (dev) | 387 | if (dev) |
381 | put_device(&dev->dev); | 388 | put_device(&dev->dev); |
382 | } | 389 | } |
390 | EXPORT_SYMBOL_GPL(usb_put_dev); | ||
383 | 391 | ||
384 | /** | 392 | /** |
385 | * usb_get_intf - increments the reference count of the usb interface structure | 393 | * usb_get_intf - increments the reference count of the usb interface structure |
@@ -400,6 +408,7 @@ struct usb_interface *usb_get_intf(struct usb_interface *intf) | |||
400 | get_device(&intf->dev); | 408 | get_device(&intf->dev); |
401 | return intf; | 409 | return intf; |
402 | } | 410 | } |
411 | EXPORT_SYMBOL_GPL(usb_get_intf); | ||
403 | 412 | ||
404 | /** | 413 | /** |
405 | * usb_put_intf - release a use of the usb interface structure | 414 | * usb_put_intf - release a use of the usb interface structure |
@@ -414,7 +423,7 @@ void usb_put_intf(struct usb_interface *intf) | |||
414 | if (intf) | 423 | if (intf) |
415 | put_device(&intf->dev); | 424 | put_device(&intf->dev); |
416 | } | 425 | } |
417 | 426 | EXPORT_SYMBOL_GPL(usb_put_intf); | |
418 | 427 | ||
419 | /* USB device locking | 428 | /* USB device locking |
420 | * | 429 | * |
@@ -461,11 +470,11 @@ int usb_lock_device_for_reset(struct usb_device *udev, | |||
461 | return -EHOSTUNREACH; | 470 | return -EHOSTUNREACH; |
462 | if (iface) { | 471 | if (iface) { |
463 | switch (iface->condition) { | 472 | switch (iface->condition) { |
464 | case USB_INTERFACE_BINDING: | 473 | case USB_INTERFACE_BINDING: |
465 | return 0; | 474 | return 0; |
466 | case USB_INTERFACE_BOUND: | 475 | case USB_INTERFACE_BOUND: |
467 | break; | 476 | break; |
468 | default: | 477 | default: |
469 | return -EINTR; | 478 | return -EINTR; |
470 | } | 479 | } |
471 | } | 480 | } |
@@ -487,7 +496,7 @@ int usb_lock_device_for_reset(struct usb_device *udev, | |||
487 | } | 496 | } |
488 | return 1; | 497 | return 1; |
489 | } | 498 | } |
490 | 499 | EXPORT_SYMBOL_GPL(usb_lock_device_for_reset); | |
491 | 500 | ||
492 | static struct usb_device *match_device(struct usb_device *dev, | 501 | static struct usb_device *match_device(struct usb_device *dev, |
493 | u16 vendor_id, u16 product_id) | 502 | u16 vendor_id, u16 product_id) |
@@ -540,10 +549,10 @@ struct usb_device *usb_find_device(u16 vendor_id, u16 product_id) | |||
540 | struct list_head *buslist; | 549 | struct list_head *buslist; |
541 | struct usb_bus *bus; | 550 | struct usb_bus *bus; |
542 | struct usb_device *dev = NULL; | 551 | struct usb_device *dev = NULL; |
543 | 552 | ||
544 | mutex_lock(&usb_bus_list_lock); | 553 | mutex_lock(&usb_bus_list_lock); |
545 | for (buslist = usb_bus_list.next; | 554 | for (buslist = usb_bus_list.next; |
546 | buslist != &usb_bus_list; | 555 | buslist != &usb_bus_list; |
547 | buslist = buslist->next) { | 556 | buslist = buslist->next) { |
548 | bus = container_of(buslist, struct usb_bus, bus_list); | 557 | bus = container_of(buslist, struct usb_bus, bus_list); |
549 | if (!bus->root_hub) | 558 | if (!bus->root_hub) |
@@ -576,6 +585,7 @@ int usb_get_current_frame_number(struct usb_device *dev) | |||
576 | { | 585 | { |
577 | return usb_hcd_get_frame_number(dev); | 586 | return usb_hcd_get_frame_number(dev); |
578 | } | 587 | } |
588 | EXPORT_SYMBOL_GPL(usb_get_current_frame_number); | ||
579 | 589 | ||
580 | /*-------------------------------------------------------------------*/ | 590 | /*-------------------------------------------------------------------*/ |
581 | /* | 591 | /* |
@@ -584,7 +594,7 @@ int usb_get_current_frame_number(struct usb_device *dev) | |||
584 | */ | 594 | */ |
585 | 595 | ||
586 | int __usb_get_extra_descriptor(char *buffer, unsigned size, | 596 | int __usb_get_extra_descriptor(char *buffer, unsigned size, |
587 | unsigned char type, void **ptr) | 597 | unsigned char type, void **ptr) |
588 | { | 598 | { |
589 | struct usb_descriptor_header *header; | 599 | struct usb_descriptor_header *header; |
590 | 600 | ||
@@ -595,7 +605,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
595 | printk(KERN_ERR | 605 | printk(KERN_ERR |
596 | "%s: bogus descriptor, type %d length %d\n", | 606 | "%s: bogus descriptor, type %d length %d\n", |
597 | usbcore_name, | 607 | usbcore_name, |
598 | header->bDescriptorType, | 608 | header->bDescriptorType, |
599 | header->bLength); | 609 | header->bLength); |
600 | return -1; | 610 | return -1; |
601 | } | 611 | } |
@@ -610,6 +620,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
610 | } | 620 | } |
611 | return -1; | 621 | return -1; |
612 | } | 622 | } |
623 | EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor); | ||
613 | 624 | ||
614 | /** | 625 | /** |
615 | * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP | 626 | * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP |
@@ -633,17 +644,14 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
633 | * | 644 | * |
634 | * When the buffer is no longer used, free it with usb_buffer_free(). | 645 | * When the buffer is no longer used, free it with usb_buffer_free(). |
635 | */ | 646 | */ |
636 | void *usb_buffer_alloc( | 647 | void *usb_buffer_alloc(struct usb_device *dev, size_t size, gfp_t mem_flags, |
637 | struct usb_device *dev, | 648 | dma_addr_t *dma) |
638 | size_t size, | ||
639 | gfp_t mem_flags, | ||
640 | dma_addr_t *dma | ||
641 | ) | ||
642 | { | 649 | { |
643 | if (!dev || !dev->bus) | 650 | if (!dev || !dev->bus) |
644 | return NULL; | 651 | return NULL; |
645 | return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); | 652 | return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); |
646 | } | 653 | } |
654 | EXPORT_SYMBOL_GPL(usb_buffer_alloc); | ||
647 | 655 | ||
648 | /** | 656 | /** |
649 | * usb_buffer_free - free memory allocated with usb_buffer_alloc() | 657 | * usb_buffer_free - free memory allocated with usb_buffer_alloc() |
@@ -656,12 +664,8 @@ void *usb_buffer_alloc( | |||
656 | * been allocated using usb_buffer_alloc(), and the parameters must match | 664 | * been allocated using usb_buffer_alloc(), and the parameters must match |
657 | * those provided in that allocation request. | 665 | * those provided in that allocation request. |
658 | */ | 666 | */ |
659 | void usb_buffer_free( | 667 | void usb_buffer_free(struct usb_device *dev, size_t size, void *addr, |
660 | struct usb_device *dev, | 668 | dma_addr_t dma) |
661 | size_t size, | ||
662 | void *addr, | ||
663 | dma_addr_t dma | ||
664 | ) | ||
665 | { | 669 | { |
666 | if (!dev || !dev->bus) | 670 | if (!dev || !dev->bus) |
667 | return; | 671 | return; |
@@ -669,6 +673,7 @@ void usb_buffer_free( | |||
669 | return; | 673 | return; |
670 | hcd_buffer_free(dev->bus, size, addr, dma); | 674 | hcd_buffer_free(dev->bus, size, addr, dma); |
671 | } | 675 | } |
676 | EXPORT_SYMBOL_GPL(usb_buffer_free); | ||
672 | 677 | ||
673 | /** | 678 | /** |
674 | * usb_buffer_map - create DMA mapping(s) for an urb | 679 | * usb_buffer_map - create DMA mapping(s) for an urb |
@@ -708,14 +713,15 @@ struct urb *usb_buffer_map(struct urb *urb) | |||
708 | urb->setup_packet, | 713 | urb->setup_packet, |
709 | sizeof(struct usb_ctrlrequest), | 714 | sizeof(struct usb_ctrlrequest), |
710 | DMA_TO_DEVICE); | 715 | DMA_TO_DEVICE); |
711 | // FIXME generic api broken like pci, can't report errors | 716 | /* FIXME generic api broken like pci, can't report errors */ |
712 | // if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; | 717 | /* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */ |
713 | } else | 718 | } else |
714 | urb->transfer_dma = ~0; | 719 | urb->transfer_dma = ~0; |
715 | urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | 720 | urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP |
716 | | URB_NO_SETUP_DMA_MAP); | 721 | | URB_NO_SETUP_DMA_MAP); |
717 | return urb; | 722 | return urb; |
718 | } | 723 | } |
724 | EXPORT_SYMBOL_GPL(usb_buffer_map); | ||
719 | #endif /* 0 */ | 725 | #endif /* 0 */ |
720 | 726 | ||
721 | /* XXX DISABLED, no users currently. If you wish to re-enable this | 727 | /* XXX DISABLED, no users currently. If you wish to re-enable this |
@@ -753,6 +759,7 @@ void usb_buffer_dmasync(struct urb *urb) | |||
753 | DMA_TO_DEVICE); | 759 | DMA_TO_DEVICE); |
754 | } | 760 | } |
755 | } | 761 | } |
762 | EXPORT_SYMBOL_GPL(usb_buffer_dmasync); | ||
756 | #endif | 763 | #endif |
757 | 764 | ||
758 | /** | 765 | /** |
@@ -788,6 +795,7 @@ void usb_buffer_unmap(struct urb *urb) | |||
788 | urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP | 795 | urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP |
789 | | URB_NO_SETUP_DMA_MAP); | 796 | | URB_NO_SETUP_DMA_MAP); |
790 | } | 797 | } |
798 | EXPORT_SYMBOL_GPL(usb_buffer_unmap); | ||
791 | #endif /* 0 */ | 799 | #endif /* 0 */ |
792 | 800 | ||
793 | /** | 801 | /** |
@@ -828,10 +836,11 @@ int usb_buffer_map_sg(const struct usb_device *dev, int is_in, | |||
828 | || !controller->dma_mask) | 836 | || !controller->dma_mask) |
829 | return -1; | 837 | return -1; |
830 | 838 | ||
831 | // FIXME generic api broken like pci, can't report errors | 839 | /* FIXME generic api broken like pci, can't report errors */ |
832 | return dma_map_sg(controller, sg, nents, | 840 | return dma_map_sg(controller, sg, nents, |
833 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 841 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
834 | } | 842 | } |
843 | EXPORT_SYMBOL_GPL(usb_buffer_map_sg); | ||
835 | 844 | ||
836 | /* XXX DISABLED, no users currently. If you wish to re-enable this | 845 | /* XXX DISABLED, no users currently. If you wish to re-enable this |
837 | * XXX please determine whether the sync is to transfer ownership of | 846 | * XXX please determine whether the sync is to transfer ownership of |
@@ -865,6 +874,7 @@ void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in, | |||
865 | dma_sync_sg(controller, sg, n_hw_ents, | 874 | dma_sync_sg(controller, sg, n_hw_ents, |
866 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 875 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
867 | } | 876 | } |
877 | EXPORT_SYMBOL_GPL(usb_buffer_dmasync_sg); | ||
868 | #endif | 878 | #endif |
869 | 879 | ||
870 | /** | 880 | /** |
@@ -891,6 +901,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in, | |||
891 | dma_unmap_sg(controller, sg, n_hw_ents, | 901 | dma_unmap_sg(controller, sg, n_hw_ents, |
892 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 902 | is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
893 | } | 903 | } |
904 | EXPORT_SYMBOL_GPL(usb_buffer_unmap_sg); | ||
894 | 905 | ||
895 | /* format to disable USB on kernel command line is: nousb */ | 906 | /* format to disable USB on kernel command line is: nousb */ |
896 | __module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444); | 907 | __module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444); |
@@ -902,6 +913,7 @@ int usb_disabled(void) | |||
902 | { | 913 | { |
903 | return nousb; | 914 | return nousb; |
904 | } | 915 | } |
916 | EXPORT_SYMBOL_GPL(usb_disabled); | ||
905 | 917 | ||
906 | /* | 918 | /* |
907 | * Init | 919 | * Init |
@@ -918,7 +930,7 @@ static int __init usb_init(void) | |||
918 | if (retval) | 930 | if (retval) |
919 | goto out; | 931 | goto out; |
920 | retval = bus_register(&usb_bus_type); | 932 | retval = bus_register(&usb_bus_type); |
921 | if (retval) | 933 | if (retval) |
922 | goto bus_register_failed; | 934 | goto bus_register_failed; |
923 | retval = usb_host_init(); | 935 | retval = usb_host_init(); |
924 | if (retval) | 936 | if (retval) |
@@ -983,45 +995,4 @@ static void __exit usb_exit(void) | |||
983 | 995 | ||
984 | subsys_initcall(usb_init); | 996 | subsys_initcall(usb_init); |
985 | module_exit(usb_exit); | 997 | module_exit(usb_exit); |
986 | |||
987 | /* | ||
988 | * USB may be built into the kernel or be built as modules. | ||
989 | * These symbols are exported for device (or host controller) | ||
990 | * driver modules to use. | ||
991 | */ | ||
992 | |||
993 | EXPORT_SYMBOL(usb_disabled); | ||
994 | |||
995 | EXPORT_SYMBOL_GPL(usb_get_intf); | ||
996 | EXPORT_SYMBOL_GPL(usb_put_intf); | ||
997 | |||
998 | EXPORT_SYMBOL(usb_put_dev); | ||
999 | EXPORT_SYMBOL(usb_get_dev); | ||
1000 | EXPORT_SYMBOL(usb_hub_tt_clear_buffer); | ||
1001 | |||
1002 | EXPORT_SYMBOL(usb_lock_device_for_reset); | ||
1003 | |||
1004 | EXPORT_SYMBOL(usb_find_interface); | ||
1005 | EXPORT_SYMBOL(usb_ifnum_to_if); | ||
1006 | EXPORT_SYMBOL(usb_altnum_to_altsetting); | ||
1007 | |||
1008 | EXPORT_SYMBOL(__usb_get_extra_descriptor); | ||
1009 | |||
1010 | EXPORT_SYMBOL(usb_get_current_frame_number); | ||
1011 | |||
1012 | EXPORT_SYMBOL(usb_buffer_alloc); | ||
1013 | EXPORT_SYMBOL(usb_buffer_free); | ||
1014 | |||
1015 | #if 0 | ||
1016 | EXPORT_SYMBOL(usb_buffer_map); | ||
1017 | EXPORT_SYMBOL(usb_buffer_dmasync); | ||
1018 | EXPORT_SYMBOL(usb_buffer_unmap); | ||
1019 | #endif | ||
1020 | |||
1021 | EXPORT_SYMBOL(usb_buffer_map_sg); | ||
1022 | #if 0 | ||
1023 | EXPORT_SYMBOL(usb_buffer_dmasync_sg); | ||
1024 | #endif | ||
1025 | EXPORT_SYMBOL(usb_buffer_unmap_sg); | ||
1026 | |||
1027 | MODULE_LICENSE("GPL"); | 998 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index c52626c51f70..2375194a9d43 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -1,22 +1,23 @@ | |||
1 | /* Functions local to drivers/usb/core/ */ | 1 | /* Functions local to drivers/usb/core/ */ |
2 | 2 | ||
3 | extern int usb_create_sysfs_dev_files (struct usb_device *dev); | 3 | extern int usb_create_sysfs_dev_files(struct usb_device *dev); |
4 | extern void usb_remove_sysfs_dev_files (struct usb_device *dev); | 4 | extern void usb_remove_sysfs_dev_files(struct usb_device *dev); |
5 | extern int usb_create_sysfs_intf_files (struct usb_interface *intf); | 5 | extern int usb_create_sysfs_intf_files(struct usb_interface *intf); |
6 | extern void usb_remove_sysfs_intf_files (struct usb_interface *intf); | 6 | extern void usb_remove_sysfs_intf_files(struct usb_interface *intf); |
7 | extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint, | 7 | extern int usb_create_ep_files(struct device *parent, |
8 | struct usb_host_endpoint *endpoint, | ||
8 | struct usb_device *udev); | 9 | struct usb_device *udev); |
9 | extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint); | 10 | extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint); |
10 | 11 | ||
11 | extern void usb_enable_endpoint(struct usb_device *dev, | 12 | extern void usb_enable_endpoint(struct usb_device *dev, |
12 | struct usb_host_endpoint *ep); | 13 | struct usb_host_endpoint *ep); |
13 | extern void usb_disable_endpoint (struct usb_device *dev, unsigned int epaddr); | 14 | extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr); |
14 | extern void usb_disable_interface (struct usb_device *dev, | 15 | extern void usb_disable_interface(struct usb_device *dev, |
15 | struct usb_interface *intf); | 16 | struct usb_interface *intf); |
16 | extern void usb_release_interface_cache(struct kref *ref); | 17 | extern void usb_release_interface_cache(struct kref *ref); |
17 | extern void usb_disable_device (struct usb_device *dev, int skip_ep0); | 18 | extern void usb_disable_device(struct usb_device *dev, int skip_ep0); |
18 | extern int usb_deauthorize_device (struct usb_device *); | 19 | extern int usb_deauthorize_device(struct usb_device *); |
19 | extern int usb_authorize_device (struct usb_device *); | 20 | extern int usb_authorize_device(struct usb_device *); |
20 | extern void usb_detect_quirks(struct usb_device *udev); | 21 | extern void usb_detect_quirks(struct usb_device *udev); |
21 | 22 | ||
22 | extern int usb_get_device_descriptor(struct usb_device *dev, | 23 | extern int usb_get_device_descriptor(struct usb_device *dev, |