Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2791844rda; Wed, 25 Oct 2023 12:22:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFp5cPrwwtJUhXSJQ3qtFDjYMu3dPjPiMcZUDmtTtmleb1b7XRnifuNVvyBOib9j7ljRxZ6 X-Received: by 2002:a25:b322:0:b0:d9c:f0e:ba89 with SMTP id l34-20020a25b322000000b00d9c0f0eba89mr16830458ybj.50.1698261762881; Wed, 25 Oct 2023 12:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698261762; cv=none; d=google.com; s=arc-20160816; b=gCNZ2toe3GmfSg0liNmXOO69NNomqopAV2/g1CsOaKq3KgFt9RUphEJJh3+mbMZwI3 mIVZUik8QCH8Sh+BiCkubay16SHEhCLTi2v7ShA2ADWrBFgHfu5oYSJkYNCidVB31FTd Ft0vKihb2VWwDOS1INrlc5LDFmQFhe5qso4AaYR62zrxUuPIhfljvHYcsitn6SN8CXcr gyO8NI4zChYAivGf07Bxctum7wuOGdSwMhJ7E+7KSXwjFIuW5xgAUp4E8FzWMP2DqKfs 8Ozg7c7+JdRAMW1YmT9wFEXAS8kuxc8+X/18qCfOI9KfCOAPm6mZVSRKdWODA5PI6Tsz CAMw== 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=k9JC5BVCnJ7Pyhvd26JQrBvi9+BbKvaXABpVAn7AyDk=; fh=8IgpUQ2T6XGOjA/qDosxdUSIIBz0a6nQ23NA8pgv1Tg=; b=gtUEwHSwNv/kuBbMdPKDbKUes4us24rByl+KSosl7PXjOjZVYAytaExC/aKKWjuOcV lCLDaofUt0jq7o9lLnJvqndtdm6MFlIs77I/PbUHwuQz/Tw4K5u0aIzYIldEl/vDCrOx MWsIJu9Cc7L8dMXRumY07GO6Kmp58sZ7I0qe8ymJMLrhJbLBd/K6aTVPewivNsgy5vLY 4ASDBRGDoakd0Gft+nsdMcerr96Ad17WURjXg505IUATT/yfKo+HhBHWA5hZ/WUUcqqa CFevSM9GLEE2OAiOvR9ldHhkS0XsLeaQMPwFU5HEKXXap6KN0/2UMyP5C7VktsRSArzl bDkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l125-20020a252583000000b00da039dc2103si5290455ybl.373.2023.10.25.12.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 12:22:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id C6D39802A362; Wed, 25 Oct 2023 12:22:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234854AbjJYTWB (ORCPT + 99 others); Wed, 25 Oct 2023 15:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234337AbjJYTVy (ORCPT ); Wed, 25 Oct 2023 15:21:54 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 462E0187; Wed, 25 Oct 2023 12:21:51 -0700 (PDT) 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 A5C5D1424; Wed, 25 Oct 2023 12:22:32 -0700 (PDT) Received: from e129166.arm.com (unknown [10.57.81.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D02F13F7C5; Wed, 25 Oct 2023 12:21:49 -0700 (PDT) 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 7/7] thermal: gov_power_allocator: Clean needed variables at the beginning Date: Wed, 25 Oct 2023 20:22:25 +0100 Message-Id: <20231025192225.468228-8-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231025192225.468228-1-lukasz.luba@arm.com> References: <20231025192225.468228-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Wed, 25 Oct 2023 12:22:40 -0700 (PDT) Rearrange the local variables setup. This improves the reading of the code and allows to better see the initial values; This change is not expected to alter the general functionality. Signed-off-by: Lukasz Luba --- drivers/thermal/gov_power_allocator.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index e6d2f0fe8d2fd..785fff14223d8 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -376,16 +376,19 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors, static int allocate_power(struct thermal_zone_device *tz, int control_temp) { - u32 total_req_power, max_allocatable_power, total_weighted_req_power; u32 *req_power, *max_power, *granted_power, *extra_actor_power; struct power_allocator_params *params = tz->governor_data; - u32 total_granted_power, power_range; struct thermal_cooling_device *cdev; struct thermal_instance *instance; + u32 total_weighted_req_power = 0; + u32 max_allocatable_power = 0; + u32 total_granted_power = 0; + u32 total_req_power = 0; u32 *weighted_req_power; + u32 power_range, weight; int total_weight = 0; int num_actors = 0; - int i, weight; + int i = 0; list_for_each_entry(instance, &tz->thermal_instances, tz_node) { if ((instance->trip == params->trip_max) && @@ -418,11 +421,6 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp) extra_actor_power = &req_power[3 * num_actors]; weighted_req_power = &req_power[4 * num_actors]; - i = 0; - total_weighted_req_power = 0; - total_req_power = 0; - max_allocatable_power = 0; - list_for_each_entry(instance, &tz->thermal_instances, tz_node) { cdev = instance->cdev; @@ -459,7 +457,6 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp) total_weighted_req_power, power_range, granted_power, extra_actor_power); - total_granted_power = 0; i = 0; list_for_each_entry(instance, &tz->thermal_instances, tz_node) { if (instance->trip != params->trip_max) -- 2.25.1