From: Nigel Cunningham <nigel@xxxxxxxxxxxxxxxxxx> Add power management related debugging into driver core. Make the kernel complain if a device driver lacks bus and class support for resume or if a PCI or USB driver does not have a driver specific resume function. Cc: Pavel Machek <pavel@xxxxxx> Cc: Rafael J. Wysocki <rjw@xxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxxxxxx> --- drivers/base/core.c | 13 +++++++++++++ drivers/pci/pci-driver.c | 6 ++++++ drivers/usb/core/driver.c | 6 ++++++ include/linux/device.h | 1 + 4 files changed, 26 insertions(+) Index: 2.6/drivers/base/core.c =================================================================== --- 2.6.orig/drivers/base/core.c 2007-04-27 14:42:13.000000000 +0300 +++ 2.6/drivers/base/core.c 2007-04-27 14:43:14.000000000 +0300 @@ -652,6 +652,18 @@ int device_add(struct device *dev) class_intf->add_dev(dev, class_intf); up(&dev->class->sem); } + +#ifdef CONFIG_PM + if (!((dev->class && dev->class->resume) || + (dev->bus && (dev->bus->resume || dev->bus->resume_early))) && + !dev->pm_safe) { + printk(KERN_WARNING "Device driver %s lacks bus and class " + "support for being resumed.\n", + kobject_name(&dev->kobj)); + dump_stack(); + } +#endif + Done: kfree(class_name); put_device(dev); @@ -989,6 +1001,7 @@ struct device *device_create(struct clas dev->class = class; dev->parent = parent; dev->release = device_create_release; + dev->pm_safe = 1; va_start(args, fmt); vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args); Index: 2.6/drivers/pci/pci-driver.c =================================================================== --- 2.6.orig/drivers/pci/pci-driver.c 2007-04-27 14:42:13.000000000 +0300 +++ 2.6/drivers/pci/pci-driver.c 2007-04-27 14:43:14.000000000 +0300 @@ -451,6 +451,12 @@ int __pci_register_driver(struct pci_dri if (error) driver_unregister(&drv->driver); +#ifdef CONFIG_PM + if (!drv->resume) + printk(KERN_WARNING "PCI driver %s lacks driver specific " + "resume support.\n", drv->name); +#endif + return error; } Index: 2.6/drivers/usb/core/driver.c =================================================================== --- 2.6.orig/drivers/usb/core/driver.c 2007-04-27 14:42:13.000000000 +0300 +++ 2.6/drivers/usb/core/driver.c 2007-04-27 14:43:14.000000000 +0300 @@ -721,6 +721,12 @@ int retval = 0; pr_info("%s: registered new device driver %s\n", usbcore_name, new_udriver->name); usbfs_update_special(); +#ifdef CONFIG_PM + if (!new_udriver->resume) + printk(KERN_WARNING "USB driver %s lacks driver " + "specific resume support.\n", + new_udriver->name); +#endif } else { printk(KERN_ERR "%s: error %d registering device " " driver %s\n", Index: 2.6/include/linux/device.h =================================================================== --- 2.6.orig/include/linux/device.h 2007-04-27 14:42:13.000000000 +0300 +++ 2.6/include/linux/device.h 2007-04-27 14:43:14.000000000 +0300 @@ -401,6 +401,7 @@ struct device { char bus_id[BUS_ID_SIZE]; /* position on parent bus */ struct device_type *type; unsigned is_registered:1; + unsigned pm_safe:1; /* no resume function is safe */ struct device_attribute uevent_attr; struct device_attribute *devt_attr; _______________________________________________ linux-pm mailing list linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/linux-pm