Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2945525rdb; Mon, 4 Dec 2023 11:49:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbdv64CTMHql15RrDUq9qyMCSUbY3kTVAYV4DygwMdCT5WJHDVkPk54BlD25f6/EsE9Gp4 X-Received: by 2002:a17:902:7c98:b0:1d0:b794:b449 with SMTP id y24-20020a1709027c9800b001d0b794b449mr893956pll.60.1701719394191; Mon, 04 Dec 2023 11:49:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701719394; cv=none; d=google.com; s=arc-20160816; b=V20OEjJn9hL+XrrCKT+NEvLHU5dC7YnZXHPCA33J8Ww0tiqtbGrczxSQv5tn8UywF2 lZcWEBAqRJvqCDtxMEUdADnnKbyOflA56wpDF4p0YefVtFfQ/EL4oexTy9W2wQvvULf1 R0nMbYYj1Uq/4lUlVftpLSD8ki0FDHJrS5dwiz0XJvlNXYhYNFQ/09GdA9DMS3V8dYR5 tCd7WMsiyVh0HQDv1d1l5e5osDHy1V2WH5IcMzzrSumYpw9tWkbFMo6XC0tul60tx0F4 XXjBpN/TnBEh52D1z/AsSvTaXht3tq8GFdXqQyA9Jxg5FngL9zgr2Mi8PMqY/BZjK/pT 8r3A== 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=juaSekogoYVf+hrsOEZvpmWFC5IzVkTw7ZIY1TboTVg=; fh=nLypB3rvk504GacFIka1NRIrs+dxk/mQtlixTJ9Bzjw=; b=t5s1aW1vw0bAKiiItn77eSVUlI1ANWB/zW+oDr5g1+zrCUe+EARN8q4l9YZl4yFLb/ NwXJIjzH6aGl9k4FgMbICfjTk4JAMlbb3u3E3wJFlD1K6rHkniMBGaWGU+IhbQWp839u skTe3RoeJVpM61Zpftp3tqVDs7hlvoST8ism4gced/0+tiErUIeHIVUyjV0P7hN9ON41 +APIemIUuN3fgPG4PjsfeLQ0oMS+GNaTw2xSEdv0g9MjIKWqEoXNqLr+uP7l/J8wpj0i Ubg16Zf7aoVHmv5VT4EvQg5zp1czxG27km2kCEHCzzcfLIJXXlCb/fvBBG44OrPQG5sd PQ5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y4-20020a17090322c400b001cff290413bsi8529664plg.390.2023.12.04.11.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:49:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 AC52F809C14D; Mon, 4 Dec 2023 11:49:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233920AbjLDTt1 (ORCPT + 99 others); Mon, 4 Dec 2023 14:49:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233778AbjLDTtX (ORCPT ); Mon, 4 Dec 2023 14:49:23 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C5BD2; Mon, 4 Dec 2023 11:49:29 -0800 (PST) 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.4.0) id 201e36bf04c5bd52; Mon, 4 Dec 2023 20:49:28 +0100 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 BECDD668764; Mon, 4 Dec 2023 20:49:27 +0100 (CET) From: "Rafael J. Wysocki" To: Daniel Lezcano , Lukasz Luba Cc: Linux PM , LKML , Srinivas Pandruvada , Zhang Rui Subject: [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips() Date: Mon, 04 Dec 2023 20:41:30 +0100 Message-ID: <4529720.LvFx2qVVIh@kreacher> In-Reply-To: <5733564.DvuYhMxLoT@kreacher> References: <5733564.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: gggruggvucftvghtrhhoucdtuddrgedvkedrudejiedgudeftdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhr ihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhm 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,T_SCC_BODY_TEXT_LINE 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]); Mon, 04 Dec 2023 11:49:51 -0800 (PST) From: Rafael J. Wysocki Make __thermal_zone_set_trips() use for_each_trip() instead of an open- coded loop over trip indices. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_trip.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) Index: linux-pm/drivers/thermal/thermal_trip.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_trip.c +++ linux-pm/drivers/thermal/thermal_trip.c @@ -63,25 +63,21 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_num_t */ void __thermal_zone_set_trips(struct thermal_zone_device *tz) { - struct thermal_trip trip; + const struct thermal_trip *trip; int low = -INT_MAX, high = INT_MAX; bool same_trip = false; - int i, ret; + int ret; lockdep_assert_held(&tz->lock); if (!tz->ops->set_trips) return; - for (i = 0; i < tz->num_trips; i++) { + for_each_trip(tz, trip) { bool low_set = false; int trip_low; - ret = __thermal_zone_get_trip(tz, i , &trip); - if (ret) - return; - - trip_low = trip.temperature - trip.hysteresis; + trip_low = trip->temperature - trip->hysteresis; if (trip_low < tz->temperature && trip_low > low) { low = trip_low; @@ -89,9 +85,9 @@ void __thermal_zone_set_trips(struct the same_trip = false; } - if (trip.temperature > tz->temperature && - trip.temperature < high) { - high = trip.temperature; + if (trip->temperature > tz->temperature && + trip->temperature < high) { + high = trip->temperature; same_trip = low_set; } }