Commit 19784c75 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[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.
parent cfdc3f3c
......@@ -1417,11 +1417,46 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
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
......
......@@ -410,6 +410,8 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
* 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.
......@@ -445,6 +447,9 @@ struct usb_driver {
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;
struct device_driver driver;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment