From patchwork Fri Feb 3 17:44:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 52601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp978262wrn; Fri, 3 Feb 2023 09:58:16 -0800 (PST) X-Google-Smtp-Source: AK7set+BfPz1g7EwcZ5llbfqYBEOr/Kaj2AB3rWLUyiezQFiOfEbu8ZiUnHAoftt1fN6FiW5UlZi X-Received: by 2002:a17:903:110f:b0:196:89c9:20f4 with SMTP id n15-20020a170903110f00b0019689c920f4mr13228008plh.7.1675447095673; Fri, 03 Feb 2023 09:58:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675447095; cv=none; d=google.com; s=arc-20160816; b=Rz+CdI6mF1QX6quf64uhRbJbWzY75b+HaKp5tZ/dZyUT9duKpUqp/Zf2oxlS7KlCX+ sgWILRdV4JKTrfA3ymyUlXAyx7BNdJVuSgaZfjSK2qpWBe62OgSvFbphvzwjDsIO2XXs NxfDBrXjQ2AAFxxd8JRh37jbO+ZgYM28JE6zGzm7OZJUdlwQA+P0Dxv+YPv8M63hao0J OxAXdlMwkM4FSV31bt/iJIJ3v3lkx6L/47O05XX0FQgkr8kzDqFUuIHLPBDfQX7OgBBi lLON6ZWZe1buAR4D0AcjHYQZ9JGNXBY98yVOvCAIaDkykCXNXE0E4sZyL/MF/c0GGxGI EW2g== 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 :dkim-signature; bh=ImiRnspQldFz7aUHwWWQjNaQE6HDsbMFrGvzaxyK5ic=; b=gvE8k4VsjhxnLF0BXKxqosdqQ6WfQGclOQpkF1aMmmGs55+YU0IBY2lqHhwU096JWi 2OJs0Mp8AQuOtKHo2kRmezPQJT4BRUvSj4XQcQ1uoxBaW+m/ZadulkWuljnHEE6iCGfU TTkpHL23SY9npPJ9sVFyHsvYZTyrA1cmCwMW4jUrbXxtMckAeC9lZWrUawTbuTOKYaKv Q7sBZJhAoYadv/pUHOqr6/vV7IVrEvRSS0/NNXM+qzsjbRtojJoQKAhsE8hk/VuizitT POY90XntJfjTUsqtyhB5x1zocJx5EzZ04CdhWi8LoocROZs/EKiJkvBbAzYxNzHrMEcA BBwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TsvIRqby; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a170902f7cd00b00189ccadd447si2707533plw.101.2023.02.03.09.58.02; Fri, 03 Feb 2023 09:58:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TsvIRqby; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233747AbjBCRvx (ORCPT + 99 others); Fri, 3 Feb 2023 12:51:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbjBCRvh (ORCPT ); Fri, 3 Feb 2023 12:51:37 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B7462713 for ; Fri, 3 Feb 2023 09:51:34 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id z11so5953560ede.1 for ; Fri, 03 Feb 2023 09:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ImiRnspQldFz7aUHwWWQjNaQE6HDsbMFrGvzaxyK5ic=; b=TsvIRqby7Oz8eG1DHfd++shiHsmPHIh06ieKcJEAFrbgyAN3mVLH1IZrTA7AtgxtJC m85VH4bkWFZVKrlBC3Ml39ZbV0PQvUS9hbNeett0FCjNZ4uVnFrX6cb9JQ2C+d8Vdr+Q Yvyx9iUO6tH3apNERAoefugBdBieK1HWn3/IM2duyWtxe3DAYRRm5N/B0THNk7jLjuOR H4nAdZIpHTGeuOmZP9DTnvWgmT3RAW0/yl93pRC6sGfoMBs0VX/KSb7m3+dtuZidxQY6 TBWsJ1jl4ti7WGYPWJGGHvT/NbqqsR+mOSMPfOvbSVhugLPuOZuGd1fCkkYUc6kGEJRb 7s4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ImiRnspQldFz7aUHwWWQjNaQE6HDsbMFrGvzaxyK5ic=; b=KuhrOOKMnHSFbV+wZWK8n+70I/ArR0VQ8m9rfHIJFRlD6eg8xMa6qdK9NQ9Zhr3T/Y WSteuGHkgqTNdNeNZsRPYzMtJjdDYj61QbEYK109PdRrWZfYiSqOyUJScnxnGDbgYgpu sjm7COXeb8dkgqy/h9Pox8kfN3MqkxjTFIFOCZUEDj1HvXTgktx7Qyq/G5KHQ+AXLJKP tpMRY8Dvbmq9xqvp99ulLKqCfeDj2W+RFmfO6p0mWxUQKxYE1ip9Ts/XVTnbX56nXXoW iqMx7rRkBsEVMBoKdpa+rdi+jpbqrwywQLDEUeImtVl3SokMs21G2JK80AZXV8fmuTWS Tx1g== X-Gm-Message-State: AO0yUKU8+XaDYKcfsiYGYepT36rwXt7gxBaiRciRqil2EBdL8Os25lwG i/u/ckxhzEYw4HpAcIfOOWu19Skay7HoMO+L X-Received: by 2002:a5d:5949:0:b0:2bf:9582:1378 with SMTP id e9-20020a5d5949000000b002bf95821378mr9589419wri.37.1675446277891; Fri, 03 Feb 2023 09:44:37 -0800 (PST) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id z1-20020a5d4c81000000b002bdd8f12effsm2443528wrs.30.2023.02.03.09.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 09:44:37 -0800 (PST) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: daniel.lezcano@linaro.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Zhang Rui , Len Brown , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 05/11] thermal/acpi: Optimize get_trip_points() Date: Fri, 3 Feb 2023 18:44:23 +0100 Message-Id: <20230203174429.3375691-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203174429.3375691-1-daniel.lezcano@linaro.org> References: <20230203174429.3375691-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756833613898305625?= X-GMAIL-MSGID: =?utf-8?q?1756833613898305625?= The function has two purposes. Initialize the trip points by reading the ACPI table and then doing a check trip points exists. This check will go through all the trip points and at the end if a valid trip point is found, the parsing is considered valid. Instead of checking all the trip points, exit when a valid trip point is found. Signed-off-by: Daniel Lezcano --- drivers/acpi/thermal.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 903f0e3d95f5..c4fd583fbf5c 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -461,23 +461,20 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) { - int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); + int i, ret; + ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); if (ret) return ret; - valid = tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid | - tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid | - tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid; + for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { + if (tz->trips[i].flags.valid) + return 0; + } - for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) - valid |= tz->trips[i].flags.valid; + pr_warn(FW_BUG "No valid trip found\n"); - if (!valid) { - pr_warn(FW_BUG "No valid trip found\n"); - return -ENODEV; - } - return 0; + return -ENODEV; } /* sys I/F for generic thermal sysfs support */