Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753413AbbGOSrx (ORCPT ); Wed, 15 Jul 2015 14:47:53 -0400 Received: from netrider.rowland.org ([192.131.102.5]:54242 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752494AbbGOSrv (ORCPT ); Wed, 15 Jul 2015 14:47:51 -0400 Date: Wed, 15 Jul 2015 14:47:50 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Tomeu Vizoso cc: linux-pm@vger.kernel.org, "Rafael J. Wysocki" , , Len Brown , Greg Kroah-Hartman , Pavel Machek Subject: Re: [PATCH v4 2/3] PM / sleep: Go direct_complete if driver has no callbacks In-Reply-To: <1436964008-15151-3-git-send-email-tomeu.vizoso@collabora.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1722 Lines: 50 On Wed, 15 Jul 2015, Tomeu Vizoso wrote: > 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 > --- > > 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; > +} This isn't exactly what I meant. We also need to check the dev_pm_ops fields in dev->pm_domain, dev->type, dev->class, and dev->bus. Only if _all_ of these callbacks are missing should we use direct_complete. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/