4 * (C) Copyright Linus Torvalds 1999
5 * (C) Copyright Johannes Erdfelt 1999-2001
6 * (C) Copyright Andreas Gal 1999
7 * (C) Copyright Gregory P. Smith 1999
8 * (C) Copyright Deti Fliegl 1999 (new USB architecture)
9 * (C) Copyright Randy Dunlap 2000
10 * (C) Copyright David Brownell 2000-2004
11 * (C) Copyright Yggdrasil Computing, Inc. 2000
12 * (usb_device_id matching changes by Adam J. Richter)
13 * (C) Copyright Greg Kroah-Hartman 2002-2003
15 * NOTE! This is not actually a driver at all, rather this is
16 * just a collection of helper routines that implement the
17 * generic USB things that the real drivers can use..
19 * Think of this as a "USB library" rather than anything else.
20 * It should be considered a slave, with no callbacks. Callbacks
24 #include <linux/config.h>
26 #ifdef CONFIG_USB_DEBUG
32 #include <linux/module.h>
33 #include <linux/string.h>
34 #include <linux/bitops.h>
35 #include <linux/slab.h>
36 #include <linux/interrupt.h> /* for in_interrupt() */
37 #include <linux/kmod.h>
38 #include <linux/init.h>
39 #include <linux/spinlock.h>
40 #include <linux/errno.h>
41 #include <linux/smp_lock.h>
42 #include <linux/rwsem.h>
43 #include <linux/usb.h>
46 #include <asm/scatterlist.h>
48 #include <linux/dma-mapping.h>
54 const char *usbcore_name = "usbcore";
56 static int nousb; /* Disable USB when built into kernel image */
57 /* Not honored on modular build */
59 static DECLARE_RWSEM(usb_all_devices_rwsem);
62 static int generic_probe (struct device *dev)
66 static int generic_remove (struct device *dev)
68 struct usb_device *udev = to_usb_device(dev);
70 /* if this is only an unbind, not a physical disconnect, then
71 * unconfigure the device */
72 if (udev->state == USB_STATE_CONFIGURED)
73 usb_set_configuration(udev, 0);
75 /* in case the call failed or the device was suspended */
76 if (udev->state >= USB_STATE_CONFIGURED)
77 usb_disable_device(udev, 0);
81 static struct device_driver usb_generic_driver = {
85 .probe = generic_probe,
86 .remove = generic_remove,
89 static int usb_generic_driver_data;
91 /* called from driver core with usb_bus_type.subsys writelock */
92 static int usb_probe_interface(struct device *dev)
94 struct usb_interface * intf = to_usb_interface(dev);
95 struct usb_driver * driver = to_usb_driver(dev->driver);
96 const struct usb_device_id *id;
99 dev_dbg(dev, "%s\n", __FUNCTION__);
103 /* FIXME we'd much prefer to just resume it ... */
104 if (interface_to_usbdev(intf)->state == USB_STATE_SUSPENDED)
105 return -EHOSTUNREACH;
107 id = usb_match_id (intf, driver->id_table);
109 dev_dbg (dev, "%s - got id\n", __FUNCTION__);
111 /* Interface "power state" doesn't correspond to any hardware
112 * state whatsoever. We use it to record when it's bound to
113 * a driver that may start I/0: it's not frozen/quiesced.
116 intf->condition = USB_INTERFACE_BINDING;
117 error = driver->probe (intf, id);
120 intf->condition = USB_INTERFACE_UNBOUND;
122 intf->condition = USB_INTERFACE_BOUND;
128 /* called from driver core with usb_bus_type.subsys writelock */
129 static int usb_unbind_interface(struct device *dev)
131 struct usb_interface *intf = to_usb_interface(dev);
132 struct usb_driver *driver = to_usb_driver(intf->dev.driver);
134 intf->condition = USB_INTERFACE_UNBINDING;
136 /* release all urbs for this interface */
137 usb_disable_interface(interface_to_usbdev(intf), intf);
139 if (driver && driver->disconnect)
140 driver->disconnect(intf);
142 /* reset other interface state */
143 usb_set_interface(interface_to_usbdev(intf),
144 intf->altsetting[0].desc.bInterfaceNumber,
146 usb_set_intfdata(intf, NULL);
147 intf->condition = USB_INTERFACE_UNBOUND;
154 * usb_register - register a USB driver
155 * @new_driver: USB operations for the driver
157 * Registers a USB driver with the USB core. The list of unattached
158 * interfaces will be rescanned whenever a new driver is added, allowing
159 * the new driver to attach to any recognized devices.
160 * Returns a negative error code on failure and 0 on success.
162 * NOTE: if you want your driver to use the USB major number, you must call
163 * usb_register_dev() to enable that functionality. This function no longer
164 * takes care of that.
166 int usb_register(struct usb_driver *new_driver)
173 new_driver->driver.name = (char *)new_driver->name;
174 new_driver->driver.bus = &usb_bus_type;
175 new_driver->driver.probe = usb_probe_interface;
176 new_driver->driver.remove = usb_unbind_interface;
177 new_driver->driver.owner = new_driver->owner;
179 usb_lock_all_devices();
180 retval = driver_register(&new_driver->driver);
181 usb_unlock_all_devices();
184 pr_info("%s: registered new driver %s\n",
185 usbcore_name, new_driver->name);
186 usbfs_update_special();
188 printk(KERN_ERR "%s: error %d registering driver %s\n",
189 usbcore_name, retval, new_driver->name);
196 * usb_deregister - unregister a USB driver
197 * @driver: USB operations of the driver to unregister
198 * Context: must be able to sleep
200 * Unlinks the specified driver from the internal USB driver list.
202 * NOTE: If you called usb_register_dev(), you still need to call
203 * usb_deregister_dev() to clean up your driver's allocated minor numbers,
204 * this * call will no longer do it for you.
206 void usb_deregister(struct usb_driver *driver)
208 pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name);
210 usb_lock_all_devices();
211 driver_unregister (&driver->driver);
212 usb_unlock_all_devices();
214 usbfs_update_special();
218 * usb_ifnum_to_if - get the interface object with a given interface number
219 * @dev: the device whose current configuration is considered
220 * @ifnum: the desired interface
222 * This walks the device descriptor for the currently active configuration
223 * and returns a pointer to the interface with that particular interface
226 * Note that configuration descriptors are not required to assign interface
227 * numbers sequentially, so that it would be incorrect to assume that
228 * the first interface in that descriptor corresponds to interface zero.
229 * This routine helps device drivers avoid such mistakes.
230 * However, you should make sure that you do the right thing with any
231 * alternate settings available for this interfaces.
233 * Don't call this function unless you are bound to one of the interfaces
234 * on this device or you have locked the device!
236 struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
238 struct usb_host_config *config = dev->actconfig;
243 for (i = 0; i < config->desc.bNumInterfaces; i++)
244 if (config->interface[i]->altsetting[0]
245 .desc.bInterfaceNumber == ifnum)
246 return config->interface[i];
252 * usb_altnum_to_altsetting - get the altsetting structure with a given
253 * alternate setting number.
254 * @intf: the interface containing the altsetting in question
255 * @altnum: the desired alternate setting number
257 * This searches the altsetting array of the specified interface for
258 * an entry with the correct bAlternateSetting value and returns a pointer
259 * to that entry, or null.
261 * Note that altsettings need not be stored sequentially by number, so
262 * it would be incorrect to assume that the first altsetting entry in
263 * the array corresponds to altsetting zero. This routine helps device
264 * drivers avoid such mistakes.
266 * Don't call this function unless you are bound to the intf interface
267 * or you have locked the device!
269 struct usb_host_interface *usb_altnum_to_altsetting(struct usb_interface *intf,
274 for (i = 0; i < intf->num_altsetting; i++) {
275 if (intf->altsetting[i].desc.bAlternateSetting == altnum)
276 return &intf->altsetting[i];
282 * usb_driver_claim_interface - bind a driver to an interface
283 * @driver: the driver to be bound
284 * @iface: the interface to which it will be bound; must be in the
285 * usb device's active configuration
286 * @priv: driver data associated with that interface
288 * This is used by usb device drivers that need to claim more than one
289 * interface on a device when probing (audio and acm are current examples).
290 * No device driver should directly modify internal usb_interface or
291 * usb_device structure members.
293 * Few drivers should need to use this routine, since the most natural
294 * way to bind to an interface is to return the private data from
295 * the driver's probe() method.
297 * Callers must own the device lock and the driver model's usb_bus_type.subsys
298 * writelock. So driver probe() entries don't need extra locking,
299 * but other call contexts may need to explicitly claim those locks.
301 int usb_driver_claim_interface(struct usb_driver *driver,
302 struct usb_interface *iface, void* priv)
304 struct device *dev = &iface->dev;
309 dev->driver = &driver->driver;
310 usb_set_intfdata(iface, priv);
311 iface->condition = USB_INTERFACE_BOUND;
314 /* if interface was already added, bind now; else let
315 * the future device_add() bind it, bypassing probe()
317 if (device_is_registered(dev))
318 device_bind_driver(dev);
324 * usb_driver_release_interface - unbind a driver from an interface
325 * @driver: the driver to be unbound
326 * @iface: the interface from which it will be unbound
328 * This can be used by drivers to release an interface without waiting
329 * for their disconnect() methods to be called. In typical cases this
330 * also causes the driver disconnect() method to be called.
332 * This call is synchronous, and may not be used in an interrupt context.
333 * Callers must own the device lock and the driver model's usb_bus_type.subsys
334 * writelock. So driver disconnect() entries don't need extra locking,
335 * but other call contexts may need to explicitly claim those locks.
337 void usb_driver_release_interface(struct usb_driver *driver,
338 struct usb_interface *iface)
340 struct device *dev = &iface->dev;
342 /* this should never happen, don't release something that's not ours */
343 if (!dev->driver || dev->driver != &driver->driver)
346 /* don't release from within disconnect() */
347 if (iface->condition != USB_INTERFACE_BOUND)
350 /* don't release if the interface hasn't been added yet */
351 if (device_is_registered(dev)) {
352 iface->condition = USB_INTERFACE_UNBINDING;
353 device_release_driver(dev);
357 usb_set_intfdata(iface, NULL);
358 iface->condition = USB_INTERFACE_UNBOUND;
359 mark_quiesced(iface);
363 * usb_match_id - find first usb_device_id matching device or interface
364 * @interface: the interface of interest
365 * @id: array of usb_device_id structures, terminated by zero entry
367 * usb_match_id searches an array of usb_device_id's and returns
368 * the first one matching the device or interface, or null.
369 * This is used when binding (or rebinding) a driver to an interface.
370 * Most USB device drivers will use this indirectly, through the usb core,
371 * but some layered driver frameworks use it directly.
372 * These device tables are exported with MODULE_DEVICE_TABLE, through
373 * modutils and "modules.usbmap", to support the driver loading
374 * functionality of USB hotplugging.
378 * The "match_flags" element in a usb_device_id controls which
379 * members are used. If the corresponding bit is set, the
380 * value in the device_id must match its corresponding member
381 * in the device or interface descriptor, or else the device_id
384 * "driver_info" is normally used only by device drivers,
385 * but you can create a wildcard "matches anything" usb_device_id
386 * as a driver's "modules.usbmap" entry if you provide an id with
387 * only a nonzero "driver_info" field. If you do this, the USB device
388 * driver's probe() routine should use additional intelligence to
389 * decide whether to bind to the specified interface.
391 * What Makes Good usb_device_id Tables:
393 * The match algorithm is very simple, so that intelligence in
394 * driver selection must come from smart driver id records.
395 * Unless you have good reasons to use another selection policy,
396 * provide match elements only in related groups, and order match
397 * specifiers from specific to general. Use the macros provided
398 * for that purpose if you can.
400 * The most specific match specifiers use device descriptor
401 * data. These are commonly used with product-specific matches;
402 * the USB_DEVICE macro lets you provide vendor and product IDs,
403 * and you can also match against ranges of product revisions.
404 * These are widely used for devices with application or vendor
405 * specific bDeviceClass values.
407 * Matches based on device class/subclass/protocol specifications
408 * are slightly more general; use the USB_DEVICE_INFO macro, or
409 * its siblings. These are used with single-function devices
410 * where bDeviceClass doesn't specify that each interface has
413 * Matches based on interface class/subclass/protocol are the
414 * most general; they let drivers bind to any interface on a
415 * multiple-function device. Use the USB_INTERFACE_INFO
416 * macro, or its siblings, to match class-per-interface style
417 * devices (as recorded in bDeviceClass).
419 * Within those groups, remember that not all combinations are
420 * meaningful. For example, don't give a product version range
421 * without vendor and product IDs; or specify a protocol without
422 * its associated class and subclass.
424 const struct usb_device_id *
425 usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
427 struct usb_host_interface *intf;
428 struct usb_device *dev;
430 /* proc_connectinfo in devio.c may call us with id == NULL. */
434 intf = interface->cur_altsetting;
435 dev = interface_to_usbdev(interface);
437 /* It is important to check that id->driver_info is nonzero,
438 since an entry that is all zeroes except for a nonzero
439 id->driver_info is the way to create an entry that
440 indicates that the driver want to examine every
441 device and interface. */
442 for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass ||
443 id->driver_info; id++) {
445 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
446 id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
449 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
450 id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
453 /* No need to test id->bcdDevice_lo != 0, since 0 is never
454 greater than any unsigned number. */
455 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
456 (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
459 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
460 (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
463 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
464 (id->bDeviceClass != dev->descriptor.bDeviceClass))
467 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
468 (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass))
471 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
472 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
475 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
476 (id->bInterfaceClass != intf->desc.bInterfaceClass))
479 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&
480 (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass))
483 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&
484 (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol))
494 static int __find_interface(struct device * dev, void * data)
496 struct usb_interface ** ret = (struct usb_interface **)data;
497 struct usb_interface * intf = *ret;
498 int *minor = (int *)data;
500 /* can't look at usb devices, only interfaces */
501 if (dev->driver == &usb_generic_driver)
504 intf = to_usb_interface(dev);
505 if (intf->minor != -1 && intf->minor == *minor) {
513 * usb_find_interface - find usb_interface pointer for driver and device
514 * @drv: the driver whose current configuration is considered
515 * @minor: the minor number of the desired device
517 * This walks the driver device list and returns a pointer to the interface
518 * with the matching minor. Note, this only works for devices that share the
521 struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
523 struct usb_interface *intf = (struct usb_interface *)(long)minor;
526 ret = driver_for_each_device(&drv->driver, NULL, &intf, __find_interface);
528 return ret ? intf : NULL;
531 static int usb_device_match (struct device *dev, struct device_driver *drv)
533 struct usb_interface *intf;
534 struct usb_driver *usb_drv;
535 const struct usb_device_id *id;
537 /* check for generic driver, which we don't match any device with */
538 if (drv == &usb_generic_driver)
541 intf = to_usb_interface(dev);
542 usb_drv = to_usb_driver(drv);
544 id = usb_match_id (intf, usb_drv->id_table);
552 #ifdef CONFIG_HOTPLUG
555 * USB hotplugging invokes what /proc/sys/kernel/hotplug says
556 * (normally /sbin/hotplug) when USB devices get added or removed.
558 * This invokes a user mode policy agent, typically helping to load driver
559 * or other modules, configure the device, and more. Drivers can provide
560 * a MODULE_DEVICE_TABLE to help with module loading subtasks.
562 * We're called either from khubd (the typical case) or from root hub
563 * (init, kapmd, modprobe, rmmod, etc), but the agents need to handle
564 * delays in event delivery. Use sysfs (and DEVPATH) to make sure the
565 * device (and this configuration!) are still present.
567 static int usb_hotplug (struct device *dev, char **envp, int num_envp,
568 char *buffer, int buffer_size)
570 struct usb_interface *intf;
571 struct usb_device *usb_dev;
578 /* driver is often null here; dev_dbg() would oops */
579 pr_debug ("usb %s: hotplug\n", dev->bus_id);
581 /* Must check driver_data here, as on remove driver is always NULL */
582 if ((dev->driver == &usb_generic_driver) ||
583 (dev->driver_data == &usb_generic_driver_data))
586 intf = to_usb_interface(dev);
587 usb_dev = interface_to_usbdev (intf);
589 if (usb_dev->devnum < 0) {
590 pr_debug ("usb %s: already deleted?\n", dev->bus_id);
594 pr_debug ("usb %s: bus removed?\n", dev->bus_id);
598 #ifdef CONFIG_USB_DEVICEFS
599 /* If this is available, userspace programs can directly read
600 * all the device descriptors we don't tell them about. Or
601 * even act as usermode drivers.
603 * FIXME reduce hardwired intelligence here
605 if (add_hotplug_env_var(envp, num_envp, &i,
606 buffer, buffer_size, &length,
607 "DEVICE=/proc/bus/usb/%03d/%03d",
608 usb_dev->bus->busnum, usb_dev->devnum))
612 /* per-device configurations are common */
613 if (add_hotplug_env_var(envp, num_envp, &i,
614 buffer, buffer_size, &length,
616 le16_to_cpu(usb_dev->descriptor.idVendor),
617 le16_to_cpu(usb_dev->descriptor.idProduct),
618 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
621 /* class-based driver binding models */
622 if (add_hotplug_env_var(envp, num_envp, &i,
623 buffer, buffer_size, &length,
625 usb_dev->descriptor.bDeviceClass,
626 usb_dev->descriptor.bDeviceSubClass,
627 usb_dev->descriptor.bDeviceProtocol))
630 if (usb_dev->descriptor.bDeviceClass == 0) {
631 struct usb_host_interface *alt = intf->cur_altsetting;
633 /* 2.4 only exposed interface zero. in 2.5, hotplug
634 * agents are called for all interfaces, and can use
635 * $DEVPATH/bInterfaceNumber if necessary.
637 if (add_hotplug_env_var(envp, num_envp, &i,
638 buffer, buffer_size, &length,
639 "INTERFACE=%d/%d/%d",
640 alt->desc.bInterfaceClass,
641 alt->desc.bInterfaceSubClass,
642 alt->desc.bInterfaceProtocol))
645 if (add_hotplug_env_var(envp, num_envp, &i,
646 buffer, buffer_size, &length,
647 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
648 le16_to_cpu(usb_dev->descriptor.idVendor),
649 le16_to_cpu(usb_dev->descriptor.idProduct),
650 le16_to_cpu(usb_dev->descriptor.bcdDevice),
651 usb_dev->descriptor.bDeviceClass,
652 usb_dev->descriptor.bDeviceSubClass,
653 usb_dev->descriptor.bDeviceProtocol,
654 alt->desc.bInterfaceClass,
655 alt->desc.bInterfaceSubClass,
656 alt->desc.bInterfaceProtocol))
659 if (add_hotplug_env_var(envp, num_envp, &i,
660 buffer, buffer_size, &length,
661 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*",
662 le16_to_cpu(usb_dev->descriptor.idVendor),
663 le16_to_cpu(usb_dev->descriptor.idProduct),
664 le16_to_cpu(usb_dev->descriptor.bcdDevice),
665 usb_dev->descriptor.bDeviceClass,
666 usb_dev->descriptor.bDeviceSubClass,
667 usb_dev->descriptor.bDeviceProtocol))
678 static int usb_hotplug (struct device *dev, char **envp,
679 int num_envp, char *buffer, int buffer_size)
684 #endif /* CONFIG_HOTPLUG */
687 * usb_release_dev - free a usb device structure when all users of it are finished.
688 * @dev: device that's been disconnected
690 * Will be called only by the device core when all users of this usb device are
693 static void usb_release_dev(struct device *dev)
695 struct usb_device *udev;
697 udev = to_usb_device(dev);
699 usb_destroy_configuration(udev);
700 usb_bus_put(udev->bus);
701 kfree(udev->product);
702 kfree(udev->manufacturer);
708 * usb_alloc_dev - usb device constructor (usbcore-internal)
709 * @parent: hub to which device is connected; null to allocate a root hub
710 * @bus: bus used to access the device
711 * @port1: one-based index of port; ignored for root hubs
712 * Context: !in_interrupt ()
714 * Only hub drivers (including virtual root hub drivers for host
715 * controllers) should ever call this.
717 * This call may not be used in a non-sleeping context.
720 usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
722 struct usb_device *dev;
724 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
728 memset(dev, 0, sizeof(*dev));
730 bus = usb_bus_get(bus);
736 device_initialize(&dev->dev);
737 dev->dev.bus = &usb_bus_type;
738 dev->dev.dma_mask = bus->controller->dma_mask;
739 dev->dev.driver_data = &usb_generic_driver_data;
740 dev->dev.driver = &usb_generic_driver;
741 dev->dev.release = usb_release_dev;
742 dev->state = USB_STATE_ATTACHED;
744 INIT_LIST_HEAD(&dev->ep0.urb_list);
745 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
746 dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT;
747 /* ep0 maxpacket comes later, from device descriptor */
748 dev->ep_in[0] = dev->ep_out[0] = &dev->ep0;
750 /* Save readable and stable topology id, distinguishing devices
751 * by location for diagnostics, tools, driver model, etc. The
752 * string is a path along hub ports, from the root. Each device's
753 * dev->devpath will be stable until USB is re-cabled, and hubs
754 * are often labeled with these port numbers. The bus_id isn't
755 * as stable: bus->busnum changes easily from modprobe order,
756 * cardbus or pci hotplugging, and so on.
758 if (unlikely (!parent)) {
759 dev->devpath [0] = '0';
761 dev->dev.parent = bus->controller;
762 sprintf (&dev->dev.bus_id[0], "usb%d", bus->busnum);
764 /* match any labeling on the hubs; it's one-based */
765 if (parent->devpath [0] == '0')
766 snprintf (dev->devpath, sizeof dev->devpath,
769 snprintf (dev->devpath, sizeof dev->devpath,
770 "%s.%d", parent->devpath, port1);
772 dev->dev.parent = &parent->dev;
773 sprintf (&dev->dev.bus_id[0], "%d-%s",
774 bus->busnum, dev->devpath);
776 /* hub driver sets up TT records */
780 dev->parent = parent;
781 INIT_LIST_HEAD(&dev->filelist);
783 init_MUTEX(&dev->serialize);
789 * usb_get_dev - increments the reference count of the usb device structure
790 * @dev: the device being referenced
792 * Each live reference to a device should be refcounted.
794 * Drivers for USB interfaces should normally record such references in
795 * their probe() methods, when they bind to an interface, and release
796 * them by calling usb_put_dev(), in their disconnect() methods.
798 * A pointer to the device with the incremented reference counter is returned.
800 struct usb_device *usb_get_dev(struct usb_device *dev)
803 get_device(&dev->dev);
808 * usb_put_dev - release a use of the usb device structure
809 * @dev: device that's been disconnected
811 * Must be called when a user of a device is finished with it. When the last
812 * user of the device calls this function, the memory of the device is freed.
814 void usb_put_dev(struct usb_device *dev)
817 put_device(&dev->dev);
821 * usb_get_intf - increments the reference count of the usb interface structure
822 * @intf: the interface being referenced
824 * Each live reference to a interface must be refcounted.
826 * Drivers for USB interfaces should normally record such references in
827 * their probe() methods, when they bind to an interface, and release
828 * them by calling usb_put_intf(), in their disconnect() methods.
830 * A pointer to the interface with the incremented reference counter is
833 struct usb_interface *usb_get_intf(struct usb_interface *intf)
836 get_device(&intf->dev);
841 * usb_put_intf - release a use of the usb interface structure
842 * @intf: interface that's been decremented
844 * Must be called when a user of an interface is finished with it. When the
845 * last user of the interface calls this function, the memory of the interface
848 void usb_put_intf(struct usb_interface *intf)
851 put_device(&intf->dev);
855 /* USB device locking
857 * Although locking USB devices should be straightforward, it is
858 * complicated by the way the driver-model core works. When a new USB
859 * driver is registered or unregistered, the core will automatically
860 * probe or disconnect all matching interfaces on all USB devices while
861 * holding the USB subsystem writelock. There's no good way for us to
862 * tell which devices will be used or to lock them beforehand; our only
863 * option is to effectively lock all the USB devices.
865 * We do that by using a private rw-semaphore, usb_all_devices_rwsem.
866 * When locking an individual device you must first acquire the rwsem's
867 * readlock. When a driver is registered or unregistered the writelock
868 * must be held. These actions are encapsulated in the subroutines
869 * below, so all a driver needs to do is call usb_lock_device() and
870 * usb_unlock_device().
872 * Complications arise when several devices are to be locked at the same
873 * time. Only hub-aware drivers that are part of usbcore ever have to
874 * do this; nobody else needs to worry about it. The problem is that
875 * usb_lock_device() must not be called to lock a second device since it
876 * would acquire the rwsem's readlock reentrantly, leading to deadlock if
877 * another thread was waiting for the writelock. The solution is simple:
879 * When locking more than one device, call usb_lock_device()
880 * to lock the first one. Lock the others by calling
881 * down(&udev->serialize) directly.
883 * When unlocking multiple devices, use up(&udev->serialize)
884 * to unlock all but the last one. Unlock the last one by
885 * calling usb_unlock_device().
887 * When locking both a device and its parent, always lock the
892 * usb_lock_device - acquire the lock for a usb device structure
893 * @udev: device that's being locked
895 * Use this routine when you don't hold any other device locks;
896 * to acquire nested inner locks call down(&udev->serialize) directly.
897 * This is necessary for proper interaction with usb_lock_all_devices().
899 void usb_lock_device(struct usb_device *udev)
901 down_read(&usb_all_devices_rwsem);
902 down(&udev->serialize);
906 * usb_trylock_device - attempt to acquire the lock for a usb device structure
907 * @udev: device that's being locked
909 * Don't use this routine if you already hold a device lock;
910 * use down_trylock(&udev->serialize) instead.
911 * This is necessary for proper interaction with usb_lock_all_devices().
913 * Returns 1 if successful, 0 if contention.
915 int usb_trylock_device(struct usb_device *udev)
917 if (!down_read_trylock(&usb_all_devices_rwsem))
919 if (down_trylock(&udev->serialize)) {
920 up_read(&usb_all_devices_rwsem);
927 * usb_lock_device_for_reset - cautiously acquire the lock for a
928 * usb device structure
929 * @udev: device that's being locked
930 * @iface: interface bound to the driver making the request (optional)
932 * Attempts to acquire the device lock, but fails if the device is
933 * NOTATTACHED or SUSPENDED, or if iface is specified and the interface
934 * is neither BINDING nor BOUND. Rather than sleeping to wait for the
935 * lock, the routine polls repeatedly. This is to prevent deadlock with
936 * disconnect; in some drivers (such as usb-storage) the disconnect()
937 * or suspend() method will block waiting for a device reset to complete.
939 * Returns a negative error code for failure, otherwise 1 or 0 to indicate
940 * that the device will or will not have to be unlocked. (0 can be
941 * returned when an interface is given and is BINDING, because in that
942 * case the driver already owns the device lock.)
944 int usb_lock_device_for_reset(struct usb_device *udev,
945 struct usb_interface *iface)
947 unsigned long jiffies_expire = jiffies + HZ;
949 if (udev->state == USB_STATE_NOTATTACHED)
951 if (udev->state == USB_STATE_SUSPENDED)
952 return -EHOSTUNREACH;
954 switch (iface->condition) {
955 case USB_INTERFACE_BINDING:
957 case USB_INTERFACE_BOUND:
964 while (!usb_trylock_device(udev)) {
966 /* If we can't acquire the lock after waiting one second,
967 * we're probably deadlocked */
968 if (time_after(jiffies, jiffies_expire))
972 if (udev->state == USB_STATE_NOTATTACHED)
974 if (udev->state == USB_STATE_SUSPENDED)
975 return -EHOSTUNREACH;
976 if (iface && iface->condition != USB_INTERFACE_BOUND)
983 * usb_unlock_device - release the lock for a usb device structure
984 * @udev: device that's being unlocked
986 * Use this routine when releasing the only device lock you hold;
987 * to release inner nested locks call up(&udev->serialize) directly.
988 * This is necessary for proper interaction with usb_lock_all_devices().
990 void usb_unlock_device(struct usb_device *udev)
992 up(&udev->serialize);
993 up_read(&usb_all_devices_rwsem);
997 * usb_lock_all_devices - acquire the lock for all usb device structures
999 * This is necessary when registering a new driver or probing a bus,
1000 * since the driver-model core may try to use any usb_device.
1002 void usb_lock_all_devices(void)
1004 down_write(&usb_all_devices_rwsem);
1008 * usb_unlock_all_devices - release the lock for all usb device structures
1010 void usb_unlock_all_devices(void)
1012 up_write(&usb_all_devices_rwsem);
1016 static struct usb_device *match_device(struct usb_device *dev,
1017 u16 vendor_id, u16 product_id)
1019 struct usb_device *ret_dev = NULL;
1022 dev_dbg(&dev->dev, "check for vendor %04x, product %04x ...\n",
1023 le16_to_cpu(dev->descriptor.idVendor),
1024 le16_to_cpu(dev->descriptor.idProduct));
1026 /* see if this device matches */
1027 if ((vendor_id == le16_to_cpu(dev->descriptor.idVendor)) &&
1028 (product_id == le16_to_cpu(dev->descriptor.idProduct))) {
1029 dev_dbg (&dev->dev, "matched this device!\n");
1030 ret_dev = usb_get_dev(dev);
1034 /* look through all of the children of this device */
1035 for (child = 0; child < dev->maxchild; ++child) {
1036 if (dev->children[child]) {
1037 down(&dev->children[child]->serialize);
1038 ret_dev = match_device(dev->children[child],
1039 vendor_id, product_id);
1040 up(&dev->children[child]->serialize);
1050 * usb_find_device - find a specific usb device in the system
1051 * @vendor_id: the vendor id of the device to find
1052 * @product_id: the product id of the device to find
1054 * Returns a pointer to a struct usb_device if such a specified usb
1055 * device is present in the system currently. The usage count of the
1056 * device will be incremented if a device is found. Make sure to call
1057 * usb_put_dev() when the caller is finished with the device.
1059 * If a device with the specified vendor and product id is not found,
1062 struct usb_device *usb_find_device(u16 vendor_id, u16 product_id)
1064 struct list_head *buslist;
1065 struct usb_bus *bus;
1066 struct usb_device *dev = NULL;
1068 down(&usb_bus_list_lock);
1069 for (buslist = usb_bus_list.next;
1070 buslist != &usb_bus_list;
1071 buslist = buslist->next) {
1072 bus = container_of(buslist, struct usb_bus, bus_list);
1075 usb_lock_device(bus->root_hub);
1076 dev = match_device(bus->root_hub, vendor_id, product_id);
1077 usb_unlock_device(bus->root_hub);
1082 up(&usb_bus_list_lock);
1087 * usb_get_current_frame_number - return current bus frame number
1088 * @dev: the device whose bus is being queried
1090 * Returns the current frame number for the USB host controller
1091 * used with the given USB device. This can be used when scheduling
1092 * isochronous requests.
1094 * Note that different kinds of host controller have different
1095 * "scheduling horizons". While one type might support scheduling only
1096 * 32 frames into the future, others could support scheduling up to
1097 * 1024 frames into the future.
1099 int usb_get_current_frame_number(struct usb_device *dev)
1101 return dev->bus->op->get_frame_number (dev);
1104 /*-------------------------------------------------------------------*/
1106 * __usb_get_extra_descriptor() finds a descriptor of specific type in the
1107 * extra field of the interface and endpoint descriptor structs.
1110 int __usb_get_extra_descriptor(char *buffer, unsigned size,
1111 unsigned char type, void **ptr)
1113 struct usb_descriptor_header *header;
1115 while (size >= sizeof(struct usb_descriptor_header)) {
1116 header = (struct usb_descriptor_header *)buffer;
1118 if (header->bLength < 2) {
1120 "%s: bogus descriptor, type %d length %d\n",
1122 header->bDescriptorType,
1127 if (header->bDescriptorType == type) {
1132 buffer += header->bLength;
1133 size -= header->bLength;
1139 * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP
1140 * @dev: device the buffer will be used with
1141 * @size: requested buffer size
1142 * @mem_flags: affect whether allocation may block
1143 * @dma: used to return DMA address of buffer
1145 * Return value is either null (indicating no buffer could be allocated), or
1146 * the cpu-space pointer to a buffer that may be used to perform DMA to the
1147 * specified device. Such cpu-space buffers are returned along with the DMA
1148 * address (through the pointer provided).
1150 * These buffers are used with URB_NO_xxx_DMA_MAP set in urb->transfer_flags
1151 * to avoid behaviors like using "DMA bounce buffers", or tying down I/O
1152 * mapping hardware for long idle periods. The implementation varies between
1153 * platforms, depending on details of how DMA will work to this device.
1154 * Using these buffers also helps prevent cacheline sharing problems on
1155 * architectures where CPU caches are not DMA-coherent.
1157 * When the buffer is no longer used, free it with usb_buffer_free().
1159 void *usb_buffer_alloc (
1160 struct usb_device *dev,
1166 if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_alloc)
1168 return dev->bus->op->buffer_alloc (dev->bus, size, mem_flags, dma);
1172 * usb_buffer_free - free memory allocated with usb_buffer_alloc()
1173 * @dev: device the buffer was used with
1174 * @size: requested buffer size
1175 * @addr: CPU address of buffer
1176 * @dma: DMA address of buffer
1178 * This reclaims an I/O buffer, letting it be reused. The memory must have
1179 * been allocated using usb_buffer_alloc(), and the parameters must match
1180 * those provided in that allocation request.
1182 void usb_buffer_free (
1183 struct usb_device *dev,
1189 if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_free)
1191 dev->bus->op->buffer_free (dev->bus, size, addr, dma);
1195 * usb_buffer_map - create DMA mapping(s) for an urb
1196 * @urb: urb whose transfer_buffer/setup_packet will be mapped
1198 * Return value is either null (indicating no buffer could be mapped), or
1199 * the parameter. URB_NO_TRANSFER_DMA_MAP and URB_NO_SETUP_DMA_MAP are
1200 * added to urb->transfer_flags if the operation succeeds. If the device
1201 * is connected to this system through a non-DMA controller, this operation
1204 * This call would normally be used for an urb which is reused, perhaps
1205 * as the target of a large periodic transfer, with usb_buffer_dmasync()
1206 * calls to synchronize memory and dma state.
1208 * Reverse the effect of this call with usb_buffer_unmap().
1211 struct urb *usb_buffer_map (struct urb *urb)
1213 struct usb_bus *bus;
1214 struct device *controller;
1218 || !(bus = urb->dev->bus)
1219 || !(controller = bus->controller))
1222 if (controller->dma_mask) {
1223 urb->transfer_dma = dma_map_single (controller,
1224 urb->transfer_buffer, urb->transfer_buffer_length,
1225 usb_pipein (urb->pipe)
1226 ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
1227 if (usb_pipecontrol (urb->pipe))
1228 urb->setup_dma = dma_map_single (controller,
1230 sizeof (struct usb_ctrlrequest),
1232 // FIXME generic api broken like pci, can't report errors
1233 // if (urb->transfer_dma == DMA_ADDR_INVALID) return 0;
1235 urb->transfer_dma = ~0;
1236 urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP
1237 | URB_NO_SETUP_DMA_MAP);
1242 /* XXX DISABLED, no users currently. If you wish to re-enable this
1243 * XXX please determine whether the sync is to transfer ownership of
1244 * XXX the buffer from device to cpu or vice verse, and thusly use the
1245 * XXX appropriate _for_{cpu,device}() method. -DaveM
1250 * usb_buffer_dmasync - synchronize DMA and CPU view of buffer(s)
1251 * @urb: urb whose transfer_buffer/setup_packet will be synchronized
1253 void usb_buffer_dmasync (struct urb *urb)
1255 struct usb_bus *bus;
1256 struct device *controller;
1259 || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
1261 || !(bus = urb->dev->bus)
1262 || !(controller = bus->controller))
1265 if (controller->dma_mask) {
1266 dma_sync_single (controller,
1267 urb->transfer_dma, urb->transfer_buffer_length,
1268 usb_pipein (urb->pipe)
1269 ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
1270 if (usb_pipecontrol (urb->pipe))
1271 dma_sync_single (controller,
1273 sizeof (struct usb_ctrlrequest),
1280 * usb_buffer_unmap - free DMA mapping(s) for an urb
1281 * @urb: urb whose transfer_buffer will be unmapped
1283 * Reverses the effect of usb_buffer_map().
1286 void usb_buffer_unmap (struct urb *urb)
1288 struct usb_bus *bus;
1289 struct device *controller;
1292 || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
1294 || !(bus = urb->dev->bus)
1295 || !(controller = bus->controller))
1298 if (controller->dma_mask) {
1299 dma_unmap_single (controller,
1300 urb->transfer_dma, urb->transfer_buffer_length,
1301 usb_pipein (urb->pipe)
1302 ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
1303 if (usb_pipecontrol (urb->pipe))
1304 dma_unmap_single (controller,
1306 sizeof (struct usb_ctrlrequest),
1309 urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP
1310 | URB_NO_SETUP_DMA_MAP);
1315 * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint
1316 * @dev: device to which the scatterlist will be mapped
1317 * @pipe: endpoint defining the mapping direction
1318 * @sg: the scatterlist to map
1319 * @nents: the number of entries in the scatterlist
1321 * Return value is either < 0 (indicating no buffers could be mapped), or
1322 * the number of DMA mapping array entries in the scatterlist.
1324 * The caller is responsible for placing the resulting DMA addresses from
1325 * the scatterlist into URB transfer buffer pointers, and for setting the
1326 * URB_NO_TRANSFER_DMA_MAP transfer flag in each of those URBs.
1328 * Top I/O rates come from queuing URBs, instead of waiting for each one
1329 * to complete before starting the next I/O. This is particularly easy
1330 * to do with scatterlists. Just allocate and submit one URB for each DMA
1331 * mapping entry returned, stopping on the first error or when all succeed.
1332 * Better yet, use the usb_sg_*() calls, which do that (and more) for you.
1334 * This call would normally be used when translating scatterlist requests,
1335 * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it
1336 * may be able to coalesce mappings for improved I/O efficiency.
1338 * Reverse the effect of this call with usb_buffer_unmap_sg().
1340 int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
1341 struct scatterlist *sg, int nents)
1343 struct usb_bus *bus;
1344 struct device *controller;
1347 || usb_pipecontrol (pipe)
1348 || !(bus = dev->bus)
1349 || !(controller = bus->controller)
1350 || !controller->dma_mask)
1353 // FIXME generic api broken like pci, can't report errors
1354 return dma_map_sg (controller, sg, nents,
1355 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
1358 /* XXX DISABLED, no users currently. If you wish to re-enable this
1359 * XXX please determine whether the sync is to transfer ownership of
1360 * XXX the buffer from device to cpu or vice verse, and thusly use the
1361 * XXX appropriate _for_{cpu,device}() method. -DaveM
1366 * usb_buffer_dmasync_sg - synchronize DMA and CPU view of scatterlist buffer(s)
1367 * @dev: device to which the scatterlist will be mapped
1368 * @pipe: endpoint defining the mapping direction
1369 * @sg: the scatterlist to synchronize
1370 * @n_hw_ents: the positive return value from usb_buffer_map_sg
1372 * Use this when you are re-using a scatterlist's data buffers for
1373 * another USB request.
1375 void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
1376 struct scatterlist *sg, int n_hw_ents)
1378 struct usb_bus *bus;
1379 struct device *controller;
1382 || !(bus = dev->bus)
1383 || !(controller = bus->controller)
1384 || !controller->dma_mask)
1387 dma_sync_sg (controller, sg, n_hw_ents,
1388 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
1393 * usb_buffer_unmap_sg - free DMA mapping(s) for a scatterlist
1394 * @dev: device to which the scatterlist will be mapped
1395 * @pipe: endpoint defining the mapping direction
1396 * @sg: the scatterlist to unmap
1397 * @n_hw_ents: the positive return value from usb_buffer_map_sg
1399 * Reverses the effect of usb_buffer_map_sg().
1401 void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
1402 struct scatterlist *sg, int n_hw_ents)
1404 struct usb_bus *bus;
1405 struct device *controller;
1408 || !(bus = dev->bus)
1409 || !(controller = bus->controller)
1410 || !controller->dma_mask)
1413 dma_unmap_sg (controller, sg, n_hw_ents,
1414 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
1417 static int verify_suspended(struct device *dev, void *unused)
1419 return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0;
1422 static int usb_generic_suspend(struct device *dev, pm_message_t message)
1424 struct usb_interface *intf;
1425 struct usb_driver *driver;
1428 /* USB devices enter SUSPEND state through their hubs, but can be
1429 * marked for FREEZE as soon as their children are already idled.
1430 * But those semantics are useless, so we equate the two (sigh).
1432 if (dev->driver == &usb_generic_driver) {
1433 if (dev->power.power_state.event == message.event)
1435 /* we need to rule out bogus requests through sysfs */
1436 status = device_for_each_child(dev, NULL, verify_suspended);
1439 return usb_suspend_device (to_usb_device(dev));
1442 if ((dev->driver == NULL) ||
1443 (dev->driver_data == &usb_generic_driver_data))
1446 intf = to_usb_interface(dev);
1447 driver = to_usb_driver(dev->driver);
1449 /* with no hardware, USB interfaces only use FREEZE and ON states */
1450 if (!is_active(intf))
1453 if (driver->suspend && driver->resume) {
1454 status = driver->suspend(intf, message);
1456 dev_err(dev, "%s error %d\n", "suspend", status);
1458 mark_quiesced(intf);
1460 // FIXME else if there's no suspend method, disconnect...
1461 dev_warn(dev, "no %s?\n", "suspend");
1467 static int usb_generic_resume(struct device *dev)
1469 struct usb_interface *intf;
1470 struct usb_driver *driver;
1471 struct usb_device *udev;
1474 if (dev->power.power_state.event == PM_EVENT_ON)
1477 /* mark things as "on" immediately, no matter what errors crop up */
1478 dev->power.power_state.event = PM_EVENT_ON;
1480 /* devices resume through their hubs */
1481 if (dev->driver == &usb_generic_driver) {
1482 udev = to_usb_device(dev);
1483 if (udev->state == USB_STATE_NOTATTACHED)
1485 return usb_resume_device (to_usb_device(dev));
1488 if ((dev->driver == NULL) ||
1489 (dev->driver_data == &usb_generic_driver_data))
1492 intf = to_usb_interface(dev);
1493 driver = to_usb_driver(dev->driver);
1495 udev = interface_to_usbdev(intf);
1496 if (udev->state == USB_STATE_NOTATTACHED)
1499 /* if driver was suspended, it has a resume method;
1500 * however, sysfs can wrongly mark things as suspended
1501 * (on the "no suspend method" FIXME path above)
1503 if (driver->resume) {
1504 status = driver->resume(intf);
1506 dev_err(dev, "%s error %d\n", "resume", status);
1507 mark_quiesced(intf);
1510 dev_warn(dev, "no %s?\n", "resume");
1514 struct bus_type usb_bus_type = {
1516 .match = usb_device_match,
1517 .hotplug = usb_hotplug,
1518 .suspend = usb_generic_suspend,
1519 .resume = usb_generic_resume,
1524 static int __init usb_setup_disable(char *str)
1530 /* format to disable USB on kernel command line is: nousb */
1531 __setup("nousb", usb_setup_disable);
1536 * for external read access to <nousb>
1538 int usb_disabled(void)
1546 static int __init usb_init(void)
1550 pr_info ("%s: USB support disabled\n", usbcore_name);
1554 retval = bus_register(&usb_bus_type);
1557 retval = usb_host_init();
1559 goto host_init_failed;
1560 retval = usb_major_init();
1562 goto major_init_failed;
1563 retval = usb_register(&usbfs_driver);
1565 goto driver_register_failed;
1566 retval = usbdev_init();
1568 goto usbdevice_init_failed;
1569 retval = usbfs_init();
1571 goto fs_init_failed;
1572 retval = usb_hub_init();
1574 goto hub_init_failed;
1575 retval = driver_register(&usb_generic_driver);
1584 usbdevice_init_failed:
1585 usb_deregister(&usbfs_driver);
1586 driver_register_failed:
1587 usb_major_cleanup();
1591 bus_unregister(&usb_bus_type);
1599 static void __exit usb_exit(void)
1601 /* This will matter if shutdown/reboot does exitcalls. */
1605 driver_unregister(&usb_generic_driver);
1606 usb_major_cleanup();
1608 usb_deregister(&usbfs_driver);
1612 bus_unregister(&usb_bus_type);
1615 subsys_initcall(usb_init);
1616 module_exit(usb_exit);
1619 * USB may be built into the kernel or be built as modules.
1620 * These symbols are exported for device (or host controller)
1621 * driver modules to use.
1624 EXPORT_SYMBOL(usb_register);
1625 EXPORT_SYMBOL(usb_deregister);
1626 EXPORT_SYMBOL(usb_disabled);
1628 EXPORT_SYMBOL_GPL(usb_get_intf);
1629 EXPORT_SYMBOL_GPL(usb_put_intf);
1631 EXPORT_SYMBOL(usb_alloc_dev);
1632 EXPORT_SYMBOL(usb_put_dev);
1633 EXPORT_SYMBOL(usb_get_dev);
1634 EXPORT_SYMBOL(usb_hub_tt_clear_buffer);
1636 EXPORT_SYMBOL(usb_lock_device);
1637 EXPORT_SYMBOL(usb_trylock_device);
1638 EXPORT_SYMBOL(usb_lock_device_for_reset);
1639 EXPORT_SYMBOL(usb_unlock_device);
1641 EXPORT_SYMBOL(usb_driver_claim_interface);
1642 EXPORT_SYMBOL(usb_driver_release_interface);
1643 EXPORT_SYMBOL(usb_match_id);
1644 EXPORT_SYMBOL(usb_find_interface);
1645 EXPORT_SYMBOL(usb_ifnum_to_if);
1646 EXPORT_SYMBOL(usb_altnum_to_altsetting);
1648 EXPORT_SYMBOL(usb_reset_device);
1649 EXPORT_SYMBOL(usb_disconnect);
1651 EXPORT_SYMBOL(__usb_get_extra_descriptor);
1653 EXPORT_SYMBOL(usb_find_device);
1654 EXPORT_SYMBOL(usb_get_current_frame_number);
1656 EXPORT_SYMBOL (usb_buffer_alloc);
1657 EXPORT_SYMBOL (usb_buffer_free);
1660 EXPORT_SYMBOL (usb_buffer_map);
1661 EXPORT_SYMBOL (usb_buffer_dmasync);
1662 EXPORT_SYMBOL (usb_buffer_unmap);
1665 EXPORT_SYMBOL (usb_buffer_map_sg);
1667 EXPORT_SYMBOL (usb_buffer_dmasync_sg);
1669 EXPORT_SYMBOL (usb_buffer_unmap_sg);
1671 MODULE_LICENSE("GPL");