-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCSI] convert to the new PM framework
This patch (as1397b) converts the SCSI midlayer to use the new PM callbacks (struct dev_pm_ops). A new source file, scsi_pm.c, is created to hold the new callback routines, and the existing suspend/resume code is moved there. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
- Loading branch information
Alan Stern
authored and
James Bottomley
committed
Jul 28, 2010
1 parent
df64d3c
commit db5bd1e
Showing
4 changed files
with
105 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* scsi_pm.c Copyright (C) 2010 Alan Stern | ||
* | ||
* SCSI dynamic Power Management | ||
* Initial version: Alan Stern <stern@rowland.harvard.edu> | ||
*/ | ||
|
||
#include <linux/pm_runtime.h> | ||
|
||
#include <scsi/scsi.h> | ||
#include <scsi/scsi_device.h> | ||
#include <scsi/scsi_driver.h> | ||
#include <scsi/scsi_host.h> | ||
|
||
#include "scsi_priv.h" | ||
|
||
static int scsi_dev_type_suspend(struct device *dev, pm_message_t msg) | ||
{ | ||
struct device_driver *drv; | ||
int err; | ||
|
||
err = scsi_device_quiesce(to_scsi_device(dev)); | ||
if (err == 0) { | ||
drv = dev->driver; | ||
if (drv && drv->suspend) | ||
err = drv->suspend(dev, msg); | ||
} | ||
dev_dbg(dev, "scsi suspend: %d\n", err); | ||
return err; | ||
} | ||
|
||
static int scsi_dev_type_resume(struct device *dev) | ||
{ | ||
struct device_driver *drv; | ||
int err = 0; | ||
|
||
drv = dev->driver; | ||
if (drv && drv->resume) | ||
err = drv->resume(dev); | ||
scsi_device_resume(to_scsi_device(dev)); | ||
dev_dbg(dev, "scsi resume: %d\n", err); | ||
return err; | ||
} | ||
|
||
#ifdef CONFIG_PM_SLEEP | ||
|
||
static int scsi_bus_suspend_common(struct device *dev, pm_message_t msg) | ||
{ | ||
int err = 0; | ||
|
||
if (scsi_is_sdev_device(dev)) | ||
err = scsi_dev_type_suspend(dev, msg); | ||
return err; | ||
} | ||
|
||
static int scsi_bus_resume_common(struct device *dev) | ||
{ | ||
int err = 0; | ||
|
||
if (scsi_is_sdev_device(dev)) | ||
err = scsi_dev_type_resume(dev); | ||
return err; | ||
} | ||
|
||
static int scsi_bus_suspend(struct device *dev) | ||
{ | ||
return scsi_bus_suspend_common(dev, PMSG_SUSPEND); | ||
} | ||
|
||
static int scsi_bus_freeze(struct device *dev) | ||
{ | ||
return scsi_bus_suspend_common(dev, PMSG_FREEZE); | ||
} | ||
|
||
static int scsi_bus_poweroff(struct device *dev) | ||
{ | ||
return scsi_bus_suspend_common(dev, PMSG_HIBERNATE); | ||
} | ||
|
||
#else /* CONFIG_PM_SLEEP */ | ||
|
||
#define scsi_bus_resume_common NULL | ||
#define scsi_bus_suspend NULL | ||
#define scsi_bus_freeze NULL | ||
#define scsi_bus_poweroff NULL | ||
|
||
#endif /* CONFIG_PM_SLEEP */ | ||
|
||
const struct dev_pm_ops scsi_bus_pm_ops = { | ||
.suspend = scsi_bus_suspend, | ||
.resume = scsi_bus_resume_common, | ||
.freeze = scsi_bus_freeze, | ||
.thaw = scsi_bus_resume_common, | ||
.poweroff = scsi_bus_poweroff, | ||
.restore = scsi_bus_resume_common, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters