Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2945401rdb; Mon, 4 Dec 2023 11:49:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFu+8C01TyYuUW7Z8q+21+1sOJ7/wqjcy4UD/vrOnHgSJZhayXxctckAU21ejnugUtIoJrq X-Received: by 2002:a05:6358:998d:b0:168:e4c1:eb9c with SMTP id j13-20020a056358998d00b00168e4c1eb9cmr2150279rwb.20.1701719379146; Mon, 04 Dec 2023 11:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701719379; cv=none; d=google.com; s=arc-20160816; b=Ruxo0BoVO0HseXYPX4yXE8BD+rBsjjgO5jGJGo1PsZmIFJ5c8E/jwsXJk7b3jA1Xnk lZnhazdWq8zwCQxhT1+K3pHcp26PYiBHgm0Lc3uKKPpWcmBuDr559PQzT2PgI7RtPTTo fa1sMHLPRbkFyZbtgZTkLtzpk5h2MezqbmgGOQ2Dsp311wl2U+u9BmzP/p7oA+O1fSdv 2ML3JT0Bbfp7j7KbBVqJZbGoxRCnPp5FXjvwSimgJG1HcgAZL0NZSKNI/XQ0S8z4ny97 wLh+Diau1zc//PF1ig7KkusFg0SkU94XNUJ5iS7SbL3LcZQbwkslNsTFNHueiVYIYwbi nfqg== 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 Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bn22-20020a056a02031600b005c62615924fsi3161586pgb.102.2023.12.04.11.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:49:39 -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 AC05F8057988; Mon, 4 Dec 2023 11:49:35 -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 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 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:35 -0800 (PST) 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 --- 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; }