From patchwork Tue Oct 3 13:21:30 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: 147887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2084745vqb; Tue, 3 Oct 2023 06:27:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgKfgPrtAXzpMSD5tY81deA54yV5eGQyJiStsRaM6CGKkP8tsIaeICil1InXXgwnWsehHF X-Received: by 2002:a17:902:7445:b0:1c5:ce3c:c399 with SMTP id e5-20020a170902744500b001c5ce3cc399mr15740521plt.39.1696339669412; Tue, 03 Oct 2023 06:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696339669; cv=none; d=google.com; s=arc-20160816; b=jFH+3/Bn1Y+xjyvGH+D8YF0rUQx3K+BTgS+kRP6ePvQpnWxIWZm18JcCyBQg/uOCms 6fhC1LlDIKx/IKxH11mkiTtjzyQctmKMzJBbje2INGe99ys9diIwmwTjkfuPE3rZD0R+ ppeFJhryUx70HBqV8s51RnsrOErcOPW6snEhSWgxNPBQuCypzXokbWDc5gUl7HBGEBsi IG02ZbEa8UovhSIsrcWxgfyb8JiTTeMYm+3M4GRMLpqVP6SvPHJFfCZBmk2YFRUwMuUZ ySWM8xTTzn8jTdcEJmBa3rV8ccoJA8wOoZmknskuDYy3wlqNHJJGMZuPeL2Nxy2yCj/2 89jg== 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=iYp9X/9qLzj0NuqTxh6JQrSwudqJxB7COP4ONX7aUxs=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=dgaCsI2MhwYKHvyQL0IuciGUsZffke3Flh292KtCBQwwVH2iOFumLiZFV7tmHFUMHr SE9ylsOwzupblvgJH8c3ztrtB7IRzE86oPWWWpaGKL5Qkrn0gjnd1dJni7ttEFwWn2ek d4QtziobUsUItlabyC2sssmJJIp+FEkVoe2mAomjslc6GRKaMoyjFlPopG9Xtnk5LHXx 9n5VwW4pYc68oT7zfMyLONbBPyYowEAZWArP1ncDnop6DpX0Zx9p5efsOjLem7sUwCDW /VjHvTkuXtvZL04qdsoISW/gGBDC9xF0V7oRaPPkcbC4f6oR+Uqj/9UpNuJstHcllgXk XE2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id i1-20020a170902c94100b001c76a06b5b5si1528380pla.298.2023.10.03.06.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 06:27:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 900D58135610; Tue, 3 Oct 2023 06:27:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235334AbjJCN1C (ORCPT + 17 others); Tue, 3 Oct 2023 09:27:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235077AbjJCN0x (ORCPT ); Tue, 3 Oct 2023 09:26:53 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06C5AAB; Tue, 3 Oct 2023 06:26:49 -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 a243c055453c96a8; Tue, 3 Oct 2023 15:26:48 +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 F01D96659AF; Tue, 3 Oct 2023 15:26:47 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Daniel Lezcano , Zhang Rui , Srinivas Pandruvada , "Rafael J. Wysocki" Subject: [PATCH v2 3/6] ACPI: thermal: Combine passive and active trip update functions Date: Tue, 03 Oct 2023 15:21:30 +0200 Message-ID: <8288399.T7Z3S40VBb@kreacher> In-Reply-To: <4846448.GXAFRqVoOG@kreacher> References: <4846448.GXAFRqVoOG@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: gggruggvucftvghtrhhoucdtuddrgedvkedrfeeigdeifecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphht thhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 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 agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 06:27:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778741064896355285 X-GMAIL-MSGID: 1778741064896355285 From: Rafael J. Wysocki Combine acpi_thermal_update_passive_trip() and acpi_thermal_update_active_trip() into one common function called acpi_thermal_update_trip(), so as to reduce code duplication and prepare the code in question for subsequent changes. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Daniel Lezcano --- drivers/acpi/thermal.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) Index: linux-pm/drivers/acpi/thermal.c =================================================================== --- linux-pm.orig/drivers/acpi/thermal.c +++ linux-pm/drivers/acpi/thermal.c @@ -212,14 +212,25 @@ static long get_active_temp(struct acpi_ return tmp; } -static void acpi_thermal_update_passive_trip(struct acpi_thermal *tz) +static void acpi_thermal_update_trip(struct acpi_thermal *tz, + int index) { - struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip; + struct acpi_thermal_trip *acpi_trip; - if (!acpi_thermal_trip_valid(acpi_trip) || psv > 0) + acpi_trip = index == ACPI_THERMAL_TRIP_PASSIVE ? + &tz->trips.passive.trip : &tz->trips.active[index].trip; + if (!acpi_thermal_trip_valid(acpi_trip)) return; - acpi_trip->temp_dk = get_passive_temp(tz); + if (index == ACPI_THERMAL_TRIP_PASSIVE) { + if (psv > 0) + return; + + acpi_trip->temp_dk = get_passive_temp(tz); + } else { + acpi_trip->temp_dk = get_active_temp(tz, index); + } + if (!acpi_thermal_trip_valid(acpi_trip)) ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); } @@ -273,18 +284,6 @@ static void acpi_thermal_update_trip_dev ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); } -static void acpi_thermal_update_active_trip(struct acpi_thermal *tz, int index) -{ - struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip; - - if (!acpi_thermal_trip_valid(acpi_trip)) - return; - - acpi_trip->temp_dk = get_active_temp(tz, index); - if (!acpi_thermal_trip_valid(acpi_trip)) - ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); -} - static int acpi_thermal_adjust_trip(struct thermal_trip *trip, void *data) { struct acpi_thermal_trip *acpi_trip = trip->priv; @@ -308,9 +307,9 @@ static void acpi_thermal_adjust_thermal_ int i; if (data == ACPI_THERMAL_NOTIFY_THRESHOLDS) { - acpi_thermal_update_passive_trip(tz); + acpi_thermal_update_trip(tz, ACPI_THERMAL_TRIP_PASSIVE); for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) - acpi_thermal_update_active_trip(tz, i); + acpi_thermal_update_trip(tz, i); } else { acpi_thermal_update_trip_devices(tz, ACPI_THERMAL_TRIP_PASSIVE); for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)