ChangeSet 1.1276.1.48, 2003/08/27 17:04:48-07:00, greg@kroah.com [PATCH] USB: hook up the USB driver core to the power management calls of the driver model. Now it's up to the individual USB drivers to implement suspend() and resume() if they want to. drivers/usb/core/usb.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/usb.h | 5 +++++ 2 files changed, 40 insertions(+) diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c --- a/drivers/usb/core/usb.c Tue Sep 2 12:43:35 2003 +++ b/drivers/usb/core/usb.c Tue Sep 2 12:43:35 2003 @@ -1417,11 +1417,46 @@ usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } +static int usb_device_suspend(struct device *dev, u32 state) +{ + struct usb_interface *intf; + struct usb_driver *driver; + + if ((dev->driver == &usb_generic_driver) || + (dev->driver_data == &usb_generic_driver_data)) + return 0; + + intf = to_usb_interface(dev); + driver = to_usb_driver(dev->driver); + + if (driver && driver->suspend) + return driver->suspend(intf, state); + return 0; +} + +static int usb_device_resume(struct device *dev) +{ + struct usb_interface *intf; + struct usb_driver *driver; + + if ((dev->driver == &usb_generic_driver) || + (dev->driver_data == &usb_generic_driver_data)) + return 0; + + intf = to_usb_interface(dev); + driver = to_usb_driver(dev->driver); + + if (driver && driver->resume) + return driver->resume(intf); + return 0; +} struct bus_type usb_bus_type = { .name = "usb", .match = usb_device_match, .hotplug = usb_hotplug, + .suspend = usb_device_suspend, + .resume = usb_device_resume, }; #ifndef MODULE diff -Nru a/include/linux/usb.h b/include/linux/usb.h --- a/include/linux/usb.h Tue Sep 2 12:43:35 2003 +++ b/include/linux/usb.h Tue Sep 2 12:43:35 2003 @@ -410,6 +410,8 @@ * the "usbfs" filesystem. This lets devices provide ways to * expose information to user space regardless of where they * do (or don't) show up otherwise in the filesystem. + * @suspend: Called when the device is going to be suspended by the system. + * @resume: Called when the device is being resumed by the system. * @id_table: USB drivers use ID table to support hotplugging. * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set * or your driver's probe function will never get called. @@ -444,6 +446,9 @@ void (*disconnect) (struct usb_interface *intf); int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf); + + int (*suspend) (struct usb_interface *intf, u32 state); + int (*resume) (struct usb_interface *intf); const struct usb_device_id *id_table;