Skip to content

Commit 691e3d3

Browse files
Aaron LuJames Bottomley
Aaron Lu
authored and
James Bottomley
committed
[SCSI] sd: update sd to use the new pm callbacks
Update sd driver to use the callbacks defined in dev_pm_ops. sd_freeze is NULL, the bus level callback has taken care of quiescing the device so there should be nothing needs to be done here. Consequently, sd_thaw is not needed here either. suspend, poweroff and runtime suspend share the same routine sd_suspend, which will sync flush and then stop the drive, this is the same as before. resume, restore and runtime resume share the same routine sd_resume, which will start the drive by putting it into active power state, this is also the same as before. Signed-off-by: Aaron Lu <[email protected]> Acked-by: Alan Stern <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 80d2fd4 commit 691e3d3

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/scsi/sd.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static void sd_unlock_native_capacity(struct gendisk *disk);
105105
static int sd_probe(struct device *);
106106
static int sd_remove(struct device *);
107107
static void sd_shutdown(struct device *);
108-
static int sd_suspend(struct device *, pm_message_t state);
108+
static int sd_suspend(struct device *);
109109
static int sd_resume(struct device *);
110110
static void sd_rescan(struct device *);
111111
static int sd_done(struct scsi_cmnd *);
@@ -465,15 +465,23 @@ static struct class sd_disk_class = {
465465
.dev_attrs = sd_disk_attrs,
466466
};
467467

468+
static 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+
468477
static struct scsi_driver sd_template = {
469478
.owner = THIS_MODULE,
470479
.gendrv = {
471480
.name = "sd",
472481
.probe = sd_probe,
473482
.remove = sd_remove,
474-
.suspend = sd_suspend,
475-
.resume = sd_resume,
476483
.shutdown = sd_shutdown,
484+
.pm = &sd_pm_ops,
477485
},
478486
.rescan = sd_rescan,
479487
.done = sd_done,
@@ -3054,7 +3062,7 @@ static void sd_shutdown(struct device *dev)
30543062
scsi_disk_put(sdkp);
30553063
}
30563064

3057-
static int sd_suspend(struct device *dev, pm_message_t mesg)
3065+
static int sd_suspend(struct device *dev)
30583066
{
30593067
struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
30603068
int ret = 0;
@@ -3069,8 +3077,7 @@ static int sd_suspend(struct device *dev, pm_message_t mesg)
30693077
goto done;
30703078
}
30713079

3072-
if (((mesg.event & PM_EVENT_SLEEP) || PMSG_IS_AUTO(mesg)) &&
3073-
sdkp->device->manage_start_stop) {
3080+
if (sdkp->device->manage_start_stop) {
30743081
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
30753082
ret = sd_start_stop_device(sdkp, 0);
30763083
}

0 commit comments

Comments
 (0)