Commit 3525978c authored by Patrick Mochel's avatar Patrick Mochel

[power] Get rid of internal spinlock.

We don't need the spinlock to protect the lists (at least not now), since 
we have a semaphore to synchronize all operations device PM operations.
parent 78156c16
......@@ -29,7 +29,6 @@ LIST_HEAD(dpm_suspended);
LIST_HEAD(dpm_off);
LIST_HEAD(dpm_off_irq);
spinlock_t dpm_lock = SPIN_LOCK_UNLOCKED;
DECLARE_MUTEX(dpm_sem);
static struct attribute power_attrs[] = {
......@@ -47,9 +46,7 @@ int device_pm_add(struct device * dev)
pr_debug("PM: Adding info for %s:%s\n",
dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
down(&dpm_sem);
spin_lock(&dpm_lock);
list_add_tail(&dev->power.entry,&dpm_active);
spin_unlock(&dpm_lock);
error = sysfs_create_group(&dev->kobj,&pm_attr_group);
up(&dpm_sem);
return error;
......@@ -61,8 +58,6 @@ void device_pm_remove(struct device * dev)
dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
down(&dpm_sem);
sysfs_remove_group(&dev->kobj,&pm_attr_group);
spin_lock(&dpm_lock);
list_del(&dev->power.entry);
spin_unlock(&dpm_lock);
up(&dpm_sem);
}
......@@ -4,11 +4,6 @@
*/
extern struct semaphore dpm_sem;
/*
* Used to protect PM lists.
*/
extern spinlock_t dpm_lock;
/*
* The PM lists.
*/
......
......@@ -39,17 +39,13 @@ static int resume_device(struct device * dev)
int dpm_resume(void)
{
spin_lock(&dpm_lock);
while(!list_empty(&dpm_suspended)) {
struct list_head * entry = dpm_suspended.next;
struct device * dev = to_device(entry);
list_del_init(entry);
spin_unlock(&dpm_lock);
resume_device(dev);
spin_lock(&dpm_lock);
list_add_tail(entry,&dpm_active);
}
spin_unlock(&dpm_lock);
return 0;
}
......@@ -95,14 +91,12 @@ static void power_up_device(struct device * dev)
void dpm_power_up_irq(void)
{
spin_lock_irq(&dpm_lock);
while(!list_empty(&dpm_off_irq)) {
struct list_head * entry = dpm_off_irq.next;
list_del_init(entry);
power_up_device(to_device(entry));
list_add_tail(entry,&dpm_suspended);
}
spin_unlock_irq(&dpm_lock);
}
......@@ -116,14 +110,12 @@ void dpm_power_up_irq(void)
void dpm_power_up(void)
{
spin_lock(&dpm_lock);
while (!list_empty(&dpm_off)) {
struct list_head * entry = dpm_off.next;
list_del_init(entry);
power_up_device(to_device(entry));
list_add_tail(entry,&dpm_suspended);
}
spin_unlock(&dpm_lock);
}
......
......@@ -71,15 +71,12 @@ int device_pm_suspend(u32 state)
int error = 0;
down(&dpm_sem);
spin_lock(&dpm_lock);
while(!list_empty(&dpm_active)) {
struct list_head * entry = dpm_active.prev;
struct device * dev = to_device(entry);
list_del_init(entry);
spin_unlock(&dpm_lock);
error = suspend_device(dev,state);
spin_lock(&dpm_lock);
if (!error)
list_add(entry,&dpm_suspended);
else {
......@@ -87,7 +84,6 @@ int device_pm_suspend(u32 state)
goto Error;
}
}
spin_unlock(&dpm_lock);
if ((error = sysdev_save(state)))
goto Error;
......@@ -129,15 +125,12 @@ static int power_down_device(struct device * dev, u32 state)
static int dpm_power_down(u32 state)
{
spin_lock(&dpm_lock);
while(!list_empty(&dpm_suspended)) {
struct list_head * entry = dpm_suspended.prev;
int error;
list_del_init(entry);
spin_unlock(&dpm_lock);
error = power_down_device(to_device(entry),state);
spin_lock(&dpm_lock);
if (!error)
list_add(entry,&dpm_off);
else if (error == -EAGAIN)
......@@ -147,7 +140,6 @@ static int dpm_power_down(u32 state)
return error;
}
}
spin_unlock(&dpm_lock);
return 0;
}
......@@ -166,12 +158,10 @@ static int dpm_power_down_irq(u32 state)
struct device * dev;
int error = 0;
spin_lock_irq(&dpm_lock);
list_for_each_entry_reverse(dev,&dpm_off_irq,power.entry) {
if ((error = power_down_device(dev,state)))
break;
}
spin_unlock_irq(&dpm_lock);
return error;
}
......
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