From nobody Sun Feb 8 20:29:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16410C7EE2D for ; Sun, 4 Jun 2023 12:21:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230484AbjFDMVi (ORCPT ); Sun, 4 Jun 2023 08:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbjFDMVZ (ORCPT ); Sun, 4 Jun 2023 08:21:25 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63378CA; Sun, 4 Jun 2023 05:21:23 -0700 (PDT) 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 5.2.0) id f9566b58db2df641; Sun, 4 Jun 2023 14:21:21 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (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 4FC29963C55; Sun, 4 Jun 2023 14:21:21 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Zhang Rui , Daniel Lezcano , Michal Wilczynski , Srinivas Pandruvada Subject: [PATCH v2 5/7] ACPI: thermal: Eliminate struct acpi_thermal_state_flags Date: Sun, 04 Jun 2023 14:18:05 +0200 Message-ID: <3186378.5fSG56mABF@kreacher> In-Reply-To: <2703629.mvXUDI8C0e@kreacher> References: <2703629.mvXUDI8C0e@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeljedgheduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepiedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehm ihgthhgrlhdrfihilhgtiiihnhhskhhisehinhhtvghlrdgtohhmpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Rafael J. Wysocki Notice that the enabled flag is only needed for active trip points, so drop struct acpi_thermal_state_flags, add a simple "bool valid" field to the definitions of all trip point structures instead of flags and add a "bool enabled" field to struct acpi_thermal_active. Adjust the code using the modified structures accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Michal Wilczynski Reviewed-by: Daniel Lezcano --- v1 -> v2: * Added R-by from Michal. * Replaced 0 with "false" in one assignment overlooked previously. --- drivers/acpi/thermal.c | 132 +++++++++++++++++++++++---------------------= ----- 1 file changed, 64 insertions(+), 68 deletions(-) Index: linux-pm/drivers/acpi/thermal.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-pm.orig/drivers/acpi/thermal.c +++ linux-pm/drivers/acpi/thermal.c @@ -105,35 +105,30 @@ struct acpi_thermal_state { int active_index; }; =20 -struct acpi_thermal_state_flags { - u8 valid:1; - u8 enabled:1; - u8 reserved:6; -}; - struct acpi_thermal_critical { - struct acpi_thermal_state_flags flags; unsigned long temperature; + bool valid; }; =20 struct acpi_thermal_hot { - struct acpi_thermal_state_flags flags; unsigned long temperature; + bool valid; }; =20 struct acpi_thermal_passive { - struct acpi_thermal_state_flags flags; + struct acpi_handle_list devices; unsigned long temperature; unsigned long tc1; unsigned long tc2; unsigned long tsp; - struct acpi_handle_list devices; + bool valid; }; =20 struct acpi_thermal_active { - struct acpi_thermal_state_flags flags; - unsigned long temperature; struct acpi_handle_list devices; + unsigned long temperature; + bool valid; + bool enabled; }; =20 struct acpi_thermal_trips { @@ -229,7 +224,7 @@ static int acpi_thermal_trips_update(str acpi_status status; unsigned long long tmp; struct acpi_handle_list devices; - int valid =3D 0; + bool valid =3D false; int i; =20 /* Critical Shutdown */ @@ -243,21 +238,21 @@ static int acpi_thermal_trips_update(str * ... so lets discard those as invalid. */ if (ACPI_FAILURE(status)) { - tz->trips.critical.flags.valid =3D 0; + tz->trips.critical.valid =3D false; acpi_handle_debug(tz->device->handle, "No critical threshold\n"); } else if (tmp <=3D 2732) { pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp); - tz->trips.critical.flags.valid =3D 0; + tz->trips.critical.valid =3D false; } else { - tz->trips.critical.flags.valid =3D 1; + tz->trips.critical.valid =3D true; acpi_handle_debug(tz->device->handle, "Found critical threshold [%lu]\n", tz->trips.critical.temperature); } - if (tz->trips.critical.flags.valid) { + if (tz->trips.critical.valid) { if (crt =3D=3D -1) { - tz->trips.critical.flags.valid =3D 0; + tz->trips.critical.valid =3D false; } else if (crt > 0) { unsigned long crt_k =3D celsius_to_deci_kelvin(crt); =20 @@ -276,12 +271,12 @@ static int acpi_thermal_trips_update(str if (flag & ACPI_TRIPS_HOT) { status =3D acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp); if (ACPI_FAILURE(status)) { - tz->trips.hot.flags.valid =3D 0; + tz->trips.hot.valid =3D false; acpi_handle_debug(tz->device->handle, "No hot threshold\n"); } else { tz->trips.hot.temperature =3D tmp; - tz->trips.hot.flags.valid =3D 1; + tz->trips.hot.valid =3D true; acpi_handle_debug(tz->device->handle, "Found hot threshold [%lu]\n", tz->trips.hot.temperature); @@ -289,9 +284,9 @@ static int acpi_thermal_trips_update(str } =20 /* Passive (optional) */ - if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || + if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.valid) || flag =3D=3D ACPI_TRIPS_INIT) { - valid =3D tz->trips.passive.flags.valid; + valid =3D tz->trips.passive.valid; if (psv =3D=3D -1) { status =3D AE_SUPPORT; } else if (psv > 0) { @@ -303,44 +298,44 @@ static int acpi_thermal_trips_update(str } =20 if (ACPI_FAILURE(status)) { - tz->trips.passive.flags.valid =3D 0; + tz->trips.passive.valid =3D false; } else { tz->trips.passive.temperature =3D tmp; - tz->trips.passive.flags.valid =3D 1; + tz->trips.passive.valid =3D true; if (flag =3D=3D ACPI_TRIPS_INIT) { status =3D acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, &tmp); if (ACPI_FAILURE(status)) - tz->trips.passive.flags.valid =3D 0; + tz->trips.passive.valid =3D false; else tz->trips.passive.tc1 =3D tmp; =20 status =3D acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, &tmp); if (ACPI_FAILURE(status)) - tz->trips.passive.flags.valid =3D 0; + tz->trips.passive.valid =3D false; else tz->trips.passive.tc2 =3D tmp; =20 status =3D acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp); if (ACPI_FAILURE(status)) - tz->trips.passive.flags.valid =3D 0; + tz->trips.passive.valid =3D false; else tz->trips.passive.tsp =3D tmp; } } } - if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { + if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.valid) { memset(&devices, 0, sizeof(struct acpi_handle_list)); status =3D acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices); if (ACPI_FAILURE(status)) { acpi_handle_info(tz->device->handle, "Invalid passive threshold\n"); - tz->trips.passive.flags.valid =3D 0; + tz->trips.passive.valid =3D false; } else { - tz->trips.passive.flags.valid =3D 1; + tz->trips.passive.valid =3D true; } =20 if (memcmp(&tz->trips.passive.devices, &devices, @@ -351,24 +346,24 @@ static int acpi_thermal_trips_update(str } } if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) { - if (valid !=3D tz->trips.passive.flags.valid) + if (valid !=3D tz->trips.passive.valid) ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state"); } =20 /* Active (optional) */ for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { char name[5] =3D { '_', 'A', 'C', ('0' + i), '\0' }; - valid =3D tz->trips.active[i].flags.valid; + valid =3D tz->trips.active[i].valid; =20 if (act =3D=3D -1) break; /* disable all active trip points */ =20 if (flag =3D=3D ACPI_TRIPS_INIT || ((flag & ACPI_TRIPS_ACTIVE) && - tz->trips.active[i].flags.valid)) { + tz->trips.active[i].valid)) { status =3D acpi_evaluate_integer(tz->device->handle, name, NULL, &tmp); if (ACPI_FAILURE(status)) { - tz->trips.active[i].flags.valid =3D 0; + tz->trips.active[i].valid =3D false; if (i =3D=3D 0) break; =20 @@ -390,21 +385,21 @@ static int acpi_thermal_trips_update(str break; } else { tz->trips.active[i].temperature =3D tmp; - tz->trips.active[i].flags.valid =3D 1; + tz->trips.active[i].valid =3D true; } } =20 name[2] =3D 'L'; - if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid) { + if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].valid) { memset(&devices, 0, sizeof(struct acpi_handle_list)); status =3D acpi_evaluate_reference(tz->device->handle, name, NULL, &devices); if (ACPI_FAILURE(status)) { acpi_handle_info(tz->device->handle, "Invalid active%d threshold\n", i); - tz->trips.active[i].flags.valid =3D 0; + tz->trips.active[i].valid =3D false; } else { - tz->trips.active[i].flags.valid =3D 1; + tz->trips.active[i].valid =3D true; } =20 if (memcmp(&tz->trips.active[i].devices, &devices, @@ -415,10 +410,10 @@ static int acpi_thermal_trips_update(str } } if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES)) - if (valid !=3D tz->trips.active[i].flags.valid) + if (valid !=3D tz->trips.active[i].valid) ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state"); =20 - if (!tz->trips.active[i].flags.valid) + if (!tz->trips.active[i].valid) break; } =20 @@ -438,17 +433,18 @@ static int acpi_thermal_trips_update(str =20 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) { - int i, valid, ret =3D acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); + int i, ret =3D acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); + bool valid; =20 if (ret) return ret; =20 - valid =3D tz->trips.critical.flags.valid | - tz->trips.hot.flags.valid | - tz->trips.passive.flags.valid; + valid =3D tz->trips.critical.valid | + tz->trips.hot.valid | + tz->trips.passive.valid; =20 for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) - valid |=3D tz->trips.active[i].flags.valid; + valid =3D valid || tz->trips.active[i].valid; =20 if (!valid) { pr_warn(FW_BUG "No valid trip found\n"); @@ -485,7 +481,7 @@ static int thermal_get_trip_type(struct if (!tz || trip < 0) return -EINVAL; =20 - if (tz->trips.critical.flags.valid) { + if (tz->trips.critical.valid) { if (!trip) { *type =3D THERMAL_TRIP_CRITICAL; return 0; @@ -493,7 +489,7 @@ static int thermal_get_trip_type(struct trip--; } =20 - if (tz->trips.hot.flags.valid) { + if (tz->trips.hot.valid) { if (!trip) { *type =3D THERMAL_TRIP_HOT; return 0; @@ -501,7 +497,7 @@ static int thermal_get_trip_type(struct trip--; } =20 - if (tz->trips.passive.flags.valid) { + if (tz->trips.passive.valid) { if (!trip) { *type =3D THERMAL_TRIP_PASSIVE; return 0; @@ -509,7 +505,7 @@ static int thermal_get_trip_type(struct trip--; } =20 - for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.va= lid; i++) { + for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].valid; i= ++) { if (!trip) { *type =3D THERMAL_TRIP_ACTIVE; return 0; @@ -529,7 +525,7 @@ static int thermal_get_trip_temp(struct if (!tz || trip < 0) return -EINVAL; =20 - if (tz->trips.critical.flags.valid) { + if (tz->trips.critical.valid) { if (!trip) { *temp =3D deci_kelvin_to_millicelsius_with_offset( tz->trips.critical.temperature, @@ -539,7 +535,7 @@ static int thermal_get_trip_temp(struct trip--; } =20 - if (tz->trips.hot.flags.valid) { + if (tz->trips.hot.valid) { if (!trip) { *temp =3D deci_kelvin_to_millicelsius_with_offset( tz->trips.hot.temperature, @@ -549,7 +545,7 @@ static int thermal_get_trip_temp(struct trip--; } =20 - if (tz->trips.passive.flags.valid) { + if (tz->trips.passive.valid) { if (!trip) { *temp =3D deci_kelvin_to_millicelsius_with_offset( tz->trips.passive.temperature, @@ -560,7 +556,7 @@ static int thermal_get_trip_temp(struct } =20 for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE && - tz->trips.active[i].flags.valid; i++) { + tz->trips.active[i].valid; i++) { if (!trip) { *temp =3D deci_kelvin_to_millicelsius_with_offset( tz->trips.active[i].temperature, @@ -578,7 +574,7 @@ static int thermal_get_crit_temp(struct { struct acpi_thermal *tz =3D thermal_zone_device_priv(thermal); =20 - if (tz->trips.critical.flags.valid) { + if (tz->trips.critical.valid) { *temperature =3D deci_kelvin_to_millicelsius_with_offset( tz->trips.critical.temperature, tz->kelvin_offset); @@ -664,13 +660,13 @@ static int acpi_thermal_cooling_device_c int trip =3D -1; int result =3D 0; =20 - if (tz->trips.critical.flags.valid) + if (tz->trips.critical.valid) trip++; =20 - if (tz->trips.hot.flags.valid) + if (tz->trips.hot.valid) trip++; =20 - if (tz->trips.passive.flags.valid) { + if (tz->trips.passive.valid) { trip++; for (i =3D 0; i < tz->trips.passive.devices.count; i++) { handle =3D tz->trips.passive.devices.handles[i]; @@ -695,7 +691,7 @@ static int acpi_thermal_cooling_device_c } =20 for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { - if (!tz->trips.active[i].flags.valid) + if (!tz->trips.active[i].valid) break; =20 trip++; @@ -783,19 +779,19 @@ static int acpi_thermal_register_thermal acpi_status status; int i; =20 - if (tz->trips.critical.flags.valid) + if (tz->trips.critical.valid) trips++; =20 - if (tz->trips.hot.flags.valid) + if (tz->trips.hot.valid) trips++; =20 - if (tz->trips.passive.flags.valid) + if (tz->trips.passive.valid) trips++; =20 - for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.va= lid; + for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].valid; i++, trips++); =20 - if (tz->trips.passive.flags.valid) + if (tz->trips.passive.valid) tz->thermal_zone =3D thermal_zone_device_register("acpitz", trips, 0, tz, &acpi_thermal_zone_ops, NULL, tz->trips.passive.tsp * 100, @@ -965,7 +961,7 @@ static int acpi_thermal_get_info(struct */ static void acpi_thermal_guess_offset(struct acpi_thermal *tz) { - if (tz->trips.critical.flags.valid && + if (tz->trips.critical.valid && (tz->trips.critical.temperature % 5) =3D=3D 1) tz->kelvin_offset =3D 273100; else @@ -1074,20 +1070,20 @@ static int acpi_thermal_resume(struct de return -EINVAL; =20 for (i =3D 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { - if (!tz->trips.active[i].flags.valid) + if (!tz->trips.active[i].valid) break; =20 - tz->trips.active[i].flags.enabled =3D 1; + tz->trips.active[i].enabled =3D true; for (j =3D 0; j < tz->trips.active[i].devices.count; j++) { result =3D acpi_bus_update_power( tz->trips.active[i].devices.handles[j], &power_state); if (result || (power_state !=3D ACPI_STATE_D0)) { - tz->trips.active[i].flags.enabled =3D 0; + tz->trips.active[i].enabled =3D false; break; } } - tz->state.active |=3D tz->trips.active[i].flags.enabled; + tz->state.active |=3D tz->trips.active[i].enabled; } =20 acpi_queue_thermal_check(tz);