mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
To: linux-pm@vger.kernel.org, Alan Stern <stern@rowland.harvard.edu>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	linux-kernel@vger.kernel.org, Len Brown <len.brown@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Pavel Machek <pavel@ucw.cz>
Subject: [PATCH v4 2/3] PM / sleep: Go direct_complete if driver has no callbacks
Date: Wed, 15 Jul 2015 14:40:07 +0200	[thread overview]
Message-ID: <1436964008-15151-3-git-send-email-tomeu.vizoso@collabora.com> (raw)
In-Reply-To: <1436964008-15151-1-git-send-email-tomeu.vizoso@collabora.com>

If a suitable prepare callback cannot be found for a given device and
its driver has no PM callbacks at all, assume that it can go direct to
complete when the system goes to sleep.

The reason for this is that there's lots of devices in a system that do
no PM at all and there's no reason for them to prevent their ancestors
to do direct_complete if they can support it.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---

 drivers/base/power/main.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 1710c26ba097..edda3f233c7c 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1540,6 +1540,21 @@ int dpm_suspend(pm_message_t state)
 	return error;
 }
 
+static bool driver_has_no_pm_callbacks(struct device_driver *drv)
+{
+	if (!drv->pm)
+		return true;
+
+	return !drv->pm->prepare &&
+	       !drv->pm->suspend &&
+	       !drv->pm->suspend_late &&
+	       !drv->pm->suspend_noirq &&
+	       !drv->pm->resume_noirq &&
+	       !drv->pm->resume_early &&
+	       !drv->pm->resume &&
+	       !drv->pm->complete;
+}
+
 /**
  * device_prepare - Prepare a device for system power transition.
  * @dev: Device to handle.
@@ -1590,6 +1605,8 @@ static int device_prepare(struct device *dev, pm_message_t state)
 
 	if (callback)
 		ret = callback(dev);
+	else if (!dev->driver || driver_has_no_pm_callbacks(dev->driver))
+		ret = 1;	/* Let device go direct_complete */
 
 	device_unlock(dev);
 
-- 
2.4.3


  parent reply	other threads:[~2015-07-15 12:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15 12:40 [PATCH v4 0/3] Tomeu Vizoso
2015-07-15 12:40 ` [PATCH v4 1/3] PM / sleep: Allow devices without runtime PM to do direct-complete Tomeu Vizoso
2015-07-16  0:39   ` Rafael J. Wysocki
2015-07-15 12:40 ` Tomeu Vizoso [this message]
2015-07-15 18:47   ` [PATCH v4 2/3] PM / sleep: Go direct_complete if driver has no callbacks Alan Stern
2015-07-16  0:41     ` Rafael J. Wysocki
2015-07-16  8:47       ` Tomeu Vizoso
2015-07-17  0:37         ` Rafael J. Wysocki
2015-07-15 12:40 ` [PATCH v4 3/3] USB / PM: Allow USB devices to remain runtime-suspended when sleeping Tomeu Vizoso
2015-07-16  0:42   ` Rafael J. Wysocki
2015-07-16 12:09     ` Tomeu Vizoso
2015-07-17  0:41       ` Rafael J. Wysocki

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=1436964008-15151-3-git-send-email-tomeu.vizoso@collabora.com \
    --to=tomeu.vizoso@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --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

all inboxes | Powered by JetHome®