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: 11855621 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB70D1130 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 A0AF120857 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_the_f?= =?utf-8?q?or_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);