From patchwork Wed Jul 15 12:40:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6798191 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D13F5C05AC for ; Wed, 15 Jul 2015 12:44:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2F03205B9 for ; Wed, 15 Jul 2015 12:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42BB5205DB for ; Wed, 15 Jul 2015 12:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752665AbbGOMol (ORCPT ); Wed, 15 Jul 2015 08:44:41 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:36384 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752216AbbGOMoK (ORCPT ); Wed, 15 Jul 2015 08:44:10 -0400 Received: by wgxm20 with SMTP id m20so32650420wgx.3; Wed, 15 Jul 2015 05:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WHdLbwh+pYyCBrB1/fplFZ6Sc7UL+BhlyXhJn8NFaJg=; b=S8cIMT6btF6fFAC4Hn76X0WsrVW1Kh5uyMgIpikOHmSmovz44dHvYGRVJzYq7V/H8A eHZ+w7bn9JCaiFcnwDFXjIx1v4X5hiof0owwV4EcQmNOaq7gnKpidsmz/Gumhr4aUrBT XH3aR4Adb8XNpSZhf2Vk756LGFvTEWbw6bLhUStTjPRbwRLmGa/9Z3CAM60CT+Qzkm5b +fWk1XJwZ8EHtfH61uq7jZeNwjQwz1xTM3S3nEXxrHd9wYPTlV+eKTT3jBDNDK6p1eOx q8390ENIGroGubkzkFjIYRTxqu5yvZatvRNbdUS2D1LSedSdaQnQABnpXhsIwcSZr2lw eG/g== X-Received: by 10.180.86.168 with SMTP id q8mr41495506wiz.80.1436964249427; Wed, 15 Jul 2015 05:44:09 -0700 (PDT) Received: from cizrna.lan ([109.72.12.162]) by smtp.gmail.com with ESMTPSA id ck7sm7729831wjc.43.2015.07.15.05.44.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2015 05:44:08 -0700 (PDT) From: Tomeu Vizoso To: linux-pm@vger.kernel.org, Alan Stern , "Rafael J. Wysocki" Cc: Tomeu Vizoso , linux-kernel@vger.kernel.org, Len Brown , Greg Kroah-Hartman , Pavel Machek Subject: [PATCH v4 2/3] PM / sleep: Go direct_complete if driver has no callbacks Date: Wed, 15 Jul 2015 14:40:07 +0200 Message-Id: <1436964008-15151-3-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1436964008-15151-1-git-send-email-tomeu.vizoso@collabora.com> References: <1436964008-15151-1-git-send-email-tomeu.vizoso@collabora.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; +} + /** * 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);