From patchwork Mon Dec 4 19:41: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: 173550 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2999006vqy; Mon, 4 Dec 2023 11:49:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXj+7p+Qx6XYz1Zhs7YROEc0zA8z4CzuK3bYVoPP78xg9cNqQ03aXQaSozo0uynZbPQxfM X-Received: by 2002:a05:6358:33a5:b0:16e:1085:cd0 with SMTP id i37-20020a05635833a500b0016e10850cd0mr5895099rwd.22.1701719389179; Mon, 04 Dec 2023 11:49:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701719389; cv=none; d=google.com; s=arc-20160816; b=Kko9Fnqh3UMqDeyIPY7N47eW2q6ZJoFaSh65DSEa7whUKPscKwIT4+npBtCYAzKRdV YJncPrrU/NFspW/p4ZaFiE7li2IrEGt3oG2H8LpgoO6nh+08oo6RAvUMwb/RY91lDlGw N2RZJu99i9rw+5FaB96WsZy1bX1UK0O9ocFd0K4nKOs6nzb/Sdq/jp/x9lBp1IQCPAJk uQE5M27+qhd8vPOzil2Cuk3B9WdRk3SV6v538Kf/E57cDF9OPM/NR/uI2bBcmiFvtWqQ auy7TjSKRNZUdy/qhAk0OJXRUNnB4mGTl3RtNuXpEVlADLCGQ3rWN9t9up0jeWkyZUai 1sow== 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 Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id k19-20020a63f013000000b005c5f5194e56si3200876pgh.372.2023.12.04.11.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:49:49 -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 A2F33809C151; Mon, 4 Dec 2023 11:49:43 -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 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:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784382109981046105 X-GMAIL-MSGID: 1784382109981046105 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 Acked-by: Daniel Lezcano --- 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; } } From patchwork Mon Dec 4 19:46: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: 173549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2998977vqy; Mon, 4 Dec 2023 11:49:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IH089iwfrYXnLAZU+/eT8reMPwPQuneiHP0dXOj+o7yEkJC0MJ/HAaMQST9MiqN4jVxMK0p X-Received: by 2002:a05:6a00:23c9:b0:6ce:4ed9:bd21 with SMTP id g9-20020a056a0023c900b006ce4ed9bd21mr105202pfc.9.1701719382282; Mon, 04 Dec 2023 11:49:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701719382; cv=none; d=google.com; s=arc-20160816; b=UvlIYdssChc7AYGp+yhh9RkbVet61UpgiS4zywyCeC8XqpBGFWL4BnoObWCS+JslLJ +KMMWe8i35oyZecscAabXrdG5AcScXPvSDA68SandtgQL1JklIoIulzLFKy6h51+bgyk rTjHfDJJKbudgb48JZY17YhzX4Sdyq9wI6Csjz5YwDlWqYfw14FO5LJEeGl23WT7T9HZ L9Ge5AjEVf0nTw+ECrDgNRIIUUsRidKb2w5F6nkcCBSmskHNjLYcWGQYDyG8lqIz2ijx gTXU1NxN410YGtCksaEXEYc8Ha2QU1+B1WS1rGwfKTP6A/4jWtom/zch9WuUUqMIzKcr JWNw== 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=2s0eARe/EC8VofRKHp0qU/S9EhEo+aL0marcw9uhjOQ=; fh=nLypB3rvk504GacFIka1NRIrs+dxk/mQtlixTJ9Bzjw=; b=jMwJ0wFblAZfCjGkpnlLBwGdO21aazZNA604JTepVNHoWVdN4Av+IBOHzxPAibALwx OneBiEbDYunqWNxrf7aIy39B9PL5sHFMiacnZEZdJRyeJj8Ne3keTZwuckg+TgPXruDG aSkPSMBTct0a4LF2g1KsA3FeYbJJkHCl2G7gPp9K0O9z8Yn4W6o0h+YcgggIaPRHexiR x/gLpS7tgCFHIUsljqJ3beZqSDTjhm5MXySIoKNENroGFQmbf9HHoAlxIGK76un/rxvh JvH69mL7pxRBO0YrT1QTL93dilOYh3LnREI7LOmNLdNrRBvfR2i5KZdCaAT1AWMMQCUW AXrQ== 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:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id s16-20020a656910000000b005c677a35320si3112665pgq.479.2023.12.04.11.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:49:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 908D1805D589; Mon, 4 Dec 2023 11:49:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233821AbjLDTtY (ORCPT + 99 others); Mon, 4 Dec 2023 14:49:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjLDTtW (ORCPT ); Mon, 4 Dec 2023 14:49:22 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 055C4CE; Mon, 4 Dec 2023 11:49:28 -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 c20daf89d4323379; Mon, 4 Dec 2023 20:49:27 +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 07FB1668764; 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 2/3] thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp() Date: Mon, 04 Dec 2023 20:46:35 +0100 Message-ID: <1871840.tdWV9SEqCh@kreacher> In-Reply-To: <5733564.DvuYhMxLoT@kreacher> References: <5733564.DvuYhMxLoT@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: 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 11:49:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784382102832316917 X-GMAIL-MSGID: 1784382102832316917 From: Rafael J. Wysocki Make __thermal_zone_get_temp() use for_each_trip() instead of an open- coded loop over trip indices. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano --- drivers/thermal/thermal_helpers.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) Index: linux-pm/drivers/thermal/thermal_helpers.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_helpers.c +++ linux-pm/drivers/thermal/thermal_helpers.c @@ -82,20 +82,18 @@ EXPORT_SYMBOL(get_thermal_instance); */ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) { - int ret = -EINVAL; - int count; + const struct thermal_trip *trip; int crit_temp = INT_MAX; - struct thermal_trip trip; + int ret = -EINVAL; lockdep_assert_held(&tz->lock); ret = tz->ops->get_temp(tz, temp); if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { - for (count = 0; count < tz->num_trips; count++) { - ret = __thermal_zone_get_trip(tz, count, &trip); - if (!ret && trip.type == THERMAL_TRIP_CRITICAL) { - crit_temp = trip.temperature; + for_each_trip(tz, trip) { + if (trip->type == THERMAL_TRIP_CRITICAL) { + crit_temp = trip->temperature; break; } } From patchwork Mon Dec 4 19:49:03 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: 173548 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2998929vqy; Mon, 4 Dec 2023 11:49:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7/BW4mPbYkrmZ8C0QP46p6jjjcM2n4XsdD8D7y3wwGcqbQ49vDHexwLe6bZKAB60K7M8l X-Received: by 2002:a05:6a00:4212:b0:6ce:4055:5109 with SMTP id cd18-20020a056a00421200b006ce40555109mr139770pfb.4.1701719374823; Mon, 04 Dec 2023 11:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701719374; cv=none; d=google.com; s=arc-20160816; b=koNjJFevRZI8Mwpc6z24uv1DpDDftgZ7GiIjDT9l6a3Fk1OOIy83gNHtEctbBP938r zGr/PutfNUzyr3penqjUhY1w+tGEN13U5RvRCatZEa8bzSiFUvV/N0L7t0++KZz4Hq4j DNDCg/JR2mo01/FLikp9JVu8/1FtyrVK6MI8wskukTWKcOs/avjJYyyLFC/SalAcJHSb uae4E3qRbmzqI1LSGRQWz2RQFVN7rzXe/ZyToDcdFp6AOjhAwrFJb2lrp5Lag+5DhanR 44RhMG5lHYEB0UYC02UmiFqNHqkC2A84wUqNkcg3NUsTpDzdoUulVTq6fFqsgfYhAxRk qD+A== 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=0IHJ0WO9rNbIdRYNBbbmJrmjn+8XBdtkMxYOZHj/B38=; fh=nLypB3rvk504GacFIka1NRIrs+dxk/mQtlixTJ9Bzjw=; b=xWU2NdIe3AZ4XjRqG+EPSrdsFMKK69OR9N5c4vxBwvh3P5wdrqFAaFpDDh4UxtsB4y uYwivZsOapnj0cGtxtAGkZTN3AYvIiIfgUW0nn1Y5mYEUwz0LSSoIDzp/55XgaE54qju lWI4u+TAEBikkAE4qAgRFv4CJatjsorN9pj7prMyaH9jbUsO0Mes8BQkbpzZBauuam8j UBftcDlKpLED8yDFy/Tn8uCJWa3wCaFCulzhqcylu6AbX7RS91y6V84Eho5NBSuQxFMz RvPWMcjBPm9spV0uifSu8Jb5Iu4649JCgPrPdbAxfWEJAwb9tuQV51zR1h4ErWneJc16 c77w== 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:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id dr2-20020a056a004a8200b006cbd3ab255bsi8000540pfb.61.2023.12.04.11.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:49:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 D42F28057B3A; Mon, 4 Dec 2023 11:49:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232848AbjLDTtW (ORCPT + 99 others); Mon, 4 Dec 2023 14:49:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjLDTtV (ORCPT ); Mon, 4 Dec 2023 14:49:21 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38AD2C1; Mon, 4 Dec 2023 11:49:28 -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 83275814bbd9dbf2; Mon, 4 Dec 2023 20:49:26 +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 44A11668764; Mon, 4 Dec 2023 20:49:26 +0100 (CET) From: "Rafael J. Wysocki" To: Daniel Lezcano , Lukasz Luba Cc: Linux PM , LKML , Srinivas Pandruvada , Zhang Rui Subject: [PATCH v1 3/3] thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip() Date: Mon, 04 Dec 2023 20:49:03 +0100 Message-ID: <2912793.e9J7NaK4W3@kreacher> In-Reply-To: <5733564.DvuYhMxLoT@kreacher> References: <5733564.DvuYhMxLoT@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: 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 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]); Mon, 04 Dec 2023 11:49:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784382094829942573 X-GMAIL-MSGID: 1784382094829942573 From: Rafael J. Wysocki Make thermal_genl_cmd_tz_get_trip() use for_each_trip() instead of an open- coded loop over trip indices. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Daniel Lezcano --- drivers/thermal/thermal_netlink.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) Index: linux-pm/drivers/thermal/thermal_netlink.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_netlink.c +++ linux-pm/drivers/thermal/thermal_netlink.c @@ -450,10 +450,10 @@ out_cancel_nest: static int thermal_genl_cmd_tz_get_trip(struct param *p) { struct sk_buff *msg = p->msg; + const struct thermal_trip *trip; struct thermal_zone_device *tz; struct nlattr *start_trip; - struct thermal_trip trip; - int ret, i, id; + int id; if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID]) return -EINVAL; @@ -470,16 +470,12 @@ static int thermal_genl_cmd_tz_get_trip( mutex_lock(&tz->lock); - for (i = 0; i < tz->num_trips; i++) { - - ret = __thermal_zone_get_trip(tz, i, &trip); - if (ret) - goto out_cancel_nest; - - if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip.type) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip.temperature) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip.hysteresis)) + for_each_trip(tz, trip) { + if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, + thermal_zone_trip_id(tz, trip)) || + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip->type) || + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip->temperature) || + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip->hysteresis)) goto out_cancel_nest; }