Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3520191pxj; Mon, 24 May 2021 08:32:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQDrGRWxjVU6L+PWLgdUex717jvkJq+r02/KmAEJ1/K2xa97foTxX8CDhFPoeiAZKP2Upu X-Received: by 2002:a17:906:a3c9:: with SMTP id ca9mr23996619ejb.553.1621870367704; Mon, 24 May 2021 08:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870367; cv=none; d=google.com; s=arc-20160816; b=yLm9Vm7LyqCPpUSmeo5VX+V9w5IQ4902iDKed1LNbYnnifpDYPWX2ec9Vs4VUE3uP4 u5OlVi2T8Q2Zm0WrTDHbFPKp/Q+K++bUkEGMSMcnbdCX4MaE1P6fwPyvr5ED9Js2ETyi /xBiNusOwmKKw2riz1f/jpW9K2l7Hx70PGJtHphe5F+42PBv5C9YC7i8HIr0V4nmH0DC 7JFvL+tokl4RKKJyVLaQ2HoWonp0WZlbt5Sy4skNmqxk/9UeRz4jv2cnxdy6F4HD6jqL DDdhIEHCnBarAw1igYpvM2fpIRS5ZCVIwXsErntdg39JJhi0GkFSi7bpHbbb1y9zkHwl V9Rg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=qNh8aVaZSzdX0RYOtJvUW3HYvFEHLHO57go8f9YU6Ug=; b=VlLmipCs+KgfFrBz4ae/0c9u7wMSHHb/1hgxn4IKp12qX2x6nv4w1gxXyeqc+mkZen rr25fT4zqFiuZ2dUgGZguAWVR9GfTcPdILxDxiQMLj5DegPvXc2DyHRf2vTBTVm3bprX 8l2rAZN781RYZSxqKfcQ5qW2aDRVpGHYe9NjlWS4xo4MUTHtr4MgvDIYl8D4oX7T5umK e1r6sgnezvUc+sRWdKFQ+5+YTsAu68hR7sIYDMHbKsv5kbCuWEaIVcSWULWRoY42lYgO u1+R+PwPMIrHY5ggJp8/qAK5BRrtjCvI22grwF8HlXNwOhpubsQypDk6Krztdc/NH614 VKFA== 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 v28si14433128ejk.540.2021.05.24.08.32.24; Mon, 24 May 2021 08:32:47 -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 S233295AbhEXPaP (ORCPT + 99 others); Mon, 24 May 2021 11:30:15 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:52510 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233460AbhEXP3I (ORCPT ); Mon, 24 May 2021 11:29:08 -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 2.0.5) id 463d994eb97b68af; Mon, 24 May 2021 17:27:38 +0200 Received: from kreacher.localnet (89-64-80-49.dynamic.chello.pl [89.64.80.49]) (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 BD9D666971F; Mon, 24 May 2021 17:27:37 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: Linux PM , LKML , Zhang Rui , David Box , "Rafael J. Wysocki" , Dave Olsthoorn , Shujun Wang Subject: [PATCH v1 1/3] ACPI: power: Use u8 as the power resource state data type Date: Mon, 24 May 2021 17:24:16 +0200 Message-ID: <2786380.e9J7NaK4W3@kreacher> In-Reply-To: <2074778.irdbgypaU6@kreacher> References: <2074778.irdbgypaU6@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.64.80.49 X-CLIENT-HOSTNAME: 89-64-80-49.dynamic.chello.pl X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrvdejledgledtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepkeelrdeigedrkedtrdegleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeekledrieegrdektddrgeelpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopegurghvihgurdgvrdgsohigsehlihhnuhigrdhi nhhtvghlrdgtohhmpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghvvgessggvfigrrghrrdhmvgdprhgtphhtthhopeifshhjvddtfeeileesudeifedrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=8 Fuz1=8 Fuz2=8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Use u8 as the data type for representing the state of an ACPI power resource. It is s not necessary to use int for that and because subsequent changes are going to use ACPI_POWER_RESOURCE_STATE_UNKNOWN, it is better to adjust the data type so that the "unknown" state is represented by the "all ones" value. While at it, clean up acpi_power_get_state() somewhat. No intentional functional impact. Tested-by: Dave Olsthoorn Tested-by: Shujun Wang Signed-off-by: Rafael J. Wysocki --- drivers/acpi/power.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) Index: linux-pm/drivers/acpi/power.c =================================================================== --- linux-pm.orig/drivers/acpi/power.c +++ linux-pm/drivers/acpi/power.c @@ -182,10 +182,11 @@ int acpi_extract_power_resources(union a return err; } -static int acpi_power_get_state(acpi_handle handle, int *state) +static int acpi_power_get_state(acpi_handle handle, u8 *state) { acpi_status status = AE_OK; unsigned long long sta = 0; + u8 cur_state; if (!handle || !state) return -EINVAL; @@ -194,25 +195,24 @@ static int acpi_power_get_state(acpi_han if (ACPI_FAILURE(status)) return -ENODEV; - *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: - ACPI_POWER_RESOURCE_STATE_OFF; + cur_state = sta & ACPI_POWER_RESOURCE_STATE_ON; acpi_handle_debug(handle, "Power resource is %s\n", - *state ? "on" : "off"); + cur_state ? "on" : "off"); + *state = cur_state; return 0; } -static int acpi_power_get_list_state(struct list_head *list, int *state) +static int acpi_power_get_list_state(struct list_head *list, u8 *state) { struct acpi_power_resource_entry *entry; - int cur_state; + u8 cur_state = ACPI_POWER_RESOURCE_STATE_OFF; if (!list || !state) return -EINVAL; /* The state of the list is 'on' IFF all resources are 'on'. */ - cur_state = 0; list_for_each_entry(entry, list, node) { struct acpi_power_resource *resource = entry->resource; acpi_handle handle = resource->device.handle; @@ -592,7 +592,7 @@ int acpi_power_wakeup_list_init(struct l struct acpi_power_resource *resource = entry->resource; acpi_handle handle = resource->device.handle; int result; - int state; + u8 state; mutex_lock(&resource->resource_lock); @@ -789,8 +789,8 @@ int acpi_disable_wakeup_device_power(str int acpi_power_get_inferred_state(struct acpi_device *device, int *state) { + u8 list_state = ACPI_POWER_RESOURCE_STATE_OFF; int result = 0; - int list_state = 0; int i = 0; if (!device || !state) @@ -919,7 +919,8 @@ struct acpi_device *acpi_add_power_resou union acpi_object acpi_object; struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; acpi_status status; - int state, result = -ENODEV; + int result; + u8 state; acpi_bus_get_device(handle, &device); if (device) @@ -979,7 +980,8 @@ void acpi_resume_power_resources(void) mutex_lock(&power_resource_list_lock); list_for_each_entry(resource, &acpi_power_resource_list, list_node) { - int result, state; + int result; + u8 state; mutex_lock(&resource->resource_lock); @@ -1012,7 +1014,8 @@ static void acpi_power_turn_off_if_unuse if (resource->users > 0) return; } else { - int result, state; + int result; + u8 state; result = acpi_power_get_state(resource->device.handle, &state); if (result || state == ACPI_POWER_RESOURCE_STATE_OFF)