Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp907138rdb; Wed, 6 Dec 2023 03:31:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7AG/x58Opcak/Dce113r9VDkMmSceCNSM1Wh7u6c2y0q6PqqLMxEpaXPSsI243i7UCqAH X-Received: by 2002:a05:6a20:a087:b0:18b:c8f8:e539 with SMTP id r7-20020a056a20a08700b0018bc8f8e539mr306345pzj.42.1701862283241; Wed, 06 Dec 2023 03:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701862283; cv=none; d=google.com; s=arc-20160816; b=RAXTXI5H39GIRhDgcgs+l7V2JnZ2XHFLnMgLHG7alVLO+yI1uxd/ULNeny1A7AFfwq wM5bqLy7mygsCiA5P5jTewHskSYU/CO3LpYSYeluw2S3NDlByidA43QEQyYPl+icZYFm puVGJ+9ZEOwPGZCKn4cJDmxYmMclWspaWkl3n5WdSnuGiDO6/hTwvr40s1fR/1ND3aSZ GoMFamahC9eDQcTysfio9PMMED2U+rju+LLuGwGFlRAMRhk1Mi7MUyyOs9TZpNuMAbS6 dZD97rZ1MVPv53MuznVfBSY2f30lguHQ6nvsWyUP1DxpgrMQMyzZtDYILWylF8uh9Pg5 y+eA== 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=sUr6/8rEIdXpDQf4IxS7mLSkdX6OFLK5rvdOCU9eSmM=; fh=8IgpUQ2T6XGOjA/qDosxdUSIIBz0a6nQ23NA8pgv1Tg=; b=M1WND3VulhRWVSfgjQXroRi8F8x9kd4XUN8/scfpi6Pv6SXIFTUzeXmXHj/dh0QJC+ v9QcrsdyDmwmUeWxkEvqyqjYxcvmJLDEKUgUzuNHQIuCGCDLTHkJ8FiQyVLuKQyqAXbl i1s60OYgv9C53EoNiwvVDw15Aux+Jhwkwyg1c9bmraQMPZQmbPtdGsBrtKhNs/kc9TMP nz2EXPSPNkKBaP0kjLVfLg6zn31bIGQKW+kaCb0mTDJhYLf+ys8o8CCgLICwml4JgIFX a1QNXvm4vYwtle+Jk9VJiE4enjcKRsOkOVCVhXKi5Q1MeJ3Lc4TMjVl8WroKwZ8NdYRT BKog== 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:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id mr17-20020a17090b239100b00286686b9d9dsi7857162pjb.130.2023.12.06.03.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 03:31:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3DD4F802A81C; Wed, 6 Dec 2023 03:31:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377722AbjLFLbA (ORCPT + 99 others); Wed, 6 Dec 2023 06:31:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377613AbjLFLap (ORCPT ); Wed, 6 Dec 2023 06:30:45 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD59E137; Wed, 6 Dec 2023 03:30:51 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9EC1B150C; Wed, 6 Dec 2023 03:31:37 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.1.114]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5E7873F5A1; Wed, 6 Dec 2023 03:30:50 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com Subject: [PATCH 5/5] thermal: gov_power_allocator: Refactor checks in divvy_up_power() Date: Wed, 6 Dec 2023 11:31:38 +0000 Message-Id: <20231206113138.3576492-6-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231206113138.3576492-1-lukasz.luba@arm.com> References: <20231206113138.3576492-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 03:31:14 -0800 (PST) Simplify the code and remove one extra 'if' block. No intentional functional impact. Signed-off-by: Lukasz Luba --- drivers/thermal/gov_power_allocator.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 8f2d2ee3def0..350a39c23ac4 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -349,7 +349,8 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors, u32 total_req_power, u32 power_range, u32 *granted_power, u32 *extra_actor_power) { - u32 extra_power, capped_extra_power; + u32 capped_extra_power = 0; + u32 extra_power = 0; int i; /* @@ -358,8 +359,6 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors, if (!total_req_power) total_req_power = 1; - capped_extra_power = 0; - extra_power = 0; for (i = 0; i < num_actors; i++) { u64 req_range = (u64)req_power[i] * power_range; @@ -375,7 +374,7 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors, capped_extra_power += extra_actor_power[i]; } - if (!extra_power) + if (!extra_power || !capped_extra_power) return; /* @@ -383,12 +382,13 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors, * how far they are from the max */ extra_power = min(extra_power, capped_extra_power); - if (capped_extra_power > 0) - for (i = 0; i < num_actors; i++) { - u64 extra_range = (u64)extra_actor_power[i] * extra_power; - granted_power[i] += DIV_ROUND_CLOSEST_ULL(extra_range, - capped_extra_power); - } + + for (i = 0; i < num_actors; i++) { + u64 extra_range = (u64)extra_actor_power[i] * extra_power; + + granted_power[i] += DIV_ROUND_CLOSEST_ULL(extra_range, + capped_extra_power); + } } static int allocate_power(struct thermal_zone_device *tz, int control_temp) -- 2.25.1