From patchwork Sun Oct 7 07:27:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe PLAGNIOL-VILLARD X-Patchwork-Id: 1560781 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 0EA50DF238 for ; Sun, 7 Oct 2012 07:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751969Ab2JGHsT (ORCPT ); Sun, 7 Oct 2012 03:48:19 -0400 Received: from 6.mo1.mail-out.ovh.net ([46.105.43.205]:35317 "EHLO mo1.mail-out.ovh.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752012Ab2JGHsR (ORCPT ); Sun, 7 Oct 2012 03:48:17 -0400 Received: from mail625.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo1.mail-out.ovh.net (Postfix) with SMTP id 632A3FFB049 for ; Sun, 7 Oct 2012 09:39:09 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 7 Oct 2012 09:29:54 +0200 Received: from ns32433.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@213.251.161.87) by ns0.ovh.net with SMTP; 7 Oct 2012 09:29:52 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org Cc: Jean-Christophe PLAGNIOL-VILLARD , Nicolas Ferre , Greg Kroah-Hartman , linux-pm@vger.kernel.org X-Ovh-Mailout: 178.32.228.1 (mo1.mail-out.ovh.net) Subject: [PATCH 2/6] platform: pm: add suspend_mem and suspend_standby support Date: Sun, 7 Oct 2012 09:27:16 +0200 Message-Id: <1349594840-11374-2-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1349594840-11374-1-git-send-email-plagnioj@jcrosoft.com> References: <20121006161429.GD12462@game.jcrosoft.org> <1349594840-11374-1-git-send-email-plagnioj@jcrosoft.com> X-Ovh-Tracer-Id: 3418232118545853437 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehuddrudduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehuddrudduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org If a drivers does not need to care about this distinction we fallback to suspend. This will allow to do not update the current drivers. Cc: Nicolas Ferre Cc: Greg Kroah-Hartman Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: linux-pm@vger.kernel.org --- drivers/base/platform.c | 40 +++++++++++++++++++++++++++++++++++++++ include/linux/platform_device.h | 6 ++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 8727e9c..f4822e2 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -740,6 +740,46 @@ static int platform_legacy_resume(struct device *dev) #ifdef CONFIG_SUSPEND +int platform_pm_suspend_mem(struct device *dev) +{ + struct device_driver *drv = dev->driver; + int ret = 0; + + if (!drv) + return 0; + + if (drv->pm) { + if (drv->pm->suspend_mem) + ret = drv->pm->suspend_mem(dev); + else if (drv->pm->suspend) + ret = drv->pm->suspend(dev); + } else { + ret = platform_legacy_suspend(dev, PMSG_SUSPEND); + } + + return ret; +} + +int platform_pm_suspend_standby(struct device *dev) +{ + struct device_driver *drv = dev->driver; + int ret = 0; + + if (!drv) + return 0; + + if (drv->pm) { + if (drv->pm->suspend_standby) + ret = drv->pm->suspend_standby(dev); + else if (drv->pm->suspend) + ret = drv->pm->suspend(dev); + } else { + ret = platform_legacy_suspend(dev, PMSG_SUSPEND); + } + + return ret; +} + int platform_pm_suspend(struct device *dev) { struct device_driver *drv = dev->driver; diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 5711e95..a7c2275 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -262,9 +262,13 @@ static inline char *early_platform_driver_setup_func(void) \ #ifdef CONFIG_SUSPEND extern int platform_pm_suspend(struct device *dev); +extern int platform_pm_suspend_mem(struct device *dev); +extern int platform_pm_suspend_standby(struct device *dev); extern int platform_pm_resume(struct device *dev); #else #define platform_pm_suspend NULL +#define platform_pm_suspend_mem NULL +#define platform_pm_suspend_standby NULL #define platform_pm_resume NULL #endif @@ -283,6 +287,8 @@ extern int platform_pm_restore(struct device *dev); #ifdef CONFIG_PM_SLEEP #define USE_PLATFORM_PM_SLEEP_OPS \ .suspend = platform_pm_suspend, \ + .suspend_standby = platform_pm_suspend_standby, \ + .suspend_mem = platform_pm_suspend_mem, \ .resume = platform_pm_resume, \ .freeze = platform_pm_freeze, \ .thaw = platform_pm_thaw, \