linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Lu <aaron.lu@intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org,
	Aaron Lu <aaron.lwe@gmail.com>
Subject: Re: [PATCH 1/2] [SCSI] pm: use callbacks from dev_pm_ops for scsi devices
Date: Thu, 11 Oct 2012 16:09:37 +0800	[thread overview]
Message-ID: <20121011080935.GA1819@mint-spring.sh.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1210101414570.1170-100000@iolanthe.rowland.org>

On Wed, Oct 10, 2012 at 02:32:13PM -0400, Alan Stern wrote:
> On Wed, 10 Oct 2012, Aaron Lu wrote:
> 
> > +static int run_dev_callback(struct device *dev, pm_message_t mesg)
> > +{
> > +	int ret;
> > +
> > +	switch (mesg.event) {
> > +		case PM_EVENT_SUSPEND:
> > +			ret = pm_generic_suspend(dev);
> > +			break;
> > +		case PM_EVENT_RESUME:
> > +			ret = pm_generic_resume(dev);
> > +			break;
> > +		case PM_EVENT_FREEZE:
> > +			ret = pm_generic_freeze(dev);
> > +			break;
> > +		case PM_EVENT_THAW:
> > +			ret = pm_generic_thaw(dev);
> > +			break;
> > +		case PM_EVENT_HIBERNATE:
> > +			ret = pm_generic_poweroff(dev);
> > +			break;
> > +		case PM_EVENT_RESTORE:
> > +			ret = pm_generic_restore(dev);
> > +			break;
> > +		case PM_EVENT_AUTO_SUSPEND:
> > +			ret = pm_generic_runtime_suspend(dev);
> > +			break;
> > +		case PM_EVENT_AUTO_RESUME:
> > +			ret = pm_generic_runtime_resume(dev);
> > +			break;
> > +		default:
> > +			ret = -1;
> > +			break;
> > +	}
> > +
> > +	return ret;
> > +}
> 
> > @@ -115,23 +145,40 @@ static int scsi_bus_suspend(struct device *dev)
> >  	return scsi_bus_suspend_common(dev, PMSG_SUSPEND);
> >  }
> >  
> > +static int scsi_bus_resume(struct device *dev)
> > +{
> > +	return scsi_bus_resume_common(dev, PMSG_RESUME);
> > +}
> > +
> >  static int scsi_bus_freeze(struct device *dev)
> >  {
> >  	return scsi_bus_suspend_common(dev, PMSG_FREEZE);
> >  }
> >  
> > +static int scsi_bus_thaw(struct device *dev)
> > +{
> > +	return scsi_bus_resume_common(dev, PMSG_THAW);
> > +}
> > +
> >  static int scsi_bus_poweroff(struct device *dev)
> >  {
> >  	return scsi_bus_suspend_common(dev, PMSG_HIBERNATE);
> >  }
> >  
> > +static int scsi_bus_restore(struct device *dev)
> > +{
> > +	return scsi_bus_resume_common(dev, PMSG_RESTORE);
> > +}
> > +
> 
> This is just dumb.  Do the parts that depend on the event type here, in 
> these routines, instead of using a big "switch" statement somewhere 
> else.  For example, have these routines figure out which callback 
> routine or generic routine to use, and pass that pointer to 
> scsi_bus_{suspend,resume}_common() instead of the PMSG_* argument.

Updated in v2, please take a look.

> 
> One thing may help simplify the conversion (you can do this in a
> separate patch).  Linus's current git tree contains a new commit
> 88d26136a256576e444db312179e17af6dd0ea87 (PM: Prevent runtime suspend
> during system resume) which makes some of the code in scsi_pm.c
> unnecessary.  The following two commits can now be reverted:
> 
> 	33a2285d96b5e7b9500612ec623bf4313397bb53
> 	[SCSI] scsi_pm: set device runtime state before parent suspended
> 
> 	28fd00d42cca178638f51c08efa986a777c24a4b
> 	[SCSI] runtime resume parent for child's system-resume
> 
> This will reduce the amount of code you need to worry about.

Yes, thanks for the info.

-Aaron


  reply	other threads:[~2012-10-11  8:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-10  7:28 [PATCH 0/2] Migrate SCSI drivers to use dev_pm_ops Aaron Lu
2012-10-10  7:28 ` [PATCH 1/2] [SCSI] pm: use callbacks from dev_pm_ops for scsi devices Aaron Lu
2012-10-10 18:32   ` Alan Stern
2012-10-11  8:09     ` Aaron Lu [this message]
2012-10-10  7:28 ` [PATCH 2/2] [SCSI] sd: update sd to use the new pm callbacks Aaron Lu
2012-10-10 18:35   ` Alan Stern
2012-10-11  8:10     ` Aaron Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121011080935.GA1819@mint-spring.sh.intel.com \
    --to=aaron.lu@intel.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=aaron.lwe@gmail.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).