2 * drivers/usb/driver.c - most of the driver model stuff for usb
6 * based on drivers/usb/usb.c which had the following copyrights:
7 * (C) Copyright Linus Torvalds 1999
8 * (C) Copyright Johannes Erdfelt 1999-2001
9 * (C) Copyright Andreas Gal 1999
10 * (C) Copyright Gregory P. Smith 1999
11 * (C) Copyright Deti Fliegl 1999 (new USB architecture)
12 * (C) Copyright Randy Dunlap 2000
13 * (C) Copyright David Brownell 2000-2004
14 * (C) Copyright Yggdrasil Computing, Inc. 2000
15 * (usb_device_id matching changes by Adam J. Richter)
16 * (C) Copyright Greg Kroah-Hartman 2002-2003
18 * NOTE! This is not actually a driver at all, rather this is
19 * just a collection of helper routines that implement the
20 * matching, probing, releasing, suspending and resuming for
25 #include <linux/device.h>
26 #include <linux/usb.h>
30 static int usb_match_one_id(struct usb_interface *interface,
31 const struct usb_device_id *id);
34 struct list_head node;
35 struct usb_device_id id;
41 * Adds a new dynamic USBdevice ID to this driver,
42 * and cause the driver to probe for all devices again.
44 static ssize_t store_new_id(struct device_driver *driver,
45 const char *buf, size_t count)
47 struct usb_driver *usb_drv = to_usb_driver(driver);
48 struct usb_dynid *dynid;
53 fields = sscanf(buf, "%x %x", &idVendor, &idProduct);
57 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
61 INIT_LIST_HEAD(&dynid->node);
62 dynid->id.idVendor = idVendor;
63 dynid->id.idProduct = idProduct;
64 dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE;
66 spin_lock(&usb_drv->dynids.lock);
67 list_add_tail(&usb_drv->dynids.list, &dynid->node);
68 spin_unlock(&usb_drv->dynids.lock);
70 if (get_driver(driver)) {
71 driver_attach(driver);
77 static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
79 static int usb_create_newid_file(struct usb_driver *usb_drv)
83 if (usb_drv->no_dynamic_id)
86 if (usb_drv->probe != NULL)
87 error = sysfs_create_file(&usb_drv->drvwrap.driver.kobj,
88 &driver_attr_new_id.attr);
93 static void usb_remove_newid_file(struct usb_driver *usb_drv)
95 if (usb_drv->no_dynamic_id)
98 if (usb_drv->probe != NULL)
99 sysfs_remove_file(&usb_drv->drvwrap.driver.kobj,
100 &driver_attr_new_id.attr);
103 static void usb_free_dynids(struct usb_driver *usb_drv)
105 struct usb_dynid *dynid, *n;
107 spin_lock(&usb_drv->dynids.lock);
108 list_for_each_entry_safe(dynid, n, &usb_drv->dynids.list, node) {
109 list_del(&dynid->node);
112 spin_unlock(&usb_drv->dynids.lock);
115 static inline int usb_create_newid_file(struct usb_driver *usb_drv)
120 static void usb_remove_newid_file(struct usb_driver *usb_drv)
124 static inline void usb_free_dynids(struct usb_driver *usb_drv)
129 static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf,
130 struct usb_driver *drv)
132 struct usb_dynid *dynid;
134 spin_lock(&drv->dynids.lock);
135 list_for_each_entry(dynid, &drv->dynids.list, node) {
136 if (usb_match_one_id(intf, &dynid->id)) {
137 spin_unlock(&drv->dynids.lock);
141 spin_unlock(&drv->dynids.lock);
146 /* called from driver core with dev locked */
147 static int usb_probe_device(struct device *dev)
149 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
150 struct usb_device *udev;
153 dev_dbg(dev, "%s\n", __FUNCTION__);
155 if (!is_usb_device(dev)) /* Sanity check */
158 udev = to_usb_device(dev);
160 /* FIXME: resume a suspended device */
161 if (udev->state == USB_STATE_SUSPENDED)
162 return -EHOSTUNREACH;
164 /* TODO: Add real matching code */
166 error = udriver->probe(udev);
170 /* called from driver core with dev locked */
171 static int usb_unbind_device(struct device *dev)
173 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
175 udriver->disconnect(to_usb_device(dev));
180 /* called from driver core with dev locked */
181 static int usb_probe_interface(struct device *dev)
183 struct usb_driver *driver = to_usb_driver(dev->driver);
184 struct usb_interface *intf;
185 const struct usb_device_id *id;
188 dev_dbg(dev, "%s\n", __FUNCTION__);
190 if (is_usb_device(dev)) /* Sanity check */
193 intf = to_usb_interface(dev);
195 /* FIXME we'd much prefer to just resume it ... */
196 if (interface_to_usbdev(intf)->state == USB_STATE_SUSPENDED)
197 return -EHOSTUNREACH;
199 id = usb_match_id(intf, driver->id_table);
201 id = usb_match_dynamic_id(intf, driver);
203 dev_dbg(dev, "%s - got id\n", __FUNCTION__);
205 /* Interface "power state" doesn't correspond to any hardware
206 * state whatsoever. We use it to record when it's bound to
207 * a driver that may start I/0: it's not frozen/quiesced.
210 intf->condition = USB_INTERFACE_BINDING;
211 error = driver->probe(intf, id);
214 intf->condition = USB_INTERFACE_UNBOUND;
216 intf->condition = USB_INTERFACE_BOUND;
222 /* called from driver core with dev locked */
223 static int usb_unbind_interface(struct device *dev)
225 struct usb_driver *driver = to_usb_driver(dev->driver);
226 struct usb_interface *intf = to_usb_interface(dev);
228 intf->condition = USB_INTERFACE_UNBINDING;
230 /* release all urbs for this interface */
231 usb_disable_interface(interface_to_usbdev(intf), intf);
233 driver->disconnect(intf);
235 /* reset other interface state */
236 usb_set_interface(interface_to_usbdev(intf),
237 intf->altsetting[0].desc.bInterfaceNumber,
239 usb_set_intfdata(intf, NULL);
240 intf->condition = USB_INTERFACE_UNBOUND;
247 * usb_driver_claim_interface - bind a driver to an interface
248 * @driver: the driver to be bound
249 * @iface: the interface to which it will be bound; must be in the
250 * usb device's active configuration
251 * @priv: driver data associated with that interface
253 * This is used by usb device drivers that need to claim more than one
254 * interface on a device when probing (audio and acm are current examples).
255 * No device driver should directly modify internal usb_interface or
256 * usb_device structure members.
258 * Few drivers should need to use this routine, since the most natural
259 * way to bind to an interface is to return the private data from
260 * the driver's probe() method.
262 * Callers must own the device lock and the driver model's usb_bus_type.subsys
263 * writelock. So driver probe() entries don't need extra locking,
264 * but other call contexts may need to explicitly claim those locks.
266 int usb_driver_claim_interface(struct usb_driver *driver,
267 struct usb_interface *iface, void* priv)
269 struct device *dev = &iface->dev;
274 dev->driver = &driver->drvwrap.driver;
275 usb_set_intfdata(iface, priv);
276 iface->condition = USB_INTERFACE_BOUND;
279 /* if interface was already added, bind now; else let
280 * the future device_add() bind it, bypassing probe()
282 if (device_is_registered(dev))
283 device_bind_driver(dev);
287 EXPORT_SYMBOL(usb_driver_claim_interface);
290 * usb_driver_release_interface - unbind a driver from an interface
291 * @driver: the driver to be unbound
292 * @iface: the interface from which it will be unbound
294 * This can be used by drivers to release an interface without waiting
295 * for their disconnect() methods to be called. In typical cases this
296 * also causes the driver disconnect() method to be called.
298 * This call is synchronous, and may not be used in an interrupt context.
299 * Callers must own the device lock and the driver model's usb_bus_type.subsys
300 * writelock. So driver disconnect() entries don't need extra locking,
301 * but other call contexts may need to explicitly claim those locks.
303 void usb_driver_release_interface(struct usb_driver *driver,
304 struct usb_interface *iface)
306 struct device *dev = &iface->dev;
308 /* this should never happen, don't release something that's not ours */
309 if (!dev->driver || dev->driver != &driver->drvwrap.driver)
312 /* don't release from within disconnect() */
313 if (iface->condition != USB_INTERFACE_BOUND)
316 /* don't release if the interface hasn't been added yet */
317 if (device_is_registered(dev)) {
318 iface->condition = USB_INTERFACE_UNBINDING;
319 device_release_driver(dev);
323 usb_set_intfdata(iface, NULL);
324 iface->condition = USB_INTERFACE_UNBOUND;
325 mark_quiesced(iface);
327 EXPORT_SYMBOL(usb_driver_release_interface);
329 /* returns 0 if no match, 1 if match */
330 static int usb_match_one_id(struct usb_interface *interface,
331 const struct usb_device_id *id)
333 struct usb_host_interface *intf;
334 struct usb_device *dev;
336 /* proc_connectinfo in devio.c may call us with id == NULL. */
340 intf = interface->cur_altsetting;
341 dev = interface_to_usbdev(interface);
343 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
344 id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
347 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
348 id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
351 /* No need to test id->bcdDevice_lo != 0, since 0 is never
352 greater than any unsigned number. */
353 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
354 (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
357 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
358 (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
361 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
362 (id->bDeviceClass != dev->descriptor.bDeviceClass))
365 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
366 (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass))
369 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
370 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
373 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
374 (id->bInterfaceClass != intf->desc.bInterfaceClass))
377 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&
378 (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass))
381 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&
382 (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol))
388 * usb_match_id - find first usb_device_id matching device or interface
389 * @interface: the interface of interest
390 * @id: array of usb_device_id structures, terminated by zero entry
392 * usb_match_id searches an array of usb_device_id's and returns
393 * the first one matching the device or interface, or null.
394 * This is used when binding (or rebinding) a driver to an interface.
395 * Most USB device drivers will use this indirectly, through the usb core,
396 * but some layered driver frameworks use it directly.
397 * These device tables are exported with MODULE_DEVICE_TABLE, through
398 * modutils, to support the driver loading functionality of USB hotplugging.
402 * The "match_flags" element in a usb_device_id controls which
403 * members are used. If the corresponding bit is set, the
404 * value in the device_id must match its corresponding member
405 * in the device or interface descriptor, or else the device_id
408 * "driver_info" is normally used only by device drivers,
409 * but you can create a wildcard "matches anything" usb_device_id
410 * as a driver's "modules.usbmap" entry if you provide an id with
411 * only a nonzero "driver_info" field. If you do this, the USB device
412 * driver's probe() routine should use additional intelligence to
413 * decide whether to bind to the specified interface.
415 * What Makes Good usb_device_id Tables:
417 * The match algorithm is very simple, so that intelligence in
418 * driver selection must come from smart driver id records.
419 * Unless you have good reasons to use another selection policy,
420 * provide match elements only in related groups, and order match
421 * specifiers from specific to general. Use the macros provided
422 * for that purpose if you can.
424 * The most specific match specifiers use device descriptor
425 * data. These are commonly used with product-specific matches;
426 * the USB_DEVICE macro lets you provide vendor and product IDs,
427 * and you can also match against ranges of product revisions.
428 * These are widely used for devices with application or vendor
429 * specific bDeviceClass values.
431 * Matches based on device class/subclass/protocol specifications
432 * are slightly more general; use the USB_DEVICE_INFO macro, or
433 * its siblings. These are used with single-function devices
434 * where bDeviceClass doesn't specify that each interface has
437 * Matches based on interface class/subclass/protocol are the
438 * most general; they let drivers bind to any interface on a
439 * multiple-function device. Use the USB_INTERFACE_INFO
440 * macro, or its siblings, to match class-per-interface style
441 * devices (as recorded in bDeviceClass).
443 * Within those groups, remember that not all combinations are
444 * meaningful. For example, don't give a product version range
445 * without vendor and product IDs; or specify a protocol without
446 * its associated class and subclass.
448 const struct usb_device_id *usb_match_id(struct usb_interface *interface,
449 const struct usb_device_id *id)
451 /* proc_connectinfo in devio.c may call us with id == NULL. */
455 /* It is important to check that id->driver_info is nonzero,
456 since an entry that is all zeroes except for a nonzero
457 id->driver_info is the way to create an entry that
458 indicates that the driver want to examine every
459 device and interface. */
460 for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass ||
461 id->driver_info; id++) {
462 if (usb_match_one_id(interface, id))
468 EXPORT_SYMBOL_GPL_FUTURE(usb_match_id);
470 int usb_device_match(struct device *dev, struct device_driver *drv)
472 /* devices and interfaces are handled separately */
473 if (is_usb_device(dev)) {
475 /* interface drivers never match devices */
476 if (!is_usb_device_driver(drv))
479 /* TODO: Add real matching code */
483 struct usb_interface *intf;
484 struct usb_driver *usb_drv;
485 const struct usb_device_id *id;
487 /* device drivers never match interfaces */
488 if (is_usb_device_driver(drv))
491 intf = to_usb_interface(dev);
492 usb_drv = to_usb_driver(drv);
494 id = usb_match_id(intf, usb_drv->id_table);
498 id = usb_match_dynamic_id(intf, usb_drv);
506 #ifdef CONFIG_HOTPLUG
509 * This sends an uevent to userspace, typically helping to load driver
510 * or other modules, configure the device, and more. Drivers can provide
511 * a MODULE_DEVICE_TABLE to help with module loading subtasks.
513 * We're called either from khubd (the typical case) or from root hub
514 * (init, kapmd, modprobe, rmmod, etc), but the agents need to handle
515 * delays in event delivery. Use sysfs (and DEVPATH) to make sure the
516 * device (and this configuration!) are still present.
518 static int usb_uevent(struct device *dev, char **envp, int num_envp,
519 char *buffer, int buffer_size)
521 struct usb_interface *intf;
522 struct usb_device *usb_dev;
523 struct usb_host_interface *alt;
530 /* driver is often null here; dev_dbg() would oops */
531 pr_debug ("usb %s: uevent\n", dev->bus_id);
533 if (is_usb_device(dev))
536 intf = to_usb_interface(dev);
537 usb_dev = interface_to_usbdev(intf);
538 alt = intf->cur_altsetting;
541 if (usb_dev->devnum < 0) {
542 pr_debug ("usb %s: already deleted?\n", dev->bus_id);
546 pr_debug ("usb %s: bus removed?\n", dev->bus_id);
550 #ifdef CONFIG_USB_DEVICEFS
551 /* If this is available, userspace programs can directly read
552 * all the device descriptors we don't tell them about. Or
553 * even act as usermode drivers.
555 * FIXME reduce hardwired intelligence here
557 if (add_uevent_var(envp, num_envp, &i,
558 buffer, buffer_size, &length,
559 "DEVICE=/proc/bus/usb/%03d/%03d",
560 usb_dev->bus->busnum, usb_dev->devnum))
564 /* per-device configurations are common */
565 if (add_uevent_var(envp, num_envp, &i,
566 buffer, buffer_size, &length,
568 le16_to_cpu(usb_dev->descriptor.idVendor),
569 le16_to_cpu(usb_dev->descriptor.idProduct),
570 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
573 /* class-based driver binding models */
574 if (add_uevent_var(envp, num_envp, &i,
575 buffer, buffer_size, &length,
577 usb_dev->descriptor.bDeviceClass,
578 usb_dev->descriptor.bDeviceSubClass,
579 usb_dev->descriptor.bDeviceProtocol))
582 if (add_uevent_var(envp, num_envp, &i,
583 buffer, buffer_size, &length,
584 "INTERFACE=%d/%d/%d",
585 alt->desc.bInterfaceClass,
586 alt->desc.bInterfaceSubClass,
587 alt->desc.bInterfaceProtocol))
590 if (add_uevent_var(envp, num_envp, &i,
591 buffer, buffer_size, &length,
592 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
593 le16_to_cpu(usb_dev->descriptor.idVendor),
594 le16_to_cpu(usb_dev->descriptor.idProduct),
595 le16_to_cpu(usb_dev->descriptor.bcdDevice),
596 usb_dev->descriptor.bDeviceClass,
597 usb_dev->descriptor.bDeviceSubClass,
598 usb_dev->descriptor.bDeviceProtocol,
599 alt->desc.bInterfaceClass,
600 alt->desc.bInterfaceSubClass,
601 alt->desc.bInterfaceProtocol))
611 static int usb_uevent(struct device *dev, char **envp,
612 int num_envp, char *buffer, int buffer_size)
617 #endif /* CONFIG_HOTPLUG */
620 * usb_register_device_driver - register a USB device (not interface) driver
621 * @new_udriver: USB operations for the device driver
622 * @owner: module owner of this driver.
624 * Registers a USB device driver with the USB core. The list of
625 * unattached devices will be rescanned whenever a new driver is
626 * added, allowing the new driver to attach to any recognized devices.
627 * Returns a negative error code on failure and 0 on success.
629 int usb_register_device_driver(struct usb_device_driver *new_udriver,
630 struct module *owner)
637 new_udriver->drvwrap.for_devices = 1;
638 new_udriver->drvwrap.driver.name = (char *) new_udriver->name;
639 new_udriver->drvwrap.driver.bus = &usb_bus_type;
640 new_udriver->drvwrap.driver.probe = usb_probe_device;
641 new_udriver->drvwrap.driver.remove = usb_unbind_device;
642 new_udriver->drvwrap.driver.owner = owner;
644 retval = driver_register(&new_udriver->drvwrap.driver);
647 pr_info("%s: registered new device driver %s\n",
648 usbcore_name, new_udriver->name);
649 usbfs_update_special();
651 printk(KERN_ERR "%s: error %d registering device "
653 usbcore_name, retval, new_udriver->name);
658 EXPORT_SYMBOL_GPL(usb_register_device_driver);
661 * usb_deregister_device_driver - unregister a USB device (not interface) driver
662 * @udriver: USB operations of the device driver to unregister
663 * Context: must be able to sleep
665 * Unlinks the specified driver from the internal USB driver list.
667 void usb_deregister_device_driver(struct usb_device_driver *udriver)
669 pr_info("%s: deregistering device driver %s\n",
670 usbcore_name, udriver->name);
672 driver_unregister(&udriver->drvwrap.driver);
673 usbfs_update_special();
675 EXPORT_SYMBOL_GPL(usb_deregister_device_driver);
678 * usb_register_driver - register a USB interface driver
679 * @new_driver: USB operations for the interface driver
680 * @owner: module owner of this driver.
682 * Registers a USB interface driver with the USB core. The list of
683 * unattached interfaces will be rescanned whenever a new driver is
684 * added, allowing the new driver to attach to any recognized interfaces.
685 * Returns a negative error code on failure and 0 on success.
687 * NOTE: if you want your driver to use the USB major number, you must call
688 * usb_register_dev() to enable that functionality. This function no longer
689 * takes care of that.
691 int usb_register_driver(struct usb_driver *new_driver, struct module *owner)
698 new_driver->drvwrap.for_devices = 0;
699 new_driver->drvwrap.driver.name = (char *) new_driver->name;
700 new_driver->drvwrap.driver.bus = &usb_bus_type;
701 new_driver->drvwrap.driver.probe = usb_probe_interface;
702 new_driver->drvwrap.driver.remove = usb_unbind_interface;
703 new_driver->drvwrap.driver.owner = owner;
704 spin_lock_init(&new_driver->dynids.lock);
705 INIT_LIST_HEAD(&new_driver->dynids.list);
707 retval = driver_register(&new_driver->drvwrap.driver);
710 pr_info("%s: registered new interface driver %s\n",
711 usbcore_name, new_driver->name);
712 usbfs_update_special();
713 usb_create_newid_file(new_driver);
715 printk(KERN_ERR "%s: error %d registering interface "
717 usbcore_name, retval, new_driver->name);
722 EXPORT_SYMBOL_GPL_FUTURE(usb_register_driver);
725 * usb_deregister - unregister a USB interface driver
726 * @driver: USB operations of the interface driver to unregister
727 * Context: must be able to sleep
729 * Unlinks the specified driver from the internal USB driver list.
731 * NOTE: If you called usb_register_dev(), you still need to call
732 * usb_deregister_dev() to clean up your driver's allocated minor numbers,
733 * this * call will no longer do it for you.
735 void usb_deregister(struct usb_driver *driver)
737 pr_info("%s: deregistering interface driver %s\n",
738 usbcore_name, driver->name);
740 usb_remove_newid_file(driver);
741 usb_free_dynids(driver);
742 driver_unregister(&driver->drvwrap.driver);
744 usbfs_update_special();
746 EXPORT_SYMBOL_GPL_FUTURE(usb_deregister);
750 static int verify_suspended(struct device *dev, void *unused)
752 if (dev->driver == NULL)
754 return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0;
757 static int usb_generic_suspend(struct device *dev, pm_message_t message)
759 struct usb_interface *intf;
760 struct usb_driver *driver;
763 /* USB devices enter SUSPEND state through their hubs, but can be
764 * marked for FREEZE as soon as their children are already idled.
765 * But those semantics are useless, so we equate the two (sigh).
767 if (is_usb_device(dev)) {
768 if (dev->power.power_state.event == message.event)
770 /* we need to rule out bogus requests through sysfs */
771 status = device_for_each_child(dev, NULL, verify_suspended);
774 return usb_port_suspend(to_usb_device(dev));
777 if (dev->driver == NULL)
780 intf = to_usb_interface(dev);
781 driver = to_usb_driver(dev->driver);
783 /* with no hardware, USB interfaces only use FREEZE and ON states */
784 if (!is_active(intf))
787 if (driver->suspend && driver->resume) {
788 status = driver->suspend(intf, message);
790 dev_err(dev, "%s error %d\n", "suspend", status);
794 // FIXME else if there's no suspend method, disconnect...
795 dev_warn(dev, "no suspend for driver %s?\n", driver->name);
802 static int usb_generic_resume(struct device *dev)
804 struct usb_interface *intf;
805 struct usb_driver *driver;
806 struct usb_device *udev;
809 if (dev->power.power_state.event == PM_EVENT_ON)
812 /* mark things as "on" immediately, no matter what errors crop up */
813 dev->power.power_state.event = PM_EVENT_ON;
815 /* devices resume through their hubs */
816 if (is_usb_device(dev)) {
817 udev = to_usb_device(dev);
818 if (udev->state == USB_STATE_NOTATTACHED)
820 return usb_port_resume(udev);
823 if (dev->driver == NULL) {
824 dev->power.power_state.event = PM_EVENT_FREEZE;
828 intf = to_usb_interface(dev);
829 driver = to_usb_driver(dev->driver);
831 udev = interface_to_usbdev(intf);
832 if (udev->state == USB_STATE_NOTATTACHED)
835 /* if driver was suspended, it has a resume method;
836 * however, sysfs can wrongly mark things as suspended
837 * (on the "no suspend method" FIXME path above)
839 if (driver->resume) {
840 status = driver->resume(intf);
842 dev_err(dev, "%s error %d\n", "resume", status);
846 dev_warn(dev, "no resume for driver %s?\n", driver->name);
850 #endif /* CONFIG_PM */
852 struct bus_type usb_bus_type = {
854 .match = usb_device_match,
855 .uevent = usb_uevent,
857 .suspend = usb_generic_suspend,
858 .resume = usb_generic_resume,