From patchwork Mon Oct 26 01:49:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernard Zhao X-Patchwork-Id: 286696 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AACBC4363A for ; Mon, 26 Oct 2020 01:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55AB220857 for ; Mon, 26 Oct 2020 01:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1421300AbgJZB6F (ORCPT ); Sun, 25 Oct 2020 21:58:05 -0400 Received: from m176150.mail.qiye.163.com ([59.111.176.150]:37989 "EHLO m176150.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1421299AbgJZB6F (ORCPT ); Sun, 25 Oct 2020 21:58:05 -0400 Received: from vivo.com (wm-10.qy.internal [127.0.0.1]) by m176150.mail.qiye.163.com (Hmail) with ESMTP id 625B11A16B5; Mon, 26 Oct 2020 09:49:24 +0800 (CST) Message-ID: To: Zhang Rui , Daniel Lezcano , Amit Kucheria , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: =?utf-8?q?=5BResend=5D=5BPATCH=5D_drivers/thermal=3A_optimize_th?= =?utf-8?q?e_for_circle_to_run_a_bit_fast?= X-Priority: 3 X-Mailer: HMail Webmail Server V2.0 Copyright (c) 2016-163.com X-Originating-IP: 157.0.31.124 MIME-Version: 1.0 Received: from bernard@vivo.com( [157.0.31.124) ] by ajax-webmail ( [127.0.0.1] ) ; Mon, 26 Oct 2020 09:49:24 +0800 (GMT+08:00) From: Bernard Date: Mon, 26 Oct 2020 09:49:24 +0800 (GMT+08:00) X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZGk9JGkoYS0IdQ05OVkpNS0hNTE1CTU9OSUxVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS09ISVVLWQY+ X-HM-Sender-Digest: e1kMHhlZQQ8JDh5XWRIfHhUPWUFZRzo1OjoOOj8rPx9OKlFDMB0pLwwY C08LCFVKVUpNS0hNTE1CTU5JSUhVMxYaEhdVGR4JFRoJHzsNEg0UVRgUFkVZV1kSC1lBWUpOTFVL VUhKVUpJT1lXWQgBWUFISkJJNwY+ X-HM-Tid: 0a756298864693b4kuws625b11a16b5 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Function thermal_zone_device_register, in the for circle, if the first if branch set the count bit in tz->trips_disabled, there is no need to set in the other if branch again. This change is to make the code run a bit fast and readable. Signed-off-by: Bernard Zhao --- drivers/thermal/thermal_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index c6d74bc1c90b..03577794eea3 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1446,10 +1446,14 @@ thermal_zone_device_register(const char *type, int trips, int mask, goto release_device; for (count = 0; count < trips; count++) { - if (tz->ops->get_trip_type(tz, count, &trip_type)) + if (tz->ops->get_trip_type(tz, count, &trip_type)) { set_bit(count, &tz->trips_disabled); - if (tz->ops->get_trip_temp(tz, count, &trip_temp)) + continue; + } + if (tz->ops->get_trip_temp(tz, count, &trip_temp)) { set_bit(count, &tz->trips_disabled); + continue; + } /* Check for bogus trip points */ if (trip_temp == 0) set_bit(count, &tz->trips_disabled);