From patchwork Tue Jul 18 00:19:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 9846507 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 46860602A7 for ; Tue, 18 Jul 2017 00:19:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 571B7205FC for ; Tue, 18 Jul 2017 00:19:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 482BC20952; Tue, 18 Jul 2017 00:19:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3BE8205FC for ; Tue, 18 Jul 2017 00:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=WxTvKmz5AQQrbXb+/emJ8cr50cLrbKy4r3PLZcEfoFk=; b=Bgyh09j4NNLyV0pJRWwU5QFBjI Q5JQu9coPoEqIeh+e2/ne6yM3Vs47cz22rJXRX52s6gwUTr5EEPp6VTIIOhuVWxKe8xTgge10rM0Y D9cKEuH5oJ9zEM8EwyAiBShdVk0TcEsxW5tK41ZKTmR/F3GxOV0MKCF7RNRzKkn99AOs1Pq/o8uGl SPFKC9ks99asgLUP4l96M46icfliZEz6eZxiQ3uNNvrymEbWw4X6MLpcPTl6OiMJ8U9Gb+L4/PiDv mTuVJz+VpphaBBZsi9GWa4HYT+BOnTc3zgFzTlgegJD1FGliGc2FXM6yiyCbhM+S4FiIRwRNZibak xvU798ew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dXGF2-0006PD-BD; Tue, 18 Jul 2017 00:19:56 +0000 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dXGEz-0006NC-1h for linux-arm-kernel@lists.infradead.org; Tue, 18 Jul 2017 00:19:54 +0000 Received: by mail-qt0-x243.google.com with SMTP id 19so703625qty.1 for ; Mon, 17 Jul 2017 17:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=siAwbJMh0Fi2/fEVrdIFM6xztzOHmgvlOhatEJVsnb0=; b=hZVZnyyX/xv/S69no5xGydnO33xOqASjpENevv6YXMJ/FRbzwQ8Ow3HjQ3K1KmhNxw NHpYZqgQfU5csX3emvt5nCrMcuC9dPCA9g8fjovPd3UNGqWb1lAMjjiXsfKmlr4qpB8x OZHHbueMAKVe+az3RhwJV9Awbt3sy7lywQBSsnURD3zt321f3sObBBRCPKoB8TYwzYcC S3zTSqLP8ma7bEH7EFF6Tfx4Q/xu6FlJJc5F1FIiJsT8mlFf2WijrspZvyPfPXTi8Uga Ulx1UTVwiZJkTLuv7lOieltMgfBl8+X05HGZfpd/r2WtXzgtgXmZHN6V/MHo8ebYUzeG JRkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=siAwbJMh0Fi2/fEVrdIFM6xztzOHmgvlOhatEJVsnb0=; b=NFr3QfnQN51Ga8rLtlRBcwvih9Yx9yxWzfk78QhgI/XggJqZB5cd83bdjjV/hhjXzB sLpminkNUhV9REW4Rho5LoxlDDv6aW/ctyVH82GXk8C52OIfkhBsMfv0FagIeZhv4DsP GJRzUwzF9klp57xF2E5UWKT0Ha8GEFppPAwwXoYo8DXbVYiHrTZd18Q95QQaAPo7mnrw F7BeHlwiQgHTmaJq2JVB0OZr2cQqgErySwPFa+d1k2Bcn+1wuo06KmZEShItMdScBMUl mivssegMOy0yvt92LQ7mlQJMFBHLZpFi0OTsAJ7JFdzWiC6bK936kQMstfSGVbGN9hA0 L+7Q== X-Gm-Message-State: AIVw110wtkS8Ce1V5Rq5UxraXysPmpXHs8XzJUQvJxYTl3iGGiozcTAn iyRje84IHVxkdw== X-Received: by 10.237.33.69 with SMTP id 63mr224462qtc.11.1500337170715; Mon, 17 Jul 2017 17:19:30 -0700 (PDT) Received: from fainelli-desktop.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id q185sm502090qke.61.2017.07.17.17.19.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 17:19:28 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Subject: [PATCH v4] PM / suspend: Export pm_suspend_target_state Date: Mon, 17 Jul 2017 17:19:25 -0700 Message-Id: <20170718001925.25286-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170717221059.6523-1-f.fainelli@gmail.com> References: <20170717221059.6523-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170717_171953_178982_097F6F8E X-CRM114-Status: GOOD ( 10.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Florian Fainelli , "Rafael J. Wysocki" , linux-pm , Daniel Lezcano , "Rafael J. Wysocki" , Mason , Kevin Hilman , Alexandre Belloni , Pavel Machek , Thibaud Cornic , Linux ARM , JB MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Have the core suspend/resume framework store the system-wide suspend state (suspend_state_t) we are about to enter, and expose it to drivers via pm_suspend_target_state in order to retrieve that. The state is assigned in suspend_devices_and_enter(). This is useful for platform specific drivers that may need to take a slightly different suspend/resume path based on the system's suspend/resume state being entered. Signed-off-by: Florian Fainelli --- Changes in v4: - clear pm_suspend_target_state in Close label Changes in v3: - just export pm_suspend_target_state without a helper function Changes in v2: - rename platform_suspend_target_state() -> suspend_target_state() - directly export the suspend_state_t value and assign it in suspend_devices_and_enter() include/linux/suspend.h | 1 + kernel/power/suspend.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 0b1cf32edfd7..2159f6841768 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -427,6 +427,7 @@ extern int unregister_pm_notifier(struct notifier_block *nb); /* drivers/base/power/wakeup.c */ extern bool events_check_enabled; extern unsigned int pm_wakeup_irq; +extern suspend_state_t pm_suspend_target_state; extern bool pm_wakeup_pending(void); extern void pm_system_wakeup(void); diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 3ecf275d7e44..d0c0b96c2383 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -47,6 +47,8 @@ const char *mem_sleep_states[PM_SUSPEND_MAX]; suspend_state_t mem_sleep_current = PM_SUSPEND_FREEZE; static suspend_state_t mem_sleep_default = PM_SUSPEND_MEM; +suspend_state_t pm_suspend_target_state; +EXPORT_SYMBOL_GPL(pm_suspend_target_state); unsigned int pm_suspend_global_flags; EXPORT_SYMBOL_GPL(pm_suspend_global_flags); @@ -456,6 +458,8 @@ int suspend_devices_and_enter(suspend_state_t state) if (!sleep_state_supported(state)) return -ENOSYS; + pm_suspend_target_state = state; + error = platform_suspend_begin(state); if (error) goto Close; @@ -485,6 +489,7 @@ int suspend_devices_and_enter(suspend_state_t state) Close: platform_resume_end(state); + pm_suspend_target_state = PM_SUSPEND_ON; return error; Recover_platform: