From patchwork Tue Oct 3 13:17:24 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: 147886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2084481vqb; Tue, 3 Oct 2023 06:27:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHW4DOZni63gasWkK4RI/HimHHHZWxRP/NJbWjKFB2KR9AIHDhu6wAD1p5EsuGZpTFr81f+ X-Received: by 2002:a17:903:228e:b0:1c6:2655:625d with SMTP id b14-20020a170903228e00b001c62655625dmr4391508plh.15.1696339643463; Tue, 03 Oct 2023 06:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696339643; cv=none; d=google.com; s=arc-20160816; b=hgLDuw9hhiKzAbjq8Tf57TXPPEdk401QhcHg1KxXjHs2KZfFMPFxim9pl85/drZ/xf SNGLXVmd05+10m2dKHugD4lOi2GcB7gWSHZHklWplYM/FYtfdw20Q3BbDUw8N2TGuBoj 3o9CWwIXXNfipGVWTcAy9eW60gfhI6x9HXsV4Rjr8GF+5jkLfIBXlEIBVyh88QB1xB1D 2RVeMmbS3MNT80Qzv7Q7RG/EblD13c679V9tpC0CRC6X8zlz8VFkykV+cm/FRhFFegvV 5J2RvqwBhQ/+QBjs4OAYrSEgn0ij3TjDSxWGEM/+8CQThsMVJJfmKOMhKeDchWVODiY4 vcNA== 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=haiupzOgPxi/70SZp9QWBMju4NpacQvbwzfcAABYpn0=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=Z7njV7Kn36mr50udolL6+ZK6uDywE5T5hR0lzz53x+2CNqblA1qhACSPcLvtm4CpBY ShzRdH/XsFvMp134aTO/Hnh3OGDCFml2dQ6oH/VM6RtXc7Daa8iu0b/7O1tUVN2vO8Tp QEHOlT31Vv3X85ANbJdNJtVTr6Bj99yrkeKeWTmQT5tLT6ftavcFqZedGRh+5CZRlavY WHh+di5kNVrktnprkRee6b9SQfv5/UOz8u2iQwkUINpFc/5dTQbtcFIRNZ7LIg9e8y0Y 6DntMV7OiNN4hfcxaSRuhPEJhMAz8kx3lqdbQDAR4krJ41rJRdxKRAq2gI1gtKhb1syd OlFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id b2-20020a170902650200b001bbf293f45esi1304069plk.625.2023.10.03.06.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 06:27:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 92085828F4E7; Tue, 3 Oct 2023 06:27:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236706AbjJCN1L (ORCPT + 17 others); Tue, 3 Oct 2023 09:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235542AbjJCN0z (ORCPT ); Tue, 3 Oct 2023 09:26:55 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 968F8B7; Tue, 3 Oct 2023 06:26:51 -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 9ed5a880723e25b6; Tue, 3 Oct 2023 15:26:50 +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 8DA4F6659AF; Tue, 3 Oct 2023 15:26:49 +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 1/6] thermal: core: Add function to walk trips under zone lock Date: Tue, 03 Oct 2023 15:17:24 +0200 Message-ID: <2169023.irdbgypaU6@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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 06:27:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778741038048861179 X-GMAIL-MSGID: 1778741038048861179 From: Rafael J. Wysocki Add a wrapper around for_each_thermal_trip(), called thermal_zone_for_each_trip(), that will invoke the former under the thermal zone lock and pass its return value to the caller. Two drivers will be modified subsequently to use this new function. No functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Daniel Lezcano --- v1 -> v2: Mo changes --- drivers/thermal/thermal_trip.c | 14 ++++++++++++++ include/linux/thermal.h | 3 +++ 2 files changed, 17 insertions(+) Index: linux-pm/drivers/thermal/thermal_trip.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_trip.c +++ linux-pm/drivers/thermal/thermal_trip.c @@ -27,6 +27,20 @@ int for_each_thermal_trip(struct thermal } EXPORT_SYMBOL_GPL(for_each_thermal_trip); +int thermal_zone_for_each_trip(struct thermal_zone_device *tz, + int (*cb)(struct thermal_trip *, void *), + void *data) +{ + int ret; + + mutex_lock(&tz->lock); + ret = for_each_thermal_trip(tz, cb, data); + mutex_unlock(&tz->lock); + + return ret; +} +EXPORT_SYMBOL_GPL(thermal_zone_for_each_trip); + int thermal_zone_get_num_trips(struct thermal_zone_device *tz) { return tz->num_trips; Index: linux-pm/include/linux/thermal.h =================================================================== --- linux-pm.orig/include/linux/thermal.h +++ linux-pm/include/linux/thermal.h @@ -287,6 +287,9 @@ int thermal_zone_set_trip(struct thermal int for_each_thermal_trip(struct thermal_zone_device *tz, int (*cb)(struct thermal_trip *, void *), void *data); +int thermal_zone_for_each_trip(struct thermal_zone_device *tz, + int (*cb)(struct thermal_trip *, void *), + void *data); int thermal_zone_get_num_trips(struct thermal_zone_device *tz); int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp); From patchwork Tue Oct 3 13:18:31 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: 147888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2084960vqb; Tue, 3 Oct 2023 06:28:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFthwWICs1lkqMKikqJGQWs5nI8lLpP+x3U4X0HplvWdCqW3qOtX+8yQhyM0JmpoAkxN8pE X-Received: by 2002:a05:6a20:f392:b0:15d:684d:f51b with SMTP id qr18-20020a056a20f39200b0015d684df51bmr11592427pzb.45.1696339691022; Tue, 03 Oct 2023 06:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696339691; cv=none; d=google.com; s=arc-20160816; b=KEyVe9BYrVo3S9rPofb9fmtc5eOra9R79F1DQOx0Q5pbCtuaGb+Ru88Syt4c3WDquu emGyApfnntrdfUUUQ/hvio3eDySqOzxwoNDc/I5cNi5uWq7NxnTCni5e3Ri0Y4UPymZM ONv9sxU96FDIGKd878kkmnOlEqNJU7F9kyC2HXFDP97gB58qx8Ea2sqGhxRE/XPvoWQx CuS7lZQbcUSFN8lug7WJrpFWmWLPSOxXSreh6bS6Sgz4I5Z5D826OsB9mzGl/FkYgJmS QkaUsUCC6AvmDgRdUMNABeeNA/fZImNr/IVIZ5vItBqTP+OgylvSSUMENmwfQXi79c3h qhoA== 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=Of8zPnJmr1nTMFa0X/9MEiLIrtoyvA7ZSmZqhYZg0lU=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=g44uo9s/H5XFEvdSW1aTBZGZoBBMJqf4R905Q5LH1+Xp2KF/dqXjfJgN0Fq3HKulSi KlzU1Ep/PX/0vF6OXj6b03/oENDAxeVNtMqpw0MbXzOgZA7371JQd21imoIMKzx4KAFQ u8lKRxghARKRw4VZ3de5XHziR2w4pw6aFWx6ucpeHIM6tGZfnOILePyjxGAU6FbrWrHn 1tkheKceBZMeW2/P95riNXlwCShm+liQBjFyC8cNl+LlAYppjpES3GQmpLzQuUirQdJx KvjieqDtCV9DX/vRioUDwhBz7TLLR+CZYUMmeuAXf15V3VUdaflmSm1M/jXb2t6gMlZH /d9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id r20-20020aa78b94000000b0068fcf6fe22esi1411432pfd.306.2023.10.03.06.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 06:28:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 75524801B8BD; Tue, 3 Oct 2023 06:28:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235896AbjJCN1P (ORCPT + 17 others); Tue, 3 Oct 2023 09:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235483AbjJCN0z (ORCPT ); Tue, 3 Oct 2023 09:26:55 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD09BD; Tue, 3 Oct 2023 06:26:50 -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 fee7940ee958ee86; Tue, 3 Oct 2023 15:26:49 +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 C63456659AF; Tue, 3 Oct 2023 15:26:48 +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 2/6] ACPI: thermal: Move get_active_temp() Date: Tue, 03 Oct 2023 15:18:31 +0200 Message-ID: <2913298.e9J7NaK4W3@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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 06:28:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778741087618300511 X-GMAIL-MSGID: 1778741087618300511 From: Rafael J. Wysocki Put the get_active_temp() function next to the analogous get_passive_temp() one to allow subsequent changes to be easier to follow. No functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano --- drivers/acpi/thermal.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) Index: linux-pm/drivers/acpi/thermal.c =================================================================== --- linux-pm.orig/drivers/acpi/thermal.c +++ linux-pm/drivers/acpi/thermal.c @@ -189,6 +189,29 @@ static long get_passive_temp(struct acpi return tmp; } +static long get_active_temp(struct acpi_thermal *tz, int index) +{ + char method[] = { '_', 'A', 'C', '0' + index, '\0' }; + unsigned long long tmp; + acpi_status status; + + status = acpi_evaluate_integer(tz->device->handle, method, NULL, &tmp); + if (ACPI_FAILURE(status)) + return THERMAL_TEMP_INVALID; + + /* + * If an override has been provided, apply it so there are no active + * trips with thresholds greater than the override. + */ + if (act > 0) { + unsigned long long override = celsius_to_deci_kelvin(act); + + if (tmp > override) + tmp = override; + } + return tmp; +} + static void acpi_thermal_update_passive_trip(struct acpi_thermal *tz) { struct acpi_thermal_trip *acpi_trip = &tz->trips.passive.trip; @@ -250,29 +273,6 @@ static void acpi_thermal_update_trip_dev ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); } -static long get_active_temp(struct acpi_thermal *tz, int index) -{ - char method[] = { '_', 'A', 'C', '0' + index, '\0' }; - unsigned long long tmp; - acpi_status status; - - status = acpi_evaluate_integer(tz->device->handle, method, NULL, &tmp); - if (ACPI_FAILURE(status)) - return THERMAL_TEMP_INVALID; - - /* - * If an override has been provided, apply it so there are no active - * trips with thresholds greater than the override. - */ - if (act > 0) { - unsigned long long override = celsius_to_deci_kelvin(act); - - if (tmp > override) - tmp = override; - } - return tmp; -} - static void acpi_thermal_update_active_trip(struct acpi_thermal *tz, int index) { struct acpi_thermal_trip *acpi_trip = &tz->trips.active[index].trip; 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++) From patchwork Tue Oct 3 13:24:12 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: 147885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2084339vqb; Tue, 3 Oct 2023 06:27:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFo05zZ+z6KM1dKdLPZDdrv9Su+nS3GOR8tX3WO+MkvVikLBwb1zUfTTcEuLV/gYh8krD7b X-Received: by 2002:a17:903:22d2:b0:1c7:245a:7fea with SMTP id y18-20020a17090322d200b001c7245a7feamr19474742plg.58.1696339627769; Tue, 03 Oct 2023 06:27:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696339627; cv=none; d=google.com; s=arc-20160816; b=HspO5aZZRVGy8L3nHmyne9lZSJXpI4PpA7B7sESeiOlb+QCCM4UDKWL2aZGdf6zadM ubJMZOf95MXEoGFeDV1QTM1+sq9F7bMSYjTd0rDopbVKmsVwrOSTtcmbFDHsafJdxZYG vzCdfLUY4zCqcHXcvn7UQjVTn1dc3pb5KIUSfDrY+6YPfYUJrbdx7CK3g1ekcrZ5oSoH WVQFUK5n6c9141BYKVh0B4GzYHQfKJIfTCq/81U2VCWZGVWAjepuz+PhrvZU/QInvEnq Z13G267PKZS0DZ81GJkIIUjOdEyX1KBOnRyAjH3eBepPrUnvg25y6U9ZToNb0jXaCqRu OwpA== 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=thkll1FSliX36Yg6ztkliLh5jkIqzUPBRz7zIsaLvAc=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=zRAYj6XV3Ozb1jTLCeSFCuny2xdVPHnweXuG0v5NoDjI4fBx+NtSqt+CKPLcrJJnU0 CJ4rWQUl95Q30yEuSjBzEQTMRPuW8Kq63XUdxmfwLE0bzRMM2Tm7/3s1G6qCa7Um5aZW fRcvzzWc028mWunUuql2ol8fdom68fEFKtPgf1EKAvhTU8QyCDUeODijnaNFzVrfLMS0 5OIQ1Cv2tn+GaID7eHTkpPzXJFNKJ214TSHjptj9N16Vsfg8s1m9F7fjhsF2mhCFT3bn BiJVsc/1BNloMoA+XYl/69aXsf/OVkLJHC8/RsGZTZVlGxVBghtc0SgxrIzQiYcJYTqx g1OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x14-20020a170902a38e00b001b222cd9826si1323986pla.349.2023.10.03.06.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 06:27:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id E85A8818F69B; Tue, 3 Oct 2023 06:27:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236100AbjJCN07 (ORCPT + 17 others); Tue, 3 Oct 2023 09:26:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234880AbjJCN0w (ORCPT ); Tue, 3 Oct 2023 09:26:52 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D237A7; 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 d9a2b773432a5c26; Tue, 3 Oct 2023 15:26:47 +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 37B3F6659AF; 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 4/6] ACPI: thermal: Use thermal_zone_for_each_trip() for updating trips Date: Tue, 03 Oct 2023 15:24:12 +0200 Message-ID: <1954465.PYKUYFuaPT@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: gggruggvucftvghtrhhoucdtuddrgedvkedrfeeigdeifecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphht thhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 06:27:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778741021523893857 X-GMAIL-MSGID: 1778741021523893857 From: Rafael J. Wysocki Rearrange the code handling notifications from the platform firmware regarding trip point updates to carry out one loop over trip points instead of two of them by using thermal_zone_for_each_trip() for that, which is more straightforward than using a combination of thermal_zone_device_exec() and for_each_thermal_trip(), each with its own callback function. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano --- v1 -> v2: * Rebase on top of the previous patches. * Add active_trip_index() for computing active trip point indices instead of storing them. --- drivers/acpi/thermal.c | 78 +++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 41 deletions(-) Index: linux-pm/drivers/acpi/thermal.c =================================================================== --- linux-pm.orig/drivers/acpi/thermal.c +++ linux-pm/drivers/acpi/thermal.c @@ -177,6 +177,15 @@ static bool acpi_thermal_trip_valid(stru return acpi_trip->temp_dk != THERMAL_TEMP_INVALID; } +static int active_trip_index(struct acpi_thermal *tz, + struct acpi_thermal_trip *acpi_trip) +{ + struct acpi_thermal_active *active; + + active = container_of(acpi_trip, struct acpi_thermal_active, trip); + return active - tz->trips.active; +} + static long get_passive_temp(struct acpi_thermal *tz) { unsigned long long tmp; @@ -213,21 +222,18 @@ static long get_active_temp(struct acpi_ } static void acpi_thermal_update_trip(struct acpi_thermal *tz, - int index) + const struct thermal_trip *trip) { - struct acpi_thermal_trip *acpi_trip; - - acpi_trip = index == ACPI_THERMAL_TRIP_PASSIVE ? - &tz->trips.passive.trip : &tz->trips.active[index].trip; - if (!acpi_thermal_trip_valid(acpi_trip)) - return; + struct acpi_thermal_trip *acpi_trip = trip->priv; - if (index == ACPI_THERMAL_TRIP_PASSIVE) { + if (trip->type == THERMAL_TRIP_PASSIVE) { if (psv > 0) return; acpi_trip->temp_dk = get_passive_temp(tz); } else { + int index = active_trip_index(tz, acpi_trip); + acpi_trip->temp_dk = get_active_temp(tz, index); } @@ -267,31 +273,39 @@ static bool update_trip_devices(struct a return true; } -static void acpi_thermal_update_trip_devices(struct acpi_thermal *tz, int index) +static void acpi_thermal_update_trip_devices(struct acpi_thermal *tz, + struct thermal_trip *trip) { - struct acpi_thermal_trip *acpi_trip; - - acpi_trip = index == ACPI_THERMAL_TRIP_PASSIVE ? - &tz->trips.passive.trip : &tz->trips.active[index].trip; - if (!acpi_thermal_trip_valid(acpi_trip)) - return; + struct acpi_thermal_trip *acpi_trip = trip->priv; + int index = trip->type == THERMAL_TRIP_PASSIVE ? + ACPI_THERMAL_TRIP_PASSIVE : active_trip_index(tz, acpi_trip); - if (update_trip_devices(tz, acpi_trip, index, true)) { + if (update_trip_devices(tz, acpi_trip, index, true)) return; - } acpi_trip->temp_dk = THERMAL_TEMP_INVALID; ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); } +struct adjust_trip_data { + struct acpi_thermal *tz; + u32 event; +}; + static int acpi_thermal_adjust_trip(struct thermal_trip *trip, void *data) { struct acpi_thermal_trip *acpi_trip = trip->priv; - struct acpi_thermal *tz = data; + struct adjust_trip_data *atd = data; + struct acpi_thermal *tz = atd->tz; - if (!acpi_trip) + if (!acpi_trip || !acpi_thermal_trip_valid(acpi_trip)) return 0; + if (atd->event == ACPI_THERMAL_NOTIFY_THRESHOLDS) + acpi_thermal_update_trip(tz, trip); + else + acpi_thermal_update_trip_devices(tz, trip); + if (acpi_thermal_trip_valid(acpi_trip)) trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); else @@ -300,25 +314,6 @@ static int acpi_thermal_adjust_trip(stru return 0; } -static void acpi_thermal_adjust_thermal_zone(struct thermal_zone_device *thermal, - unsigned long data) -{ - struct acpi_thermal *tz = thermal_zone_device_priv(thermal); - int i; - - if (data == ACPI_THERMAL_NOTIFY_THRESHOLDS) { - acpi_thermal_update_trip(tz, ACPI_THERMAL_TRIP_PASSIVE); - for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; 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++) - acpi_thermal_update_trip_devices(tz, i); - } - - for_each_thermal_trip(tz->thermal_zone, acpi_thermal_adjust_trip, tz); -} - static void acpi_queue_thermal_check(struct acpi_thermal *tz) { if (!work_pending(&tz->thermal_check_work)) @@ -327,17 +322,18 @@ static void acpi_queue_thermal_check(str static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event) { + struct adjust_trip_data atd = { .tz = tz, .event = event }; struct acpi_device *adev = tz->device; /* - * Use thermal_zone_device_exec() to carry out the trip points + * Use thermal_zone_for_each_trip() to carry out the trip points * update, so as to protect thermal_get_trend() from getting stale * trip point temperatures and to prevent thermal_zone_device_update() * invoked from acpi_thermal_check_fn() from producing inconsistent * results. */ - thermal_zone_device_exec(tz->thermal_zone, - acpi_thermal_adjust_thermal_zone, event); + thermal_zone_for_each_trip(tz->thermal_zone, + acpi_thermal_adjust_trip, &atd); acpi_queue_thermal_check(tz); acpi_bus_generate_netlink_event(adev->pnp.device_class, dev_name(&adev->dev), event, 0); From patchwork Tue Oct 3 13:25:33 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: 147883 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2084252vqb; Tue, 3 Oct 2023 06:26:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHy2w0CsLhRHk02k7KKYIwv3LAD1TGOgh1kQjiOVIaJZ66kOHb0YPpzWbGEkJuw+0TBVHND X-Received: by 2002:a05:6871:5ca:b0:1d6:7449:e0dc with SMTP id v10-20020a05687105ca00b001d67449e0dcmr14849153oan.20.1696339618753; Tue, 03 Oct 2023 06:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696339618; cv=none; d=google.com; s=arc-20160816; b=fumHPGPMW4234MlrCnwlFAQnWj/2saA7YucmTG37eT1pK+kGEm98HczfPOr0FpFWsh bM8qZpsjEoPU94VBEj9WoMsm2e+1Tz0Cxkz5sLlN1WmMpRolDTt+tmS5X+0SMmqtdzGB fTLgCjHBqmgsOvxHorjUb02wdot3czvXexG+bI5sKn/oSqf3NTtu2DD4al9sR/2Nz97L oneguyN+R+ZLGGh/nkkljjbuYActlZxHKFhzu3BM5w6xv2S5gcLoNtHDUOQ3px5GWhHn dB1U3Ff/AaAkYobZI0HqmWr64V0n92aYZWxQ8M88+0ii1GMww9KBkxc8xPotCYxYicd3 OAGA== 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=S3WsqdAYU0NkDrgQPIax3amh9m+YnubN5rgM8ynP5gI=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=GKpnuV8nilamGj19t9myN9bt7uV3/uyoekSRKGpAP51MUHtaPa85hl73eh/XOfmLGi uaXIqxHp8+zcpxz8h2JYFxS2kA/XewY0c6efulnSBkZNz2wtkihGzKTLdyYZfhIKV+Vn w895mQ9pUrXyIPSgdCLRLxzZAEtnL/s3WcKCoCYkJzfiDE+gSE3qcPJ4eauVTUDbLnmd 54pOocQYf0g/+N1f9+s7phBWL8lvpfZKdLosXGPa9QDvx5VaUWekXp6cit/rgW7DxioG EzMf6UJzn5zLODIucobOo7GC5+mvyaxz3F5T4wBM/EcgxY2mO9RGDKIH3gZdMG0h+yiy UZOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i4-20020a63e444000000b00563f72935e3si1366839pgk.608.2023.10.03.06.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 06:26:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E0FF8818F68D; Tue, 3 Oct 2023 06:26:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235428AbjJCN0y (ORCPT + 17 others); Tue, 3 Oct 2023 09:26:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234854AbjJCN0v (ORCPT ); Tue, 3 Oct 2023 09:26:51 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88FDFA3; Tue, 3 Oct 2023 06:26:48 -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 33a4cce9f7ccaff8; Tue, 3 Oct 2023 15:26:47 +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 6F4326659AF; Tue, 3 Oct 2023 15:26:46 +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 5/6] thermal: core: Drop thermal_zone_device_exec() Date: Tue, 03 Oct 2023 15:25:33 +0200 Message-ID: <7586518.EvYhyI6sBW@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: gggruggvucftvghtrhhoucdtuddrgedvkedrfeeigdeivdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphht thhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 06:26:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778741011830668077 X-GMAIL-MSGID: 1778741011830668077 From: Rafael J. Wysocki Because thermal_zone_device_exec() has no users any more and there are no plans to use it anywhere, revert commit 9a99a996d1ec ("thermal: core: Introduce thermal_zone_device_exec()") that introduced it. No functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano --- v1 -> v2: No changes --- drivers/thermal/thermal_core.c | 19 ------------------- include/linux/thermal.h | 4 ---- 2 files changed, 23 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -493,25 +493,6 @@ void thermal_zone_device_update(struct t } EXPORT_SYMBOL_GPL(thermal_zone_device_update); -/** - * thermal_zone_device_exec - Run a callback under the zone lock. - * @tz: Thermal zone. - * @cb: Callback to run. - * @data: Data to pass to the callback. - */ -void thermal_zone_device_exec(struct thermal_zone_device *tz, - void (*cb)(struct thermal_zone_device *, - unsigned long), - unsigned long data) -{ - mutex_lock(&tz->lock); - - cb(tz, data); - - mutex_unlock(&tz->lock); -} -EXPORT_SYMBOL_GPL(thermal_zone_device_exec); - static void thermal_zone_device_check(struct work_struct *work) { struct thermal_zone_device *tz = container_of(work, struct Index: linux-pm/include/linux/thermal.h =================================================================== --- linux-pm.orig/include/linux/thermal.h +++ linux-pm/include/linux/thermal.h @@ -340,10 +340,6 @@ int thermal_zone_unbind_cooling_device(s struct thermal_cooling_device *); void thermal_zone_device_update(struct thermal_zone_device *, enum thermal_notify_event); -void thermal_zone_device_exec(struct thermal_zone_device *tz, - void (*cb)(struct thermal_zone_device *, - unsigned long), - unsigned long data); struct thermal_cooling_device *thermal_cooling_device_register(const char *, void *, const struct thermal_cooling_device_ops *); From patchwork Tue Oct 3 13:26:35 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: 147884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2084280vqb; Tue, 3 Oct 2023 06:27:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/8f159XqZ1YqVFB9ecigqPzFeU+5CAZpBuCZP23HkIUpVUZoJpUWH+aqJIt6m9gS0RxPN X-Received: by 2002:a05:6870:b50e:b0:1d5:b4a0:dd3e with SMTP id v14-20020a056870b50e00b001d5b4a0dd3emr16041416oap.31.1696339621995; Tue, 03 Oct 2023 06:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696339621; cv=none; d=google.com; s=arc-20160816; b=QBuc4KsiQPLMpa5cFd7BNq3wYUeVa+WMZuB6stU46U4WV2THQyUOAvFkuBMpLI1b/K djENPifLnltjuvstjSjlXm1HoxTCzpWoVWg7IkrcrKb0Cdyge6h8uFfmsmokNncPJdVS JBm/NQE/wvx90oGqzE//4/I0Zpb1RhJZfI34KlJLYeX6sWJ7N7j7pnITnbEXa3YykJKP dMqigyVGJ/aXXiG8pZ+hN7+VWMVCop7R6AgoZ1tBlFcZyLbkaSP2agR0vFQMgtpTZykE n0Z8XXyuMx2DD8PhtIYWSp3nzQXWrAX4kJAvzWSYYBendmC8NtvCNfeLOnTbDtESDJhE 6raw== 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=BP0Uvu8UnC2lEkPqetz9kgVf6gBh1UhyRLFtIxvuoeI=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=E80xiCv0vanGj24seGO031k24GcXAypjIWczwCjnnwJ+15L1ecyYktKhl2MTUg1/5n kNgLVFwKW5GjKdpVdmqJe+IBjVaU1IbGjzZbg86EvTNdQwz9uoSjCTzdxO0+V7pqPQQ/ hCJEHM3bW6FQK1NpskPVqywsK1+KOPGli66P9EbNCgbOUit4sZAVBQl7YRCDhYUN2MYw IZN/8JzpVGot1Mvz3xDnyiPghoAHB4jtU3scD+sZHwGwUALuEugWd3duQaor6HO4GUY5 n3m5PvxhCuKi4TXG5UynqT4uTPY95ErUVCSdLvUtBrDDU+maoexPEt1Puu+tNHAEHq8I 2X6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q140-20020a632a92000000b0054402b987f8si1366042pgq.605.2023.10.03.06.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 06:27:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 266A3829BD4D; Tue, 3 Oct 2023 06:27:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235841AbjJCN04 (ORCPT + 17 others); Tue, 3 Oct 2023 09:26:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbjJCN0v (ORCPT ); Tue, 3 Oct 2023 09:26:51 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20F9BA1; Tue, 3 Oct 2023 06:26:47 -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 790a30df8c9ae96b; Tue, 3 Oct 2023 15:26:46 +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 B05B36659AF; Tue, 3 Oct 2023 15:26:45 +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 6/6] thermal: int340x: Use thermal_zone_for_each_trip() Date: Tue, 03 Oct 2023 15:26:35 +0200 Message-ID: <3532950.iIbC2pHGDl@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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 06:27:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778741015605498259 X-GMAIL-MSGID: 1778741015605498259 From: Rafael J. Wysocki Modify int340x_thermal_update_trips() to use thermal_zone_for_each_trip() for walking trips instead of using the trips[] table passed to the thermal zone registration function. For this purpose, store active trip point indices in the priv fieids of the corresponding thermal_trip structures. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano --- v1 -> v2: Mo changes --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 76 +++++------ 1 file changed, 41 insertions(+), 35 deletions(-) Index: linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -67,6 +67,16 @@ static struct thermal_zone_device_ops in .critical = int340x_thermal_critical, }; +static inline void *int_to_trip_priv(int i) +{ + return (void *)(long)i; +} + +static inline int trip_priv_to_int(const struct thermal_trip *trip) +{ + return (long)trip->priv; +} + static int int340x_thermal_read_trips(struct acpi_device *zone_adev, struct thermal_trip *zone_trips, int trip_cnt) @@ -101,6 +111,7 @@ static int int340x_thermal_read_trips(st break; zone_trips[trip_cnt].type = THERMAL_TRIP_ACTIVE; + zone_trips[trip_cnt].priv = int_to_trip_priv(i); trip_cnt++; } @@ -212,45 +223,40 @@ void int340x_thermal_zone_remove(struct } EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); -void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone) +static int int340x_update_one_trip(struct thermal_trip *trip, void *arg) { - struct acpi_device *zone_adev = int34x_zone->adev; - struct thermal_trip *zone_trips = int34x_zone->trips; - int trip_cnt = int34x_zone->zone->num_trips; - int act_trip_nr = 0; - int i; - - mutex_lock(&int34x_zone->zone->lock); - - for (i = int34x_zone->aux_trip_nr; i < trip_cnt; i++) { - int temp, err; - - switch (zone_trips[i].type) { - case THERMAL_TRIP_CRITICAL: - err = thermal_acpi_critical_trip_temp(zone_adev, &temp); - break; - case THERMAL_TRIP_HOT: - err = thermal_acpi_hot_trip_temp(zone_adev, &temp); - break; - case THERMAL_TRIP_PASSIVE: - err = thermal_acpi_passive_trip_temp(zone_adev, &temp); - break; - case THERMAL_TRIP_ACTIVE: - err = thermal_acpi_active_trip_temp(zone_adev, act_trip_nr++, - &temp); - break; - default: - err = -ENODEV; - } - if (err) { - zone_trips[i].temperature = THERMAL_TEMP_INVALID; - continue; - } + struct acpi_device *zone_adev = arg; + int temp, err; - zone_trips[i].temperature = temp; + switch (trip->type) { + case THERMAL_TRIP_CRITICAL: + err = thermal_acpi_critical_trip_temp(zone_adev, &temp); + break; + case THERMAL_TRIP_HOT: + err = thermal_acpi_hot_trip_temp(zone_adev, &temp); + break; + case THERMAL_TRIP_PASSIVE: + err = thermal_acpi_passive_trip_temp(zone_adev, &temp); + break; + case THERMAL_TRIP_ACTIVE: + err = thermal_acpi_active_trip_temp(zone_adev, + trip_priv_to_int(trip), + &temp); + break; + default: + err = -ENODEV; } + if (err) + temp = THERMAL_TEMP_INVALID; - mutex_unlock(&int34x_zone->zone->lock); + trip->temperature = temp; + return 0; +} + +void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone) +{ + thermal_zone_for_each_trip(int34x_zone->zone, int340x_update_one_trip, + int34x_zone->adev); } EXPORT_SYMBOL_GPL(int340x_thermal_update_trips);