Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp498985rdg; Thu, 12 Oct 2023 11:36:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgHnLBmXk0FOGa77A3KIf6fYJHVYsYnv04qKusKGjkoGnXjqYHLZscALlsoaxsXJpwKv8Y X-Received: by 2002:a05:6870:d795:b0:1b0:649f:e68a with SMTP id bd21-20020a056870d79500b001b0649fe68amr28126196oab.25.1697135762427; Thu, 12 Oct 2023 11:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697135762; cv=none; d=google.com; s=arc-20160816; b=gicgdnj6Haf/YsB+eZc+u45Oi0EcijGaXbScov3arTQWb/qWrWthSgf5t1HhDJIJC1 TsSEzWNZLFpGHvN+2j9jXM8zQI5twzJqA5ZoMxXNzXEYJ74H3ojxqyL/VCDFEwAXI4NL kk/qsraMQVAqPT9eKUGTw5eMT8XaJVDL7RPqexFVbbORuw3PGDs//LdKjFsZFcBJiynB jEblmQBDPDI/QfJgbZT2D3kER1j6DTLwVZVvxyHXUPPNCiijkOdGRD8QDI/v2YTCb0Ey W/i4wrDsO5w0oAPVBgQcn04Y3B9QMnp2OV44M5yaTsv91MwrGdHdioDtzjye+MXeOtPf QPPA== 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=LVB37QCsHSviVmK30z5t/FBYAPtf9wyrN3yOgXviDBY=; fh=7MtGe3Dn5wgXLQQm5DZb5OyhwmEFEEdRNCLYMJcP5yE=; b=Lqxbb6kYiwfs8SfwcQt9JJeGqJUeJ9ZLpi3g/wUZrypNKgBgitCbNh7QlUpnD+wQys mPMTiFxbCHZx3IzZrM/0iQA4ScGfHnoSW83c7RCg1QaRUaJSFsa+K/SwGRcC+jNh/FrT wREIQaPZzxFwoTfEmSk4acmFgFdF8urzYt58BMbo/xwesF6BkQGC3Gdc2rlYOzP9GyIF BiDprzKat8tnUmqq1QkIy2hqUN0rhv67k/Db8JfDkbzMOwLPuY9dv42p0GpqBpX5zR4l EtXOZmnJAo4CEOKlWVVKueNPGi6xC+eXgUFWjEn/O/txyU64SVhaO95zBGIz1NiJedc5 yE7g== 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:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x5-20020a654145000000b00578afd89ba6si2568330pgp.457.2023.10.12.11.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 11:36:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 9B4F5807C654; Thu, 12 Oct 2023 11:35:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442149AbjJLSfS (ORCPT + 99 others); Thu, 12 Oct 2023 14:35:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441945AbjJLSfI (ORCPT ); Thu, 12 Oct 2023 14:35:08 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6460BE; Thu, 12 Oct 2023 11:35:05 -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 16bddb04797c5061; Thu, 12 Oct 2023 20:35: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 cloudserver094114.home.pl (Postfix) with ESMTPSA id 1DFAB666870; Thu, 12 Oct 2023 20:35:03 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Srinivas Pandruvada , Zhang Rui , Lukasz Luba Subject: [PATCH v2 1/6] thermal: trip: Simplify computing trip indices Date: Thu, 12 Oct 2023 20:25:06 +0200 Message-ID: <4882956.31r3eYUQgx@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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 11:35:42 -0700 (PDT) From: Rafael J. Wysocki A trip index can be computed right away as a difference between the value of a trip pointer pointing to the given trip object and the start of the trips[] table in the given thermal zone, so change thermal_zone_trip_id() accordingly. No intentional functional impact (except for some speedup). Signed-off-by: Rafael J. Wysocki --- v1 -> v2: Rebase on top of current linux-next --- drivers/thermal/thermal_trip.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) Index: linux-pm/drivers/thermal/thermal_trip.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_trip.c +++ linux-pm/drivers/thermal/thermal_trip.c @@ -173,12 +173,9 @@ int thermal_zone_set_trip(struct thermal int thermal_zone_trip_id(struct thermal_zone_device *tz, const struct thermal_trip *trip) { - int i; - - for (i = 0; i < tz->num_trips; i++) { - if (&tz->trips[i] == trip) - return i; - } - - return -ENODATA; + /* + * Assume the trip to be located within the bounds of the thermal + * zone's trips[] table. + */ + return trip - tz->trips; }