From patchwork Thu Oct 11 05:08:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 1581031 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 1284940135 for ; Thu, 11 Oct 2012 05:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753815Ab2JKFIt (ORCPT ); Thu, 11 Oct 2012 01:08:49 -0400 Received: from mga02.intel.com ([134.134.136.20]:3751 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753680Ab2JKFIs (ORCPT ); Thu, 11 Oct 2012 01:08:48 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 10 Oct 2012 22:08:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,569,1344236400"; d="scan'208";a="204188189" Received: from mint-spring.sh.intel.com ([10.239.36.118]) by orsmga001.jf.intel.com with ESMTP; 10 Oct 2012 22:08:46 -0700 From: Aaron Lu To: Alan Stern , "Rafael J. Wysocki" , James Bottomley Cc: linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org, Aaron Lu , Aaron Lu Subject: [PATCH v2 5/5] sd: update sd to use the new pm callbacks Date: Thu, 11 Oct 2012 13:08:11 +0800 Message-Id: <1349932091-6856-6-git-send-email-aaron.lu@intel.com> X-Mailer: git-send-email 1.7.12.21.g871e293 In-Reply-To: <1349932091-6856-1-git-send-email-aaron.lu@intel.com> References: <1349932091-6856-1-git-send-email-aaron.lu@intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 --- drivers/scsi/sd.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8b6e004..6564305 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -104,7 +104,7 @@ static void sd_unlock_native_capacity(struct gendisk *disk); static int sd_probe(struct device *); static int sd_remove(struct device *); static void sd_shutdown(struct device *); -static int sd_suspend(struct device *, pm_message_t state); +static int sd_suspend(struct device *); static int sd_resume(struct device *); static void sd_rescan(struct device *); static int sd_done(struct scsi_cmnd *); @@ -423,15 +423,23 @@ static struct class sd_disk_class = { .dev_attrs = sd_disk_attrs, }; +static const struct dev_pm_ops sd_pm_ops = { + .suspend = sd_suspend, + .resume = sd_resume, + .poweroff = sd_suspend, + .restore = sd_resume, + .runtime_suspend = sd_suspend, + .runtime_resume = sd_resume, +}; + static struct scsi_driver sd_template = { .owner = THIS_MODULE, .gendrv = { .name = "sd", .probe = sd_probe, .remove = sd_remove, - .suspend = sd_suspend, - .resume = sd_resume, .shutdown = sd_shutdown, + .pm = &sd_pm_ops, }, .rescan = sd_rescan, .done = sd_done, @@ -2896,7 +2904,7 @@ exit: scsi_disk_put(sdkp); } -static int sd_suspend(struct device *dev, pm_message_t mesg) +static int sd_suspend(struct device *dev) { struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); int ret = 0; @@ -2911,8 +2919,7 @@ static int sd_suspend(struct device *dev, pm_message_t mesg) goto done; } - if (((mesg.event & PM_EVENT_SLEEP) || PMSG_IS_AUTO(mesg)) && - sdkp->device->manage_start_stop) { + if (sdkp->device->manage_start_stop) { sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); ret = sd_start_stop_device(sdkp, 0); }