Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1364084ybi; Fri, 2 Aug 2019 14:13:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzebZwL+4IfvbR4tz+Hrf7O679iSVUlSitX/jWj259RPZZrYkpk63Ce0iG58p4HHcbLtsdW X-Received: by 2002:a17:90a:2488:: with SMTP id i8mr6017041pje.123.1564780385741; Fri, 02 Aug 2019 14:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564780385; cv=none; d=google.com; s=arc-20160816; b=SLKDuQ/PS+YVp4FCdZNl/xr+UEWI5kvAUaBzTW8YRM+5CHkUhmP9ZTT2wdQ0ClpP7L Y4oP7LIZdYLQO4rDLvxHWO9P1yxy6iA3IcwFoTUzdfqsvg11HLcIW2ubqXiVc1G7Jwry dFI/xkIq7g7Inl8P0Dl8L7DywVSyyr7lqsRoppmSZ2JmGUCIdDZekS5wqJ8ZxdPgnimd HqW4LK2s/lfpqUWm9Pe1v+qLJrOA2bW2qKvGutA+j3x9Ch3frSSo3O3kf5FNyDt+u64X J6kjV46Ep8MtXJ19EuYGjOu0gbSI1GniV4SUeznAUCVjGJozw8TmYuclwdQ2CfyJyiT4 tnNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=335du6one7Tf/2rsJR9vKPmrRNMwIBPYYNIL4dOYxVQ=; b=JZ2CMBHU0rQ1L3/XCXRL7aDNJ7ADo+Eeor8Ufsn38jznz+hYDzKF/j0bkKPJwiw9fQ 54PM7UtjUI2t1N99hVBy3Q1osuFxbLbVho0p58KZcPlYhE8wG1Y9eK+ADmPIx1jH/YG7 ++7rwY1M+6IaFGy7B8R8gLXfHNac+CEDNn/rdXDGRDvS5vqOr3/RHeHUzC6Y30S8z2LY grae6zj08SdWPp2XTk93X119RHIdmlrtH1Qka7KbJ4twJTAL7sFRitgRj81LneS3Lo3s 3iQWki0xLJuoSmS1H1LNCzd4zOPSZB+xt8fgjULdhuBXrkeCJfhVD1KcB3HWtdbd1Qv0 UP1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b123si40501385pfa.14.2019.08.02.14.12.50; Fri, 02 Aug 2019 14:13:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404909AbfHBKqN (ORCPT + 99 others); Fri, 2 Aug 2019 06:46:13 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:51387 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730943AbfHBKpw (ORCPT ); Fri, 2 Aug 2019 06:45:52 -0400 Received: from 79.184.255.110.ipv4.supernova.orange.pl (79.184.255.110) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.275) id 0dbcfeec0813e87f; Fri, 2 Aug 2019 12:45:50 +0200 From: "Rafael J. Wysocki" To: Linux ACPI Cc: Linux PM , LKML , Zhang Rui , Rajneesh Bhardwaj , Andy Shevchenko , Mario Limonciello , Kai-Heng Feng Subject: [PATCH v3 2/8] ACPI: PM: s2idle: Rearrange lps0_device_attach() Date: Fri, 02 Aug 2019 12:38:34 +0200 Message-ID: <1674293.dTdQWrCe23@kreacher> In-Reply-To: <5997740.FPbUVk04hV@kreacher> References: <5997740.FPbUVk04hV@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki To allow a subsequent change to be simpler, rearrange the code in lps0_device_attach() to reduce the indentation level and (while at it) make it avoid calling lpi_device_get_constraints() when lps0_device_handle is not going to be set. Signed-off-by: Rafael J. Wysocki --- In v2 this was patch 3. --- drivers/acpi/sleep.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) Index: linux-pm/drivers/acpi/sleep.c =================================================================== --- linux-pm.orig/drivers/acpi/sleep.c +++ linux-pm/drivers/acpi/sleep.c @@ -916,28 +916,30 @@ static int lps0_device_attach(struct acp guid_parse(ACPI_LPS0_DSM_UUID, &lps0_dsm_guid); /* Check if the _DSM is present and as expected. */ out_obj = acpi_evaluate_dsm(adev->handle, &lps0_dsm_guid, 1, 0, NULL); - if (out_obj && out_obj->type == ACPI_TYPE_BUFFER) { - char bitmask = *(char *)out_obj->buffer.pointer; - - lps0_dsm_func_mask = bitmask; - lps0_device_handle = adev->handle; - /* - * Use suspend-to-idle by default if the default - * suspend mode was not set from the command line. - */ - if (mem_sleep_default > PM_SUSPEND_MEM) - mem_sleep_current = PM_SUSPEND_TO_IDLE; - - acpi_handle_debug(adev->handle, "_DSM function mask: 0x%x\n", - bitmask); - } else { + if (!out_obj || out_obj->type != ACPI_TYPE_BUFFER) { acpi_handle_debug(adev->handle, "_DSM function 0 evaluation failed\n"); + return 0; } + + lps0_dsm_func_mask = *(char *)out_obj->buffer.pointer; + ACPI_FREE(out_obj); + acpi_handle_debug(adev->handle, "_DSM function mask: 0x%x\n", + lps0_dsm_func_mask); + + lps0_device_handle = adev->handle; + lpi_device_get_constraints(); + /* + * Use suspend-to-idle by default if the default suspend mode was not + * set from the command line. + */ + if (mem_sleep_default > PM_SUSPEND_MEM) + mem_sleep_current = PM_SUSPEND_TO_IDLE; + return 0; }