Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp498820rdg; Thu, 12 Oct 2023 11:35:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfu03aQQWSg0klhDFnxu7BnmVEA3k6uBMdlti6oPNuertDSNKXG1OkSgYKNvlbrii3Y+tV X-Received: by 2002:a05:6358:5191:b0:164:8252:260d with SMTP id 17-20020a056358519100b001648252260dmr13623406rwk.24.1697135737647; Thu, 12 Oct 2023 11:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697135737; cv=none; d=google.com; s=arc-20160816; b=C33GxawTMkxxfgV5/YFUyjKPw6V6Y96WIRpMP77ZSuQ9qeT3VncrmEBG/FVTiEL3gU iD9q3qPGf9e9NcctPgUVq1U1mMWg5AZX7obCfmhesNHOz+M5gwMf+BFdKsucYKAEEXow rJeIzr9ywL6exOsK5P4Z3dSksFPfa31Y9FTrR64D3KwvPMQQ05YWhSCU8EZUcUSeUjIx bxFMXdBl0ga2TR6HqYe57w2PIrTZfBo32dkVIwjCyhmV1NUI/Dag4qTsAOjvUkiZ0sBZ xPiTfPAhTzxte3rbFerqjVxGC8sQn0Ibbb3yVc2aihDL7SgCL9ecmzqnApJzRUcscSf7 5qqg== 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=vsmbZ0urdhPPXlBdLIhvHy100HNiNyT2AI2msEOG2UA=; fh=7MtGe3Dn5wgXLQQm5DZb5OyhwmEFEEdRNCLYMJcP5yE=; b=rv0xbCjRs4S4hbWO+KuHVgdUilgqYnGzvpVAkq+4Wx2jIH9l4yHxid4nc/5yLVVPWf dzABWXtaqz8ZripyagAB97lSjseX3RkX+0VU5Sb90u5Jk7x2ZHpCHeuB5EJoXMdGPBi+ qdHhbSP5QSZmFnIM9amgVw0rkd5cR5f8OQSZGyWurhMa+I/c5T71+3Y2bRwYuZYyNsCb sE+8sIu2bqC5BH9TewffzC4OLXn7430r94/crGg1RohrtS+rlj45LVODINheEzQaY0yC HrvmwpNWlOtcCugk8K/Zb3fI7Lrkl+g2lLINuAMyZa/V1x6xK1yHC/gytTPWXFVKqd8j 4KDw== 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 Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id c10-20020a056a00248a00b0068ffda29587si15977250pfv.109.2023.10.12.11.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 11:35:37 -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 14B0681A0C12; Thu, 12 Oct 2023 11:35:35 -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 S1442009AbjJLSfO (ORCPT + 99 others); Thu, 12 Oct 2023 14:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441905AbjJLSfF (ORCPT ); Thu, 12 Oct 2023 14:35:05 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2143CB7; Thu, 12 Oct 2023 11:35: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 154efc8d398ecaea; Thu, 12 Oct 2023 20:35: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 cloudserver094114.home.pl (Postfix) with ESMTPSA id E56A0666869; Thu, 12 Oct 2023 20:35:01 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Srinivas Pandruvada , Zhang Rui , Lukasz Luba Subject: [PATCH v2 2/6] thermal: trip: Define for_each_trip() macro Date: Thu, 12 Oct 2023 20:26:46 +0200 Message-ID: <2316634.ElGaqSPkdT@kreacher> In-Reply-To: <5734364.DvuYhMxLoT@kreacher> References: <5734364.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedriedtgdduudeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepiedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgv lhdrtghomhdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 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]); Thu, 12 Oct 2023 11:35:35 -0700 (PDT) From: Rafael J. Wysocki Define a new macro for_each_trip() to be used by the thermal core code and thermal governors for walking trips in a given thermal zone. Modify for_each_thermal_trip() to use this macro instead of an open- coded loop over trips. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano --- v1 -> v2: * Rebase on top of current linux-next. * Add the tag from Daniel. --- drivers/thermal/thermal_core.h | 3 +++ drivers/thermal/thermal_trip.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.h =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.h +++ linux-pm/drivers/thermal/thermal_core.h @@ -116,6 +116,9 @@ void __thermal_zone_device_update(struct enum thermal_notify_event event); /* Helpers */ +#define for_each_trip(__tz, __trip) \ + for (__trip = __tz->trips; __trip - __tz->trips < __tz->num_trips; __trip++) + void __thermal_zone_set_trips(struct thermal_zone_device *tz); int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, struct thermal_trip *trip); Index: linux-pm/drivers/thermal/thermal_trip.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_trip.c +++ linux-pm/drivers/thermal/thermal_trip.c @@ -13,10 +13,11 @@ int for_each_thermal_trip(struct thermal int (*cb)(struct thermal_trip *, void *), void *data) { - int i, ret; + struct thermal_trip *trip; + int ret; - for (i = 0; i < tz->num_trips; i++) { - ret = cb(&tz->trips[i], data); + for_each_trip(tz, trip) { + ret = cb(trip, data); if (ret) return ret; }