From patchwork Mon Oct 2 17:59: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: 147417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1608897vqb; Mon, 2 Oct 2023 11:19:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeKtmlJFhvByAGhQD2hz+PABFtNXf0CWh8DU7ilNVNGeyPBcQHeJjORnruVEIJWXDz/gBI X-Received: by 2002:a05:6870:8329:b0:1d5:d899:a9c1 with SMTP id p41-20020a056870832900b001d5d899a9c1mr13575944oae.37.1696270787560; Mon, 02 Oct 2023 11:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696270787; cv=none; d=google.com; s=arc-20160816; b=shEXnTpRVfgagu/39ZrUu/hsaZjY8CqBJmcNi0aDQfW/zw9n40uon0FnZVGS/ndWcz 2wR6eOpB+m9rOs0KUic2wXxNei/VLcTCivzQ/+sqU5F+stR7uJ1KhkphIM2PnFv4ahyx QoZ6GoGqBMSHgalabZcfpYKkgRIhxbm5TibFuIK+AcSJincNu+/C4wTtJ1duelD0qHqK N7c0HQ/5YXBDYBuZ0Z1KUFslRR/3nK9bUHoyEFhdoYSTS7oZU7tbw5/TWVPognBd2s09 bbbr3jvAgvc6ayTtqSmk9yeP4pshBoNn5sqD7fbtMSZtGOV/tmNPkHT+IPxVsKzknQvi woeg== 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=REXTRFYAUL17xjAwSySiCko7WZTzsoPXZFGu0zbBg7g=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=v9m1N7PUW9fdX9L7NsBkN/18BFWtNpHTxrWHVZuBEsuUKIk9TPKFOX34kCXLcYvX1F Ek9Ey9S51scyAaIBkO7NLn9ciN4WKeNUCmHXvqb6PwRhOC6ErDH9yP652/K67ML+Ueqe rAmiMHYecp9VKfUinvdOaMm3RdhyS4Rs7Xq/2Nlmy0Xl1o9EAr9Unmg4buyFABL92u72 qTXVGL4QJ7UJNcQq+4TNCmu05L8u+z6A6P65CDtFyzJHza+WnSOGSthjzFqJA0DOqXoZ eK0HPCR6cc4Q2+/ccjoMOuxAVO/rbibg8QeufzkuoaaG0Wsv564bZ53N9gj7jznFYwkK hcpg== 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 l25-20020a635b59000000b0056c403cd155si8077251pgm.596.2023.10.02.11.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 11:19:47 -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 5A6FA80AEE19; Mon, 2 Oct 2023 11:04:24 -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 S238746AbjJBSEQ (ORCPT + 18 others); Mon, 2 Oct 2023 14:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238706AbjJBSEJ (ORCPT ); Mon, 2 Oct 2023 14:04:09 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D637C4; Mon, 2 Oct 2023 11:04:06 -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 0e4c9e098fc70d13; Mon, 2 Oct 2023 20:04:04 +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 5035D6658DF; Mon, 2 Oct 2023 20:04:04 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Daniel Lezcano , Zhang Rui , Srinivas Pandruvada , "Rafael J. Wysocki" Subject: [PATCH v1 1/4] thermal: core: Add function to walk trips under zone lock Date: Mon, 02 Oct 2023 19:59:35 +0200 Message-ID: <2306658.ElGaqSPkdT@kreacher> In-Reply-To: <4871671.31r3eYUQgx@kreacher> References: <4871671.31r3eYUQgx@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: gggruggvucftvghtrhhoucdtuddrgedvkedrvdelgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghp thhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhm 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,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]); Mon, 02 Oct 2023 11:04:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778668837157784277 X-GMAIL-MSGID: 1778668837157784277 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 --- 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 Mon Oct 2 18:00:20 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: 147419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1609820vqb; Mon, 2 Oct 2023 11:21:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOlSgeDXGYzUxHcYbMVR3/XnqmkrgeLSrTx3AZJ5qyuteRHW/e+p/TEx8qihcgbnmAKG4q X-Received: by 2002:a05:6a20:3d26:b0:163:d382:ba99 with SMTP id y38-20020a056a203d2600b00163d382ba99mr8078008pzi.5.1696270895298; Mon, 02 Oct 2023 11:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696270895; cv=none; d=google.com; s=arc-20160816; b=VSMXK3VjQbhy7aGxo5q30zRXBRaLhmFoDc/NMyBZd2BG/hOyp5ISZOhpgKKF9NJIGh 2+E30HvTwDNl5LRgZ8okSZqv8WoFuYskmW2hahpl8/+LDihwxb90HSlhCAWNN4yDC811 bLqUIwN3pPbEzEJCAX4y2W6qOtcZnlUnkBc3VTwUir42oRpFe77weUL312V+/rD+CrHQ mR1jfRWcFkWvnLKt8nCfHVkjfk26CvuhOAcCVYFAVLMLPO/KVJfHj63EKbPLLa9Pxkqb GHKuWQPNDPvatmqNX/vMB0Gm8uV9vnw3+3aHbJpzPkElY3MdZZcbXOkd60gxIJe2tNuD RyzQ== 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=TVPcBw3hSCD0/SdQ3I25n92l15/FtUZsB8/xcubWJe4=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=dUKl6OG3c79rdiN9ZrbCDK9oKlI8h5MgMMy+p15A/uTnAo8COBoOoWNrEYliMUlMcg KzWmpimI01J4SBFY+LWmdWVJS1Ux9hR7ip27CBGmWV2wtXCRGKuwfLE6dsXQV4i4cF0W KcNydVNAH4z/pH87WJ9sxHxO8esMzlsBh2R3gkO2liPbuTLm5gcIgYB7nRCpmrkAZa81 rHxc7eGMc9biEBKWzRSctFllo4Za73JmIC/kpQaOdzpuXNv1oz8aLi0GWq0cka70+dAh gjT6BdIUBeadMcMVR47Rs8prxN8YJMX16afAKBzR2p64mWC2acQvfkkuvbpAK8XAAgKF /HQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id t64-20020a628143000000b0069023e4bcb4si25337455pfd.114.2023.10.02.11.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 11:21:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 39BC18083E76; Mon, 2 Oct 2023 11:05:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238741AbjJBSEO (ORCPT + 18 others); Mon, 2 Oct 2023 14:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238708AbjJBSEJ (ORCPT ); Mon, 2 Oct 2023 14:04:09 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CA65AC; Mon, 2 Oct 2023 11:04:05 -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 86a8d004266c595f; Mon, 2 Oct 2023 20:04:04 +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 88BE16658DF; Mon, 2 Oct 2023 20:04:03 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Daniel Lezcano , Zhang Rui , Srinivas Pandruvada , "Rafael J. Wysocki" Subject: [PATCH v1 2/4] ACPI: thermal: Use thermal_zone_for_each_trip() Date: Mon, 02 Oct 2023 20:00:20 +0200 Message-ID: <1873286.tdWV9SEqCh@kreacher> In-Reply-To: <4871671.31r3eYUQgx@kreacher> References: <4871671.31r3eYUQgx@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: gggruggvucftvghtrhhoucdtuddrgedvkedrvdelgdduvddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghp thhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhm 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 02 Oct 2023 11:05:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778668950610604433 X-GMAIL-MSGID: 1778668950610604433 From: Rafael J. Wysocki Rearrange the code handling notifications from the platform firmware to carry out one loop over trip points instead of two and use thermal_zone_for_each_trip() for that, which is more straightforward that 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 --- drivers/acpi/thermal.c | 58 +++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 26 deletions(-) Index: linux-pm/drivers/acpi/thermal.c =================================================================== --- linux-pm.orig/drivers/acpi/thermal.c +++ linux-pm/drivers/acpi/thermal.c @@ -95,6 +95,7 @@ struct acpi_thermal_passive { struct acpi_thermal_active { struct acpi_thermal_trip trip; + int index; }; struct acpi_thermal_trips { @@ -285,14 +286,36 @@ static void acpi_thermal_update_active_t 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) return 0; + if (trip->type == THERMAL_TRIP_PASSIVE) { + if (atd->event == ACPI_THERMAL_NOTIFY_THRESHOLDS) + acpi_thermal_update_passive_trip(tz); + else + acpi_thermal_update_trip_devices(tz, ACPI_THERMAL_TRIP_PASSIVE); + } else { + /* Since acpi_trip is present, this must be an active trip. */ + struct acpi_thermal_active *active; + + active = container_of(acpi_trip, struct acpi_thermal_active, trip); + if (atd->event == ACPI_THERMAL_NOTIFY_THRESHOLDS) + acpi_thermal_update_active_trip(tz, active->index); + else + acpi_thermal_update_trip_devices(tz, active->index); + } + if (acpi_thermal_trip_valid(acpi_trip)) trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); else @@ -301,25 +324,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_passive_trip(tz); - for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) - acpi_thermal_update_active_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)) @@ -328,17 +332,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); @@ -466,11 +471,12 @@ static int acpi_thermal_get_trip_points( count++; for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { - if (acpi_thermal_init_trip(tz, i)) + if (acpi_thermal_init_trip(tz, i)) { + tz->trips.active[i].index = i; count++; - else + } else { break; - + } } while (++i < ACPI_THERMAL_MAX_ACTIVE) From patchwork Mon Oct 2 18:02:28 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: 147415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1607937vqb; Mon, 2 Oct 2023 11:17:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+fjsaWCM1q8HnU5EUBtj3KlKOOXNdPgUxPVcKIGG82gtOJ2kXIoY+ZuWG92FPuL0SZBvg X-Received: by 2002:a17:903:2446:b0:1bb:83ec:832 with SMTP id l6-20020a170903244600b001bb83ec0832mr14152379pls.2.1696270670199; Mon, 02 Oct 2023 11:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696270670; cv=none; d=google.com; s=arc-20160816; b=zp0CVCai23aKHrMFJbNsC5fRK5ZuZga/Zpu1InbWMXGNiTseIx00335hix1MHN1a1Q TKwDJZ/Jk18Emkf3hNqgHO/YTSrxTUa1jZpRTCdnHh+89zke4U6UfgowA6BORcxqXiey G+KJISoigp1DvxZHUuJtre93jA68oE7lj/SyHuWK4dJ7ZdWChEvXkmqHiBhwr4TOY3bv Kt5IGQrYkgGkyq53BwPS1c7IB6ImcO7TPMFPE3081SDDPd9UxqPMCFRlNZuaOVSWiiz+ lU4XRL+X270N7HUl7uBj+SK8iK7bZqRbixc1wWhXVCmbnI98VfD9MjqzsPlW7797OoUL cjsw== 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=5bWI01ScoIsnhDusfyiUkNu6OFVpv693azUrMWkIsaw=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=hSQD3592vVG6Pr9HlYcnRGzqmSzKFxtv7W76xj/791eiPm3G7XQNaG6XhLSfiMLAmk Zl6erEt8dJxIQJCyHivR91GDKR+i5y52w0uazTjVg1e9vn3Y7eleTbrMt38tq8Z0SNGQ WRCg/xABZjWuQ8+ZeGzVxhH/q04nGemaufm52EZLd66eiQ9VJZu6PNSpy1hBO/04TdnC U6bT9k0VixiUqfxhp6gCXLQY5kIK4eGRuQMScxrnjTj2n/eIEEVGFdblB7svDVVLbWW2 6bhddqhoEazNWPtta/D4B0OaKkl80SdQX0Zt+kWneNgiegVCrplNDTWwrZ8lsUHHqDNo 5FSw== 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:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w3-20020a170902e88300b001c574110eecsi3642999plg.341.2023.10.02.11.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 11:17:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 2F3F68035AED; Mon, 2 Oct 2023 11:04:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238709AbjJBSEJ (ORCPT + 18 others); Mon, 2 Oct 2023 14:04:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238683AbjJBSEH (ORCPT ); Mon, 2 Oct 2023 14:04:07 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA2BE9B; Mon, 2 Oct 2023 11:04:04 -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 3fad41435fcd9097; Mon, 2 Oct 2023 20:04:03 +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 B40456658DF; Mon, 2 Oct 2023 20:04:02 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Daniel Lezcano , Zhang Rui , Srinivas Pandruvada , "Rafael J. Wysocki" Subject: [PATCH v1 3/4] thermal: core: Drop thermal_zone_device_exec() Date: Mon, 02 Oct 2023 20:02:28 +0200 Message-ID: <13367754.uLZWGnKmhe@kreacher> In-Reply-To: <4871671.31r3eYUQgx@kreacher> References: <4871671.31r3eYUQgx@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: gggruggvucftvghtrhhoucdtuddrgedvkedrvdelgdduvddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghp thhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhm 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 02 Oct 2023 11:04:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778668714074970003 X-GMAIL-MSGID: 1778668714074970003 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 --- 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 Mon Oct 2 18:03:42 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: 147416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1608362vqb; Mon, 2 Oct 2023 11:18:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyVTTfyuMsib1qjZgaP3hQHx+SE4xPG2oOFNvF0RLbXtZukzVBf3/RowgygUsiUw8g+mDX X-Received: by 2002:a05:6a00:14c9:b0:693:3783:4a29 with SMTP id w9-20020a056a0014c900b0069337834a29mr10995383pfu.20.1696270722744; Mon, 02 Oct 2023 11:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696270722; cv=none; d=google.com; s=arc-20160816; b=lnHvp2FQD9iiEDjTOK/wa9iOYgkB+F3e1yQSbLZqD4ZOurTDF1RSVf5z+yVyBpN/UM mQ7avrTSbvtI+kv1pcldb62fZPxEm4PFwIfyoPrbruq1XuJs4N/wZHU43gArCOWJpwpE QYBObVIwuf1OfjUGoqlA0mC+SwF+0qdzmNlREww6q8R3MiUdeJCGvXQqZ0BkZBQoX1i5 myLIJCmwFVzq+3a0+PGKQ9u4N99YrhizP1rAyr1Cnw0uPMsIfVdUEJGnYUfvZdOehuc3 C2cNUGcOqiUYfBtz7R57o5a2sWQylq7wN8CYfiIRzcXQOzC8aVCifAW7ZeIMrTKw1aeL 6bdg== 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=0WrVbHMF0V3I4XpZePtPuGnetDMux/b+6sVvfpR2Gt0=; fh=99EXAs+vKBd0HJG3OZyygM2izuzSBDrYNgeLDvqQNA4=; b=xycrbJTvHlIMz42av9Zq3Jxb0o1OUvHuosNBfg0G+ieU+LElmjzLC7s11DRqze99yl 6I3BEW5WUfh8H2WeN2kftBYao71+sAxBIrETibe4mZyfH+iQTR2vl50B85nPrvAiIm7u DMHN+69ST/fu0gGvz1zTlNFDGMfTxTcDv0dgfcixep++MxCTu2K6aGvr/qj5bAUXNHN0 GfIXUtszmUY6KURZKudWQ3VvX5/wATX/3mjiEu45UGhInyFj/v0BNthlmV2haUqLPU+6 ESh/+apgg6nS9vF1oN5bR954RIHdaiImYgWbPC9RTyg7UiFNN6+UeBtWJ6nIrwimy+YW 80/g== 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 eg6-20020a056a00800600b0068fefb0c039si27702542pfb.99.2023.10.02.11.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 11:18:42 -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 324E68042A8E; Mon, 2 Oct 2023 11:04:20 -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 S238729AbjJBSEL (ORCPT + 18 others); Mon, 2 Oct 2023 14:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238697AbjJBSEH (ORCPT ); Mon, 2 Oct 2023 14:04:07 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BA13B4; Mon, 2 Oct 2023 11:04:03 -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 323f4ac4e097ed97; Mon, 2 Oct 2023 20:04:02 +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 ACC1D6658DF; Mon, 2 Oct 2023 20:04:01 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Daniel Lezcano , Zhang Rui , Srinivas Pandruvada , "Rafael J. Wysocki" Subject: [PATCH v1 4/4] thermal: int340x: Use thermal_zone_for_each_trip() Date: Mon, 02 Oct 2023 20:03:42 +0200 Message-ID: <3260859.aeNJFYEL58@kreacher> In-Reply-To: <4871671.31r3eYUQgx@kreacher> References: <4871671.31r3eYUQgx@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: gggruggvucftvghtrhhoucdtuddrgedvkedrvdelgdduvddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghp thhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhm 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,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]); Mon, 02 Oct 2023 11:04:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778668769676081814 X-GMAIL-MSGID: 1778668769676081814 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 --- 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);