Received: by 2002:a05:7412:a9a8:b0:f9:92ae:e617 with SMTP id o40csp38429rdh; Wed, 20 Dec 2023 15:17:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaJ9lEW1fXYPSm/tzCJ33+TeFEYufaJ8nwKuCKRzCBJXrgoD6vY9VmBWRe5BGvz5YgAHzX X-Received: by 2002:a05:6871:3a25:b0:204:857:55cb with SMTP id pu37-20020a0568713a2500b00204085755cbmr635961oac.10.1703114269245; Wed, 20 Dec 2023 15:17:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703114269; cv=none; d=google.com; s=arc-20160816; b=iBz+XAzJhNb9BiCZdmbmOwqjwW6rAK2NBYB04bPDGAe/lrDTi+bfhTgVX+eQZbsuwe nUFs7bzlpd9BCR+I4OmvivsookVHQesLsb4UroKYTkx6SxZCvEvwh38mu56nzbx3Oi1/ TrhChwbw9P0DXp80YKZwSaoshvNUvdNcSmNpqq4sMpOYaNKKv6blpu1EcmMIUdI6RVdO VsfSpuG+/SZKilLOrpNf+NbxTv20SuHdXLM6WNSbVv3TF75p5nstdj4L54CP/mnclsrB C9j4FZh7Pd0n6E4y5viq2InmDfv328Nf3ibTAiyGa2blXC8Y1Qd44jGrRj/+raGNfy4L EZ0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=2eTCM7EnA/yOVrukdarNu4f8Sq56+XBAvEEAORlUsTc=; fh=BLXDRFxX5XTO46cEytehPgkEKhEpfPIIZAXbZsHkuJk=; b=ItTdrxfhgkinMcHww86b4bCLJLOucdmElh2utcAUOdgDA4Z6Y5N7chyL49X8+Jr1Xu oPzebVPcEFsOZr3mIS2vJxOGyx6tTt9lk0oWNISdB4dN5vBzE2Gi0lfJm/bbAX1MWfYG AGgFUTaC9hKMzwO/o16hWMGgqJGJyWRcSfjx6NE17nID+aQNxfvmE+hIwzJebgGNJm6G 9ha5j4iv7e13AR1739FoaejppixwNcwLBQ0IjCNxpAnFil1lC6FfMlrU7V7UeoKT+grH SDZaKMLu8GCMy7fO4R3Ez8ka4qWMkbhFkS0gJIQAjjLk1V0c27WkIZHJG7lItHXfreji ynxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l23-20020a639857000000b005bdf5961d93si511228pgo.387.2023.12.20.15.17.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 15:17:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DCFCE2871F4 for ; Wed, 20 Dec 2023 23:17:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81A744C3A6; Wed, 20 Dec 2023 23:17:00 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78AAD4B5BB; Wed, 20 Dec 2023 23:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 247892F4; Wed, 20 Dec 2023 15:17:43 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.82.217]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E90F13F64C; Wed, 20 Dec 2023 15:16:56 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, rui.zhang@intel.com, lukasz.luba@arm.com Subject: [PATCH v3 3/9] thermal: gov_power_allocator: Refactor checks in divvy_up_power() Date: Wed, 20 Dec 2023 23:17:47 +0000 Message-Id: <20231220231753.1824364-4-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231220231753.1824364-1-lukasz.luba@arm.com> References: <20231220231753.1824364-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 d9175d9f5e3f..9e35ebd7cb03 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -332,7 +332,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; /* @@ -341,8 +342,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; @@ -358,7 +357,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; /* @@ -366,12 +365,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