Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1855169pxb; Fri, 22 Oct 2021 08:55:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+koRWtwNQKt4B+zS1l9EFniHgrAw3ZiQH/Bkd1qAm8vOZ7QSITxSxsegPWTaCZjgixhHZ X-Received: by 2002:a62:ce07:0:b0:44c:fef2:e410 with SMTP id y7-20020a62ce07000000b0044cfef2e410mr357280pfg.71.1634918136837; Fri, 22 Oct 2021 08:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634918136; cv=none; d=google.com; s=arc-20160816; b=JzyDgGvvCd9nmB0n7K+DHEJJj0+72lCUw34Bz566yPe1V9lNRTjaTuuwyGWxhhBVDI HfbB2KdR5m27NcRxTAIzK7kjijTjeVWx0Z7ybVNH5Qh4avXDV7t54bxe4cVZjDPtpM1G IP1b0cQs/zQTwv56YFCc/GOwu5WHABaLeSH4LmuhDYMZ3B3cqOZazme3ui+VMxfvGBVw vpcE/ZQ+hBRto0D1ma6ngwALGcikII9HCxBjoN8CYvP527lbgInmna2y7+iirw2g3ELK 8a9ch6Ffc/syhvYcKSswnPr/Z/geFccFn6HRf+lnSX5g8m/r96TlDBVY1oVMF2xCnqnv 5lZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=gaAG9Kdn1FcRcjBO1D79o00KiB79RteuVIiSD/D7cqU=; b=TIHJBJTDwsLJ6WpSL2KijhZ9tZgTzdHrH7m4HOjT/Zmfax4VuVylQLJ5RDWAcnWcsm 5jSKmZ8bBjpbTzII+xhiJkOQ+LljMzQxGtpHDNrmGfncu0DeSgBAyLE/IjCHJN1AjQt8 3UwfsaDlsa0HBKqLNLBDNmph7SfSUdXOF24yZAQXrLlsq9O1XUaDElqUIl3nM43z9P0A 26a/WEUy9LAwVLLgueQOGqFgst3w8FI+rFvssjQsN158tyRniRWOyoSguWIBfBwHVvcx so7F9MW+6g6fqt9y4GF9RsPSnSdbzmRLxAU6uDx/5kD2/bvKMZ32yqMSGb5BsVH/+c/P OjcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 15si15786102pjt.0.2021.10.22.08.55.23; Fri, 22 Oct 2021 08:55:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233327AbhJVP4F (ORCPT + 99 others); Fri, 22 Oct 2021 11:56:05 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:47726 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233268AbhJVP4E (ORCPT ); Fri, 22 Oct 2021 11:56:04 -0400 Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 3.0.0) id a55714590f225a46; Fri, 22 Oct 2021 17:53:45 +0200 Received: from kreacher.localnet (unknown [213.134.175.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 5FB0166A9BA; Fri, 22 Oct 2021 17:53:44 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML Subject: [PATCH] PM: suspend: Use valid_state() consistently Date: Fri, 22 Oct 2021 17:53:43 +0200 Message-ID: <2617889.mvXUDI8C0e@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.175.233 X-CLIENT-HOSTNAME: 213.134.175.233 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrudeljedguddtfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhephfegtdffjeehkeegleejveevtdeugfffieeijeduuddtkefgjedvheeujeejtedvnecukfhppedvudefrddufeegrddujeehrddvfeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudejhedrvdeffedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=2 Fuz1=2 Fuz2=2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Make valid_state() check if the ->enter callback is present in suspend_ops (only PM_SUSPEND_TO_IDLE can be valid otherwise) and make sleep_state_supported() call valid_state() consistently to validate the states other than PM_SUSPEND_TO_IDLE. While at it, clean up the comment in valid_state(). No expected functional impact. Signed-off-by: Rafael J. Wysocki --- kernel/power/suspend.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) Index: linux-pm/kernel/power/suspend.c =================================================================== --- linux-pm.orig/kernel/power/suspend.c +++ linux-pm/kernel/power/suspend.c @@ -160,11 +160,13 @@ EXPORT_SYMBOL_GPL(s2idle_wake); static bool valid_state(suspend_state_t state) { /* - * PM_SUSPEND_STANDBY and PM_SUSPEND_MEM states need low level - * support and need to be valid to the low level - * implementation, no valid callback implies that none are valid. + * The PM_SUSPEND_STANDBY and PM_SUSPEND_MEM states require low-level + * support and need to be valid to the low-level implementation. + * + * No ->valid() or ->enter() callback implies that none are valid. */ - return suspend_ops && suspend_ops->valid && suspend_ops->valid(state); + return suspend_ops && suspend_ops->valid && suspend_ops->valid(state) && + suspend_ops->enter; } void __init pm_states_init(void) @@ -236,7 +238,7 @@ EXPORT_SYMBOL_GPL(suspend_valid_only_mem static bool sleep_state_supported(suspend_state_t state) { - return state == PM_SUSPEND_TO_IDLE || (suspend_ops && suspend_ops->enter); + return state == PM_SUSPEND_TO_IDLE || valid_state(state); } static int platform_suspend_prepare(suspend_state_t state)