aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b1195fd537b6..7992635d405f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -105,7 +105,7 @@ static void sd_unlock_native_capacity(struct gendisk *disk);
105static int sd_probe(struct device *); 105static int sd_probe(struct device *);
106static int sd_remove(struct device *); 106static int sd_remove(struct device *);
107static void sd_shutdown(struct device *); 107static void sd_shutdown(struct device *);
108static int sd_suspend(struct device *, pm_message_t state); 108static int sd_suspend(struct device *);
109static int sd_resume(struct device *); 109static int sd_resume(struct device *);
110static void sd_rescan(struct device *); 110static void sd_rescan(struct device *);
111static int sd_done(struct scsi_cmnd *); 111static int sd_done(struct scsi_cmnd *);
@@ -465,15 +465,23 @@ static struct class sd_disk_class = {
465 .dev_attrs = sd_disk_attrs, 465 .dev_attrs = sd_disk_attrs,
466}; 466};
467 467
468static const struct dev_pm_ops sd_pm_ops = {
469 .suspend = sd_suspend,
470 .resume = sd_resume,
471 .poweroff = sd_suspend,
472 .restore = sd_resume,
473 .runtime_suspend = sd_suspend,
474 .runtime_resume = sd_resume,
475};
476
468static struct scsi_driver sd_template = { 477static struct scsi_driver sd_template = {
469 .owner = THIS_MODULE, 478 .owner = THIS_MODULE,
470 .gendrv = { 479 .gendrv = {
471 .name = "sd", 480 .name = "sd",
472 .probe = sd_probe, 481 .probe = sd_probe,
473 .remove = sd_remove, 482 .remove = sd_remove,
474 .suspend = sd_suspend,
475 .resume = sd_resume,
476 .shutdown = sd_shutdown, 483 .shutdown = sd_shutdown,
484 .pm = &sd_pm_ops,
477 }, 485 },
478 .rescan = sd_rescan, 486 .rescan = sd_rescan,
479 .done = sd_done, 487 .done = sd_done,
@@ -3054,7 +3062,7 @@ exit:
3054 scsi_disk_put(sdkp); 3062 scsi_disk_put(sdkp);
3055} 3063}
3056 3064
3057static int sd_suspend(struct device *dev, pm_message_t mesg) 3065static int sd_suspend(struct device *dev)
3058{ 3066{
3059 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 3067 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
3060 int ret = 0; 3068 int ret = 0;
@@ -3069,8 +3077,7 @@ static int sd_suspend(struct device *dev, pm_message_t mesg)
3069 goto done; 3077 goto done;
3070 } 3078 }
3071 3079
3072 if (((mesg.event & PM_EVENT_SLEEP) || PMSG_IS_AUTO(mesg)) && 3080 if (sdkp->device->manage_start_stop) {
3073 sdkp->device->manage_start_stop) {
3074 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); 3081 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
3075 ret = sd_start_stop_device(sdkp, 0); 3082 ret = sd_start_stop_device(sdkp, 0);
3076 } 3083 }