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: 9846503 X-Patchwork-Delegate: rjw@sisk.pl 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 A92DB602A7 for ; Tue, 18 Jul 2017 00:19:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCFBF205AF for ; Tue, 18 Jul 2017 00:19:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1B3D205FC; Tue, 18 Jul 2017 00:19:33 +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=ham 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 57C0C205AF for ; Tue, 18 Jul 2017 00:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751686AbdGRATc (ORCPT ); Mon, 17 Jul 2017 20:19:32 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:33079 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbdGRATb (ORCPT ); Mon, 17 Jul 2017 20:19:31 -0400 Received: by mail-qt0-f194.google.com with SMTP id j25so711279qtf.0; 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=hQLggPW1f5p1zDxdkep/J15J19zszDLiUdzH+yjW8qa4opKy5TQu7EaZyZTU+naudl XGeSlVv+sGsbSVwWx5/7Rugbx4d0cXQ8EtvkiYf2on3BMBbMoxgAtZA0iV9ylK7nWJnD llsDlWAgs6dbt4BlX3pwS3fT/8/bNlxQ5pUTz/AOfslAFQHH1V4tXMRb4iAteLlKPy7m AEfAUkCPnTpVaxFkhR73e9Smkxy+Ma15O8tPX4fX+wqQOg+PGn6yLRD9Lma567y4d+wJ d1AdDNHd0d1sUDjnOncTnywvPT8GophxgGBw48kXkG7jMs0MZslR6F0EWf5EJJy+Sasn xGuQ== X-Gm-Message-State: AIVw111ZiPGBo3XdtxJLcLbU9Rh7C6/RZKAOn0P+iZwJN0QBm7U48NjL H2z+PtSx0i5g2iEyA3I= 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 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 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> 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 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: