Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: debugfs: fix sparse warnings Driver core: Fix cleanup when failing device_add(). driver core: Remove dpm_sysfs_remove() from error path of device_add() PM: fix new mutex-locking bug in the PM core PM: Do not acquire device semaphores upfront during suspend kobject: properly initialize ksets sysfs: CONFIG_SYSFS_DEPRECATED fix driver core: fix up Kconfig text for CONFIG_SYSFS_DEPRECATED
This commit is contained in:
@@ -621,7 +621,8 @@ static struct kobject *get_device_parent(struct device *dev,
|
|||||||
static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
|
static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
|
||||||
{
|
{
|
||||||
/* see if we live in a "glue" directory */
|
/* see if we live in a "glue" directory */
|
||||||
if (!dev->class || glue_dir->kset != &dev->class->class_dirs)
|
if (!glue_dir || !dev->class ||
|
||||||
|
glue_dir->kset != &dev->class->class_dirs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
kobject_put(glue_dir);
|
kobject_put(glue_dir);
|
||||||
@@ -770,17 +771,10 @@ int device_add(struct device *dev)
|
|||||||
struct class_interface *class_intf;
|
struct class_interface *class_intf;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = pm_sleep_lock();
|
|
||||||
if (error) {
|
|
||||||
dev_warn(dev, "Suspicious %s during suspend\n", __FUNCTION__);
|
|
||||||
dump_stack();
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev = get_device(dev);
|
dev = get_device(dev);
|
||||||
if (!dev || !strlen(dev->bus_id)) {
|
if (!dev || !strlen(dev->bus_id)) {
|
||||||
error = -EINVAL;
|
error = -EINVAL;
|
||||||
goto Error;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__);
|
pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__);
|
||||||
@@ -843,11 +837,9 @@ int device_add(struct device *dev)
|
|||||||
}
|
}
|
||||||
Done:
|
Done:
|
||||||
put_device(dev);
|
put_device(dev);
|
||||||
pm_sleep_unlock();
|
|
||||||
return error;
|
return error;
|
||||||
BusError:
|
BusError:
|
||||||
device_pm_remove(dev);
|
device_pm_remove(dev);
|
||||||
dpm_sysfs_remove(dev);
|
|
||||||
PMError:
|
PMError:
|
||||||
if (dev->bus)
|
if (dev->bus)
|
||||||
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
|
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
|
||||||
|
@@ -48,7 +48,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LIST_HEAD(dpm_active);
|
LIST_HEAD(dpm_active);
|
||||||
static LIST_HEAD(dpm_locked);
|
|
||||||
static LIST_HEAD(dpm_off);
|
static LIST_HEAD(dpm_off);
|
||||||
static LIST_HEAD(dpm_off_irq);
|
static LIST_HEAD(dpm_off_irq);
|
||||||
static LIST_HEAD(dpm_destroy);
|
static LIST_HEAD(dpm_destroy);
|
||||||
@@ -81,28 +80,6 @@ void device_pm_add(struct device *dev)
|
|||||||
*/
|
*/
|
||||||
void device_pm_remove(struct device *dev)
|
void device_pm_remove(struct device *dev)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* If this function is called during a suspend, it will be blocked,
|
|
||||||
* because we're holding the device's semaphore at that time, which may
|
|
||||||
* lead to a deadlock. In that case we want to print a warning.
|
|
||||||
* However, it may also be called by unregister_dropped_devices() with
|
|
||||||
* the device's semaphore released, in which case the warning should
|
|
||||||
* not be printed.
|
|
||||||
*/
|
|
||||||
if (down_trylock(&dev->sem)) {
|
|
||||||
if (down_read_trylock(&pm_sleep_rwsem)) {
|
|
||||||
/* No suspend in progress, wait on dev->sem */
|
|
||||||
down(&dev->sem);
|
|
||||||
up_read(&pm_sleep_rwsem);
|
|
||||||
} else {
|
|
||||||
/* Suspend in progress, we may deadlock */
|
|
||||||
dev_warn(dev, "Suspicious %s during suspend\n",
|
|
||||||
__FUNCTION__);
|
|
||||||
dump_stack();
|
|
||||||
/* The user has been warned ... */
|
|
||||||
down(&dev->sem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pr_debug("PM: Removing info for %s:%s\n",
|
pr_debug("PM: Removing info for %s:%s\n",
|
||||||
dev->bus ? dev->bus->name : "No Bus",
|
dev->bus ? dev->bus->name : "No Bus",
|
||||||
kobject_name(&dev->kobj));
|
kobject_name(&dev->kobj));
|
||||||
@@ -110,7 +87,6 @@ void device_pm_remove(struct device *dev)
|
|||||||
dpm_sysfs_remove(dev);
|
dpm_sysfs_remove(dev);
|
||||||
list_del_init(&dev->power.entry);
|
list_del_init(&dev->power.entry);
|
||||||
mutex_unlock(&dpm_list_mtx);
|
mutex_unlock(&dpm_list_mtx);
|
||||||
up(&dev->sem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,6 +206,8 @@ static int resume_device(struct device *dev)
|
|||||||
TRACE_DEVICE(dev);
|
TRACE_DEVICE(dev);
|
||||||
TRACE_RESUME(0);
|
TRACE_RESUME(0);
|
||||||
|
|
||||||
|
down(&dev->sem);
|
||||||
|
|
||||||
if (dev->bus && dev->bus->resume) {
|
if (dev->bus && dev->bus->resume) {
|
||||||
dev_dbg(dev,"resuming\n");
|
dev_dbg(dev,"resuming\n");
|
||||||
error = dev->bus->resume(dev);
|
error = dev->bus->resume(dev);
|
||||||
@@ -245,6 +223,8 @@ static int resume_device(struct device *dev)
|
|||||||
error = dev->class->resume(dev);
|
error = dev->class->resume(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
up(&dev->sem);
|
||||||
|
|
||||||
TRACE_RESUME(error);
|
TRACE_RESUME(error);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -266,7 +246,7 @@ static void dpm_resume(void)
|
|||||||
struct list_head *entry = dpm_off.next;
|
struct list_head *entry = dpm_off.next;
|
||||||
struct device *dev = to_device(entry);
|
struct device *dev = to_device(entry);
|
||||||
|
|
||||||
list_move_tail(entry, &dpm_locked);
|
list_move_tail(entry, &dpm_active);
|
||||||
mutex_unlock(&dpm_list_mtx);
|
mutex_unlock(&dpm_list_mtx);
|
||||||
resume_device(dev);
|
resume_device(dev);
|
||||||
mutex_lock(&dpm_list_mtx);
|
mutex_lock(&dpm_list_mtx);
|
||||||
@@ -274,25 +254,6 @@ static void dpm_resume(void)
|
|||||||
mutex_unlock(&dpm_list_mtx);
|
mutex_unlock(&dpm_list_mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* unlock_all_devices - Release each device's semaphore
|
|
||||||
*
|
|
||||||
* Go through the dpm_off list. Put each device on the dpm_active
|
|
||||||
* list and unlock it.
|
|
||||||
*/
|
|
||||||
static void unlock_all_devices(void)
|
|
||||||
{
|
|
||||||
mutex_lock(&dpm_list_mtx);
|
|
||||||
while (!list_empty(&dpm_locked)) {
|
|
||||||
struct list_head *entry = dpm_locked.prev;
|
|
||||||
struct device *dev = to_device(entry);
|
|
||||||
|
|
||||||
list_move(entry, &dpm_active);
|
|
||||||
up(&dev->sem);
|
|
||||||
}
|
|
||||||
mutex_unlock(&dpm_list_mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unregister_dropped_devices - Unregister devices scheduled for removal
|
* unregister_dropped_devices - Unregister devices scheduled for removal
|
||||||
*
|
*
|
||||||
@@ -305,7 +266,6 @@ static void unregister_dropped_devices(void)
|
|||||||
struct list_head *entry = dpm_destroy.next;
|
struct list_head *entry = dpm_destroy.next;
|
||||||
struct device *dev = to_device(entry);
|
struct device *dev = to_device(entry);
|
||||||
|
|
||||||
up(&dev->sem);
|
|
||||||
mutex_unlock(&dpm_list_mtx);
|
mutex_unlock(&dpm_list_mtx);
|
||||||
/* This also removes the device from the list */
|
/* This also removes the device from the list */
|
||||||
device_unregister(dev);
|
device_unregister(dev);
|
||||||
@@ -324,7 +284,6 @@ void device_resume(void)
|
|||||||
{
|
{
|
||||||
might_sleep();
|
might_sleep();
|
||||||
dpm_resume();
|
dpm_resume();
|
||||||
unlock_all_devices();
|
|
||||||
unregister_dropped_devices();
|
unregister_dropped_devices();
|
||||||
up_write(&pm_sleep_rwsem);
|
up_write(&pm_sleep_rwsem);
|
||||||
}
|
}
|
||||||
@@ -388,18 +347,15 @@ int device_power_down(pm_message_t state)
|
|||||||
struct list_head *entry = dpm_off.prev;
|
struct list_head *entry = dpm_off.prev;
|
||||||
struct device *dev = to_device(entry);
|
struct device *dev = to_device(entry);
|
||||||
|
|
||||||
list_del_init(&dev->power.entry);
|
|
||||||
error = suspend_device_late(dev, state);
|
error = suspend_device_late(dev, state);
|
||||||
if (error) {
|
if (error) {
|
||||||
printk(KERN_ERR "Could not power down device %s: "
|
printk(KERN_ERR "Could not power down device %s: "
|
||||||
"error %d\n",
|
"error %d\n",
|
||||||
kobject_name(&dev->kobj), error);
|
kobject_name(&dev->kobj), error);
|
||||||
if (list_empty(&dev->power.entry))
|
|
||||||
list_add(&dev->power.entry, &dpm_off);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (list_empty(&dev->power.entry))
|
if (!list_empty(&dev->power.entry))
|
||||||
list_add(&dev->power.entry, &dpm_off_irq);
|
list_move(&dev->power.entry, &dpm_off_irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error)
|
if (!error)
|
||||||
@@ -419,6 +375,8 @@ static int suspend_device(struct device *dev, pm_message_t state)
|
|||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
|
down(&dev->sem);
|
||||||
|
|
||||||
if (dev->power.power_state.event) {
|
if (dev->power.power_state.event) {
|
||||||
dev_dbg(dev, "PM: suspend %d-->%d\n",
|
dev_dbg(dev, "PM: suspend %d-->%d\n",
|
||||||
dev->power.power_state.event, state.event);
|
dev->power.power_state.event, state.event);
|
||||||
@@ -441,6 +399,9 @@ static int suspend_device(struct device *dev, pm_message_t state)
|
|||||||
error = dev->bus->suspend(dev, state);
|
error = dev->bus->suspend(dev, state);
|
||||||
suspend_report_result(dev->bus->suspend, error);
|
suspend_report_result(dev->bus->suspend, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
up(&dev->sem);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,13 +422,13 @@ static int dpm_suspend(pm_message_t state)
|
|||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
mutex_lock(&dpm_list_mtx);
|
mutex_lock(&dpm_list_mtx);
|
||||||
while (!list_empty(&dpm_locked)) {
|
while (!list_empty(&dpm_active)) {
|
||||||
struct list_head *entry = dpm_locked.prev;
|
struct list_head *entry = dpm_active.prev;
|
||||||
struct device *dev = to_device(entry);
|
struct device *dev = to_device(entry);
|
||||||
|
|
||||||
list_del_init(&dev->power.entry);
|
|
||||||
mutex_unlock(&dpm_list_mtx);
|
mutex_unlock(&dpm_list_mtx);
|
||||||
error = suspend_device(dev, state);
|
error = suspend_device(dev, state);
|
||||||
|
mutex_lock(&dpm_list_mtx);
|
||||||
if (error) {
|
if (error) {
|
||||||
printk(KERN_ERR "Could not suspend device %s: "
|
printk(KERN_ERR "Could not suspend device %s: "
|
||||||
"error %d%s\n",
|
"error %d%s\n",
|
||||||
@@ -476,50 +437,16 @@ static int dpm_suspend(pm_message_t state)
|
|||||||
(error == -EAGAIN ?
|
(error == -EAGAIN ?
|
||||||
" (please convert to suspend_late)" :
|
" (please convert to suspend_late)" :
|
||||||
""));
|
""));
|
||||||
mutex_lock(&dpm_list_mtx);
|
|
||||||
if (list_empty(&dev->power.entry))
|
|
||||||
list_add(&dev->power.entry, &dpm_locked);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mutex_lock(&dpm_list_mtx);
|
if (!list_empty(&dev->power.entry))
|
||||||
if (list_empty(&dev->power.entry))
|
list_move(&dev->power.entry, &dpm_off);
|
||||||
list_add(&dev->power.entry, &dpm_off);
|
|
||||||
}
|
}
|
||||||
mutex_unlock(&dpm_list_mtx);
|
mutex_unlock(&dpm_list_mtx);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* lock_all_devices - Acquire every device's semaphore
|
|
||||||
*
|
|
||||||
* Go through the dpm_active list. Carefully lock each device's
|
|
||||||
* semaphore and put it in on the dpm_locked list.
|
|
||||||
*/
|
|
||||||
static void lock_all_devices(void)
|
|
||||||
{
|
|
||||||
mutex_lock(&dpm_list_mtx);
|
|
||||||
while (!list_empty(&dpm_active)) {
|
|
||||||
struct list_head *entry = dpm_active.next;
|
|
||||||
struct device *dev = to_device(entry);
|
|
||||||
|
|
||||||
/* Required locking order is dev->sem first,
|
|
||||||
* then dpm_list_mutex. Hence this awkward code.
|
|
||||||
*/
|
|
||||||
get_device(dev);
|
|
||||||
mutex_unlock(&dpm_list_mtx);
|
|
||||||
down(&dev->sem);
|
|
||||||
mutex_lock(&dpm_list_mtx);
|
|
||||||
|
|
||||||
if (list_empty(entry))
|
|
||||||
up(&dev->sem); /* Device was removed */
|
|
||||||
else
|
|
||||||
list_move_tail(entry, &dpm_locked);
|
|
||||||
put_device(dev);
|
|
||||||
}
|
|
||||||
mutex_unlock(&dpm_list_mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* device_suspend - Save state and stop all devices in system.
|
* device_suspend - Save state and stop all devices in system.
|
||||||
* @state: new power management state
|
* @state: new power management state
|
||||||
@@ -533,7 +460,6 @@ int device_suspend(pm_message_t state)
|
|||||||
|
|
||||||
might_sleep();
|
might_sleep();
|
||||||
down_write(&pm_sleep_rwsem);
|
down_write(&pm_sleep_rwsem);
|
||||||
lock_all_devices();
|
|
||||||
error = dpm_suspend(state);
|
error = dpm_suspend(state);
|
||||||
if (error)
|
if (error)
|
||||||
device_resume();
|
device_resume();
|
||||||
|
@@ -233,7 +233,7 @@ static int ksuspend_usb_init(void)
|
|||||||
* singlethreaded. Its job doesn't justify running on more
|
* singlethreaded. Its job doesn't justify running on more
|
||||||
* than one CPU.
|
* than one CPU.
|
||||||
*/
|
*/
|
||||||
ksuspend_usb_wq = create_singlethread_workqueue("ksuspend_usbd");
|
ksuspend_usb_wq = create_freezeable_workqueue("ksuspend_usbd");
|
||||||
if (!ksuspend_usb_wq)
|
if (!ksuspend_usb_wq)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -29,10 +29,6 @@
|
|||||||
|
|
||||||
#define DEBUGFS_MAGIC 0x64626720
|
#define DEBUGFS_MAGIC 0x64626720
|
||||||
|
|
||||||
/* declared over in file.c */
|
|
||||||
extern struct file_operations debugfs_file_operations;
|
|
||||||
extern struct inode_operations debugfs_link_operations;
|
|
||||||
|
|
||||||
static struct vfsmount *debugfs_mount;
|
static struct vfsmount *debugfs_mount;
|
||||||
static int debugfs_mount_count;
|
static int debugfs_mount_count;
|
||||||
|
|
||||||
|
@@ -27,6 +27,11 @@ struct debugfs_blob_wrapper {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if defined(CONFIG_DEBUG_FS)
|
#if defined(CONFIG_DEBUG_FS)
|
||||||
|
|
||||||
|
/* declared over in file.c */
|
||||||
|
extern const struct file_operations debugfs_file_operations;
|
||||||
|
extern const struct inode_operations debugfs_link_operations;
|
||||||
|
|
||||||
struct dentry *debugfs_create_file(const char *name, mode_t mode,
|
struct dentry *debugfs_create_file(const char *name, mode_t mode,
|
||||||
struct dentry *parent, void *data,
|
struct dentry *parent, void *data,
|
||||||
const struct file_operations *fops);
|
const struct file_operations *fops);
|
||||||
|
11
init/Kconfig
11
init/Kconfig
@@ -382,9 +382,13 @@ config CGROUP_MEM_RES_CTLR
|
|||||||
sure you need the memory resource controller.
|
sure you need the memory resource controller.
|
||||||
|
|
||||||
config SYSFS_DEPRECATED
|
config SYSFS_DEPRECATED
|
||||||
|
bool
|
||||||
|
|
||||||
|
config SYSFS_DEPRECATED_V2
|
||||||
bool "Create deprecated sysfs files"
|
bool "Create deprecated sysfs files"
|
||||||
depends on SYSFS
|
depends on SYSFS
|
||||||
default y
|
default y
|
||||||
|
select SYSFS_DEPRECATED
|
||||||
help
|
help
|
||||||
This option creates deprecated symlinks such as the
|
This option creates deprecated symlinks such as the
|
||||||
"device"-link, the <subsystem>:<name>-link, and the
|
"device"-link, the <subsystem>:<name>-link, and the
|
||||||
@@ -397,10 +401,11 @@ config SYSFS_DEPRECATED
|
|||||||
|
|
||||||
If enabled, this option will also move any device structures
|
If enabled, this option will also move any device structures
|
||||||
that belong to a class, back into the /sys/class hierarchy, in
|
that belong to a class, back into the /sys/class hierarchy, in
|
||||||
order to support older versions of udev.
|
order to support older versions of udev and some userspace
|
||||||
|
programs.
|
||||||
|
|
||||||
If you are using a distro that was released in 2006 or later,
|
If you are using a distro with the most recent userspace
|
||||||
it should be safe to say N here.
|
packages, it should be safe to say N here.
|
||||||
|
|
||||||
config PROC_PID_CPUSET
|
config PROC_PID_CPUSET
|
||||||
bool "Include legacy /proc/<pid>/cpuset file"
|
bool "Include legacy /proc/<pid>/cpuset file"
|
||||||
|
@@ -153,6 +153,10 @@ static void kobject_init_internal(struct kobject *kobj)
|
|||||||
return;
|
return;
|
||||||
kref_init(&kobj->kref);
|
kref_init(&kobj->kref);
|
||||||
INIT_LIST_HEAD(&kobj->entry);
|
INIT_LIST_HEAD(&kobj->entry);
|
||||||
|
kobj->state_in_sysfs = 0;
|
||||||
|
kobj->state_add_uevent_sent = 0;
|
||||||
|
kobj->state_remove_uevent_sent = 0;
|
||||||
|
kobj->state_initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -289,13 +293,8 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
|
|||||||
dump_stack();
|
dump_stack();
|
||||||
}
|
}
|
||||||
|
|
||||||
kref_init(&kobj->kref);
|
kobject_init_internal(kobj);
|
||||||
INIT_LIST_HEAD(&kobj->entry);
|
|
||||||
kobj->ktype = ktype;
|
kobj->ktype = ktype;
|
||||||
kobj->state_in_sysfs = 0;
|
|
||||||
kobj->state_add_uevent_sent = 0;
|
|
||||||
kobj->state_remove_uevent_sent = 0;
|
|
||||||
kobj->state_initialized = 1;
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
Reference in New Issue
Block a user