From patchwork Mon Jul 17 22:10:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 9846423 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 DCBF46037F for ; Mon, 17 Jul 2017 22:11:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1487B26E54 for ; Mon, 17 Jul 2017 22:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08EE827F54; Mon, 17 Jul 2017 22:11:23 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBD3826E54 for ; Mon, 17 Jul 2017 22:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751557AbdGQWLJ (ORCPT ); Mon, 17 Jul 2017 18:11:09 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:36492 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751850AbdGQWLG (ORCPT ); Mon, 17 Jul 2017 18:11:06 -0400 Received: by mail-qk0-f195.google.com with SMTP id d136so366794qkg.3; Mon, 17 Jul 2017 15:11:06 -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=q+UWkUd/jw4fNJOYEw/4G8wHAP4UbOXczvmhFZ127bs=; b=L0E/BcgUsDVWnH0df7xBwU8r/nvRuFI+PLOa72zBZigwhgk2/6daSeUBaPlplNSc7u zPePQbRAtFuk8jplLcIAkXmWVrmfcAp8IvxZ2tari6IrY+rBF9sgNDCe/u3W4xCZmybe 0FNqS20w/iW1ZLOiDNXTzNnmMoRWVcKx/wvCywSJC89h3y9O5uyqtXVCnznHfuqVrUNS evLocQuMZcYpT1oMJ5b55znNBQbs2iY0vZU1nN84rg1XsWjKPgSW5J/xggTb7hkWIkLB Wsq/3MM5+PZdiE/axUG8Eeg0bqQ3/b5sq21GOCk7tW5kYhA84ygxa7Ceu0YKkzTM74CO IvvA== 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=q+UWkUd/jw4fNJOYEw/4G8wHAP4UbOXczvmhFZ127bs=; b=IjQB4LSjjyxugMKnyvbSyKx5hK9irhWYblTiDdQy8reRvRcIe5CH6Vhy2ifO90gpgW 51NaVWlmTj5O4ttPJpD2KpK3iLaT0IhoqjmL+OtzV9PrJ/lATDDUDyGvrlHTEbOhNqQv J2P+wtVT0ZKOnuml1XRX+J/eiECizKTQra8TGYdAs3QnYlIz4o8FLT3jO2gs/jtTIaWU czi6IaJyvYrBBCe259WrWZIxGS0aTwakShiSIzZjzm1r6L6CNBM4TujUdWFgBoIvBT7k uUrAJ4n94Ok0XSXyOqZCzl46uZ7ENx6MyiuDTO70O6oxNnkAYNAqYBKD3QqpWoFKuupX KYvw== X-Gm-Message-State: AIVw112LX2Q8zISeyQEuNmoEy0qHxbM5+2zN1byy55Ka8XVbiFCsHnWz 9DnduuZ3c0QBJ+PatHE= X-Received: by 10.55.9.9 with SMTP id 9mr28208909qkj.53.1500329465704; Mon, 17 Jul 2017 15:11:05 -0700 (PDT) Received: from fainelli-desktop.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id v34sm320961qtg.31.2017.07.17.15.11.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 15:11:05 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: Florian Fainelli , "Rafael J. Wysocki" , Alexandre Belloni , "Rafael J. Wysocki" , Ulf Hansson , Daniel Lezcano , linux-pm , Thibaud Cornic , JB , Mason , Kevin Hilman , Pavel Machek , Linux ARM Subject: [PATCH v3] PM / suspend: Export pm_suspend_target_state Date: Mon, 17 Jul 2017 15:10:59 -0700 Message-Id: <20170717221059.6523-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170716023610.4658-1-f.fainelli@gmail.com> References: <20170716023610.4658-1-f.fainelli@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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 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 | 4 ++++ 2 files changed, 5 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..1aecdaf22ab5 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;