From patchwork Fri Feb 3 17:33:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 52580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp969120wrn; Fri, 3 Feb 2023 09:35:48 -0800 (PST) X-Google-Smtp-Source: AK7set9NFmEv8FXqicsGovEahSpEFhAAOB+TGSQsUREJllOaZlBTKKzxmsip4sgRmKsdP5f9g2HP X-Received: by 2002:a05:6a20:4428:b0:bd:278:f68f with SMTP id ce40-20020a056a20442800b000bd0278f68fmr13535498pzb.52.1675445748271; Fri, 03 Feb 2023 09:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675445748; cv=none; d=google.com; s=arc-20160816; b=anUzXwDQQBDWDkyeGwjpI0k4lBnT21k+V+cCE0I6bKjGjrG84xo6w739fECkwSAQ4x Nb/FlbZw7ZT7qeGCPZiNYCrGb/7tMovVHjPn9GanXC08j7Yv/JWq+LV9u8UL9wuF0cLy Oexioa8VA87KYzNhwDDShmEWGmB0VLe6LbB6pA+FN+pq6FqinMXMmIe84jHBOTFP3Whr ivEzAOQZyRWjfy6MrVg5OQZoN4u1DOxR0Y2zN77QUn/hVII+W5GO+xKRvFt/IKqHzMDJ Um+xlXg/7vn/pKMfPGTqWb8//LrhV+JeXcq98NIZuesQVtj7iPKVoxuhlz4joHGgy9kN 0gcw== 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=W0WMeqO1vZNLVskDd96ga8DPKCx7MU4pvjHfg5TCNV4=; b=YdBeT7qUCrh3zRDybVf5UvauOy/ffvzHOhlKqW4aRs6TkMogha6yhIWHFEDX3Oqr0s Hc9GU49c1RLCjQhVed2J5CjFlRSkTBfyllz1F4D1CnXpS4qdo0jZPfrIiyO35DqCwwbR zTeCvgXAoggZ9w/Tzs35gQekpAj2NdAKgVhW+A0gyBYxfvTJG0mn7HEP0eeYFtWYPKB7 PRQ4v2TL/lnkcJl+FbIi3hXSjMaPDpNrTVfhKjNdsxdXkP7WdbEVj8VV+FzK404NonUz btkfq0bKqFyitWr7Z8CeBu6s/JgMFM/gAZgEQJY8n0KZhYyjFOyFoMDKHreoN0zHFdED m2bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XHOfdsZu; 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 a187-20020a6390c4000000b004f1ce43e6b8si3406451pge.22.2023.02.03.09.35.35; Fri, 03 Feb 2023 09:35:48 -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=XHOfdsZu; 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 S233761AbjBCReS (ORCPT + 99 others); Fri, 3 Feb 2023 12:34:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233255AbjBCRd6 (ORCPT ); Fri, 3 Feb 2023 12:33:58 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5814A428F for ; Fri, 3 Feb 2023 09:33:55 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id j32-20020a05600c1c2000b003dc4fd6e61dso6511821wms.5 for ; Fri, 03 Feb 2023 09:33:55 -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=W0WMeqO1vZNLVskDd96ga8DPKCx7MU4pvjHfg5TCNV4=; b=XHOfdsZuhQ64j8+pZNPju1LBEDBsM5d7gyUiAOkeKBc9vEbcIvqsDaDN4IETWMjbQp ZrHX0rW380A/WYefqmUKfScwbTttISBpjVzSochOvs0f77cBjt6Opf4+uMTSi3nMbhkf 9uAy4fsfmLxX4t6ph19DRXFq8zC5ccMJq2eIgSsQtPTNl+7KmMuGpfWjhOA7GQoSYGR7 I/pmwdxj0LZGeSJA7345nd2y3mpcQEJBQczKp0umtrTV/VgcWUZ5uVjqDN+n3IEVqlqX C/HK95ys11iiPgpVOTS9Xt08cuAUDcdf9kdNJFo6IS2wDlij0h6vZ6p7qj5A7J3wqE6z XLDA== 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=W0WMeqO1vZNLVskDd96ga8DPKCx7MU4pvjHfg5TCNV4=; b=Q2je9q34gecoelaufgw+RvD9tartsR82KM5si1dBRkKUDM1WxSlTJi+oj1Tl+p8Cov p49GKfFF/AT5BerDrM3KqHDLgWAj/26aXX3ndi1XPNpI1y3WCeahJ5b2rbE/qLrOV/kT SoIW3Z+d25Qde7T6sPk8B1UJbOuq/9iryF2dagRMkSDVMUA1Zov8mDAn9/YvdvZXGdOH 3jM0AuyV4m3kJi7qx0ADg/58UfT5NLT96IGVaBe14r0QtmUHulL3CkybCNxgxr3/pWOL LgHrDO4NFeOr+6KJ8GexykNNd0lJvJEw5hYNoYUw+lrYkN+VRUdbpcydi6EOUWPj01dg MbjA== X-Gm-Message-State: AO0yUKVXreE76wpIkfDkZvMXpSQBPDmxt4Qs+W2F3QuTZwYxATsDL29Q WwA85D1Dnn3of0DRSQLCG+5Va4DhFA7X0DWM X-Received: by 2002:a05:600c:3ba3:b0:3dc:58a2:3900 with SMTP id n35-20020a05600c3ba300b003dc58a23900mr10266362wms.29.1675445635238; Fri, 03 Feb 2023 09:33:55 -0800 (PST) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id z4-20020a05600c0a0400b003dfdeb57027sm5876356wmp.38.2023.02.03.09.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 09:33:54 -0800 (PST) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: 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 v1 07/11] thermal/acpi: Simplifify the condition check Date: Fri, 3 Feb 2023 18:33:27 +0100 Message-Id: <20230203173331.3322089-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203173331.3322089-1-daniel.lezcano@linaro.org> References: <20230203173331.3322089-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?1756832201196479971?= X-GMAIL-MSGID: =?utf-8?q?1756832201196479971?= The condition: if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE)) and on the other side: ACPI_TRIPS_INIT (... | ACPI_TRIPS_ACTIVE) So if the first predicate is true, the second is also true. The 'valid' flag for the trip point is also checked before, so it is pointless to redo the same check again and again as it is unchanged. Signed-off-by: Daniel Lezcano --- drivers/acpi/thermal.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index a3a8130c955f..c7c2b3d63e90 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -321,6 +321,9 @@ static int acpi_thermal_trips_update_passive(struct acpi_thermal *tz, int flag) int valid = 0; valid = tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid; + if (!valid) + return 0; + if (psv == -1) { status = AE_SUPPORT; } else if (psv > 0) { @@ -398,13 +401,16 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag) for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) { char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; + valid = tz->trips[i].flags.valid; if (act == -1) break; /* disable all active trip points */ - if (flag == ACPI_TRIPS_INIT || ((flag & ACPI_TRIPS_ACTIVE) && - tz->trips[i].flags.valid)) { + if (!tz->trips[i].flags.valid) + continue; + + if (flag & ACPI_TRIPS_ACTIVE) { status = acpi_evaluate_integer(tz->device->handle, name, NULL, &tmp); if (ACPI_FAILURE(status)) { @@ -436,7 +442,7 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag) } name[2] = 'L'; - if ((flag & ACPI_TRIPS_DEVICES) && tz->trips[i].flags.valid ) { + if (flag & ACPI_TRIPS_DEVICES) { memset(&devices, 0, sizeof(struct acpi_handle_list)); status = acpi_evaluate_reference(tz->device->handle, name, NULL, &devices); @@ -455,6 +461,7 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag) ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device"); } } + if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES)) if (valid != tz->trips[i].flags.valid) ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state"); @@ -495,8 +502,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) } /* Passive (optional) */ - if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) || - (flag == ACPI_TRIPS_INIT)) { + if (flag & ACPI_TRIPS_PASSIVE) { acpi_thermal_trips_update_passive(tz, flag); }