From patchwork Tue Sep 12 18:47:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 138380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp613450vqx; Tue, 12 Sep 2023 11:52:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEClmusU8250eMHjDYH332WPc2WD91QSt5X24uSeXKHMi5eP8TXcQbWot7Qk1zO2g2WWLZh X-Received: by 2002:a05:6a21:7988:b0:155:bff3:ea1d with SMTP id bh8-20020a056a21798800b00155bff3ea1dmr209480pzc.58.1694544769699; Tue, 12 Sep 2023 11:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694544769; cv=none; d=google.com; s=arc-20160816; b=yshVUlkmmPqGNOGj/O4Ksn6trSdCqFJyf7LA7I+0KyYgPEzIlgRczCyTAp49iXvy8s PkFYSF02+o3QKGvgGRJXNTzpQaRZ6xSJJJ+oPdN5m6wb0RfPWQkyix8sh+iA9zsSij4A 4HzQFoDW2bWiSxWKFIoOMrgNU0Z82rU4YZkU4Ukx7BagYsxNel4qpduDnKAy2bRWru1e FL5t7tIL1exKk+AnbkMkoAMmms8ices7M4MvlhS2GO4oLtQMrqh47zCTbx06cEY4Gp9y 0qJlxN1k6PsAZ4MlhKgtO1Aawca9JZTXbzCgx8P5jQGQMQg5wBr+cvMQGIYr1bIYnI2V Xr7w== 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=u0NTx4TLDXWUazZTrjRzmC9b6rF0xkRay09dimp/omc=; fh=TcRPROXzT9svfC8PL4GA9v01BlJpZsrjV4HRPcpqUxk=; b=LzDj/eYThZ5kuhRrhkqqb1Jcpzi7mv1XLxfVCw65J6Lvli+t/r49ro6nlWmBNkbr8l CmG9znz7eZ4B+2OCMvSOoOFUJtFe55VwTOpet4MMdejI94s7MHoOcQVKXx21bQMQY7+Q TaLddbLSjPp8tRG2OUIFp3ow6jlUB/XOtN+/XBVHYVlS2SFEI99Tnz4e2jpaCl2ZLNE5 FYZ8KjqITaPbZu2EmIACdoJj62HorpnFSvxEHbaAvC1nbJodiI/JT2egzsLd74Dxnimu JPgTHHUs+c22rYY5vLESod+A+eLWnr5pYACgLV7Nw0FjQekDQ2b1fNrWjv4WmJEv/Sr7 sJXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h5-20020a170902680500b001c3e3b19908si392210plk.485.2023.09.12.11.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 11:52:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A8D51825350A; Tue, 12 Sep 2023 11:47:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237450AbjILSrl (ORCPT + 36 others); Tue, 12 Sep 2023 14:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231382AbjILSrk (ORCPT ); Tue, 12 Sep 2023 14:47:40 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BEC810D3; Tue, 12 Sep 2023 11:47:36 -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 d591d3eab9350a03; Tue, 12 Sep 2023 20:47:33 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) 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 BAB64663C2D; Tue, 12 Sep 2023 20:47:32 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1 9/9] ACPI: thermal: Drop valid flag from struct acpi_thermal_trip Date: Tue, 12 Sep 2023 20:47:23 +0200 Message-ID: <9162925.CDJkKcVGEf@kreacher> In-Reply-To: <5708760.DvuYhMxLoT@kreacher> References: <5708760.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrudeiiedgudeftdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehs rhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 11:47:50 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776858976358408058 X-GMAIL-MSGID: 1776858976358408058 From: Rafael J. Wysocki Notice that the valid flag in struct acpi_thermal_trip is in fact redundant, because the temperature field of invalid trips is always equal to THERMAL_TEMP_INVALID, so drop it from there and adjust the code accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano Reviewed-by: Daniel Lezcano --- drivers/acpi/thermal.c | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) Index: linux-pm/drivers/acpi/thermal.c =================================================================== --- linux-pm.orig/drivers/acpi/thermal.c +++ linux-pm/drivers/acpi/thermal.c @@ -81,7 +81,6 @@ static struct workqueue_struct *acpi_the struct acpi_thermal_trip { unsigned long temperature; - bool valid; }; struct acpi_thermal_passive { @@ -175,11 +174,9 @@ static int acpi_thermal_temp(struct acpi tz->kelvin_offset); } -static void update_acpi_thermal_trip_temp(struct acpi_thermal_trip *acpi_trip, - int temp) +static bool acpi_thermal_trip_valid(struct acpi_thermal_trip *acpi_trip) { - acpi_trip->valid = temp != THERMAL_TEMP_INVALID; - acpi_trip->temperature = temp; + return acpi_trip->temperature != THERMAL_TEMP_INVALID; } static long get_passive_temp(struct acpi_thermal *tz) @@ -198,11 +195,11 @@ static void acpi_thermal_update_passive_ { struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip; - if (!acpi_trip->valid || psv > 0) + if (!acpi_thermal_trip_valid(acpi_trip) || psv > 0) return; - update_acpi_thermal_trip_temp(acpi_trip, get_passive_temp(tz)); - if (!acpi_trip->valid) + acpi_trip->temperature = get_passive_temp(tz); + if (!acpi_thermal_trip_valid(acpi_trip)) ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); } @@ -231,13 +228,13 @@ static void acpi_thermal_update_passive_ { struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip; - if (!acpi_trip->valid) + if (!acpi_thermal_trip_valid(acpi_trip)) return; if (update_passive_devices(tz, true)) return; - update_acpi_thermal_trip_temp(acpi_trip, THERMAL_TEMP_INVALID); + acpi_trip->temperature = THERMAL_TEMP_INVALID; ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); } @@ -268,11 +265,11 @@ static void acpi_thermal_update_active_t { struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip; - if (!acpi_trip->valid) + if (!acpi_thermal_trip_valid(acpi_trip)) return; - update_acpi_thermal_trip_temp(acpi_trip, get_active_temp(tz, index)); - if (!acpi_trip->valid) + acpi_trip->temperature = get_active_temp(tz, index); + if (!acpi_thermal_trip_valid(acpi_trip)) ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); } @@ -303,13 +300,13 @@ static void acpi_thermal_update_active_d { struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip; - if (!acpi_trip->valid) + if (!acpi_thermal_trip_valid(acpi_trip)) return; if (update_active_devices(tz, index, true)) return; - update_acpi_thermal_trip_temp(acpi_trip, THERMAL_TEMP_INVALID); + acpi_trip->temperature = THERMAL_TEMP_INVALID; ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); } @@ -321,7 +318,7 @@ static int acpi_thermal_adjust_trip(stru if (!acpi_trip) return 0; - if (acpi_trip->valid) + if (acpi_thermal_trip_valid(acpi_trip)) trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature); else trip->temperature = THERMAL_TEMP_INVALID; @@ -465,11 +462,11 @@ static bool acpi_thermal_init_passive_tr if (!update_passive_devices(tz, false)) goto fail; - update_acpi_thermal_trip_temp(&tz->trips.passive.trip, temp); + tz->trips.passive.trip.temperature = temp; return true; fail: - update_acpi_thermal_trip_temp(&tz->trips.passive.trip, THERMAL_TEMP_INVALID); + tz->trips.passive.trip.temperature = THERMAL_TEMP_INVALID; return false; } @@ -487,11 +484,11 @@ static bool acpi_thermal_init_active_tri if (!update_active_devices(tz, false, index)) goto fail; - update_acpi_thermal_trip_temp(&tz->trips.active[index].trip, temp); + tz->trips.active[index].trip.temperature = temp; return true; fail: - update_acpi_thermal_trip_temp(&tz->trips.active[index].trip, THERMAL_TEMP_INVALID); + tz->trips.active[index].trip.temperature = THERMAL_TEMP_INVALID; return false; } @@ -545,7 +542,7 @@ static int thermal_get_trend(struct ther return -EINVAL; acpi_trip = trip->priv; - if (!acpi_trip || !acpi_trip->valid) + if (!acpi_trip || !acpi_thermal_trip_valid(acpi_trip)) return -EINVAL; switch (trip->type) { @@ -618,7 +615,7 @@ static int acpi_thermal_cooling_device_c if (tz->trips.hot_valid) trip++; - if (tz->trips.passive.trip.valid) { + if (acpi_thermal_trip_valid(&tz->trips.passive.trip)) { trip++; for (i = 0; i < tz->trips.passive.devices.count; i++) { handle = tz->trips.passive.devices.handles[i]; @@ -643,7 +640,7 @@ static int acpi_thermal_cooling_device_c } for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { - if (!tz->trips.active[i].trip.valid) + if (!acpi_thermal_trip_valid(&tz->trips.active[i].trip)) break; trip++; @@ -949,7 +946,7 @@ static int acpi_thermal_add(struct acpi_ } acpi_trip = &tz->trips.passive.trip; - if (acpi_trip->valid) { + if (acpi_thermal_trip_valid(acpi_trip)) { passive_delay = tz->trips.passive.tsp * 100; trip->type = THERMAL_TRIP_PASSIVE; @@ -961,7 +958,7 @@ static int acpi_thermal_add(struct acpi_ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { acpi_trip = &tz->trips.active[i].trip; - if (!acpi_trip->valid) + if (!acpi_thermal_trip_valid(acpi_trip)) break; trip->type = THERMAL_TRIP_ACTIVE; @@ -1038,7 +1035,7 @@ static int acpi_thermal_resume(struct de return -EINVAL; for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { - if (!tz->trips.active[i].trip.valid) + if (!acpi_thermal_trip_valid(&tz->trips.active[i].trip)) break; for (j = 0; j < tz->trips.active[i].devices.count; j++) {