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);