[PATCH] Add a semaphore to struct device to synchronize calls to its driver.
This adds a per-device semaphore that is taken before every call from the core to a driver method. This prevents e.g. simultaneous calls to the ->suspend() or ->resume() and ->probe() or ->release(), potentially saving a whole lot of headaches. It also moves us a step closer to removing the bus rwsem, since it protects the fields in struct device that are modified by the core. Signed-off-by: Patrick Mochel <mochel@digitalimplant.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
eb51b65005
commit
af70316af1
@@ -22,6 +22,9 @@ extern int sysdev_resume(void);
|
||||
|
||||
int resume_device(struct device * dev)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
down(&dev->sem);
|
||||
if (dev->power.pm_parent
|
||||
&& dev->power.pm_parent->power.power_state) {
|
||||
dev_err(dev, "PM: resume from %d, parent %s still %d\n",
|
||||
@@ -31,9 +34,10 @@ int resume_device(struct device * dev)
|
||||
}
|
||||
if (dev->bus && dev->bus->resume) {
|
||||
dev_dbg(dev,"resuming\n");
|
||||
return dev->bus->resume(dev);
|
||||
error = dev->bus->resume(dev);
|
||||
}
|
||||
return 0;
|
||||
up(&dev->sem);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user