Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp73851rdb; Wed, 20 Dec 2023 06:42:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeUcX7wzJPl/FFvIkoGyDShs/nBSE5r24XfYEsRaroAvNnNl7698B+vWr9HEySvdFfVFd1 X-Received: by 2002:a05:622a:147:b0:425:615f:2fc8 with SMTP id v7-20020a05622a014700b00425615f2fc8mr5523878qtw.61.1703083324419; Wed, 20 Dec 2023 06:42:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703083324; cv=none; d=google.com; s=arc-20160816; b=Gypfzilyh9ufhv0+7xm30PeP6Me/MhEdW2+tx6tAerFQw+ePAsDgAm5RkMF8jICYvJ L8ZsWQwC98zYewUSETCBt4PPztoqE2CCZf57nXwcdd6Be0PeCdQXH7kOLnECfko8qVeC t16K4lPqYnlUd4t15EI0tKy/oAklknTCI97DXr6O80+Br+iBUK3mNjzxSMAUQB+FFoV3 MXSvXZETLc6ST/KwQWGgAdVouLUZIOSMWXX2DZ/0i+I5XnYh577N+pFAxCL47LDyhFBD MauSZ+CZ/rff0zgKPUlejE81QrHz3QPgfao0hAQPlfXWGzWX+eKfqQ8WujsSGBsEYJzX nWsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=E+XJtAZSW6XAM9Qwm/kB+hjQt5tSRjulwvOVlKrXhqs=; fh=wkSuoy5b1EIMGYEcqvfC1yBGuiIWNqkyE3KOqDLfZ9I=; b=U8cslw+GzkEXA5TwffZI6rH9mwUCT/LU30ROn2uw8TrKX2oa1MRHQvPgUGRjxN9FNt zf8vUI0a8Wrpg7J4wzrJHTcGaM5+iRitJ+OzglxWnOwCttEoyh/ZY6ZCrbRSqqXRt4mp 5ektQ12C7ZYbRDdPr9ovuG6S34Nhnp+Dcgi4GZKsOr/3sWBsZ5LySOh7Dvih2jRZkP9D DSDJ/2TYqfG36w92KZzIlFuE3fwueNkCE7hgH607uurLbIQSga1+pbLFkndUmbs7WYTu Rw1I2EuiwbkWZCjVrS+rtiI36t9sSECZbN9Y6GIejklF2fHaWdX0abXrsT/tuI6GnCK0 /J/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t20-20020a05622a01d400b004277d662d67si3069336qtw.512.2023.12.20.06.42.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 06:42:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2E71D1C228B3 for ; Wed, 20 Dec 2023 14:42:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADCF13D3B6; Wed, 20 Dec 2023 14:41:55 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC88B3D966; Wed, 20 Dec 2023 14:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-59415f07ee4so2974eaf.1; Wed, 20 Dec 2023 06:41:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703083313; x=1703688113; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E+XJtAZSW6XAM9Qwm/kB+hjQt5tSRjulwvOVlKrXhqs=; b=cy6PxAYDDfNb6lbhwEkh2BZmotTqg+d9LyS4anqROLyBMidxaSJ5EwSS0UXCiIjdyK InCS6awY/hfExE2LGIw2J88GQVvdav5Jrc6EThzHBLh0BIO6wWVbs1R0Wpz/WOTt2QYe bZXYmDYpQZTH40n+CLj+lFe3BLJvlpXtSbK8jduX6z2SISqFZRTUAjvVG5E4TNQACMQu uoqKCVXtQ64qKu8M9oURUZoeJvvyxRqCvHZ7zABE4SfjcrOL+2JH2bfF3jUizJmsys5Z URoRUM4Xnv2m9nN8RqTRtotJeDcdxMdVdmPKCufTv6Kd9v7tO0rJQLxZLz194XLn3hCM qjXA== X-Gm-Message-State: AOJu0YxnoxYSLYsGUSCj7eqssdR7rpq8yVDvefv3Hn0eiBZ1nn4eWOWC L6zu4OrLFE1gIYtau/fo1VqZV0Pspkhfd2WfCsE= X-Received: by 2002:a05:6820:2c91:b0:593:e60a:493e with SMTP id dx17-20020a0568202c9100b00593e60a493emr4341253oob.0.1703083312931; Wed, 20 Dec 2023 06:41:52 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231212134844.1213381-1-lukasz.luba@arm.com> <20231212134844.1213381-6-lukasz.luba@arm.com> In-Reply-To: <20231212134844.1213381-6-lukasz.luba@arm.com> From: "Rafael J. Wysocki" Date: Wed, 20 Dec 2023 15:41:41 +0100 Message-ID: Subject: Re: [PATCH v2 5/8] thermal: gov_power_allocator: Refactor checks in divvy_up_power() To: Lukasz Luba Cc: linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org, rafael@kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 12, 2023 at 2:48=E2=80=AFPM Lukasz Luba w= rote: > > 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 1a605fd9c8c6..574aa5822112 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_p= ower, 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 =3D 0; > + u32 extra_power =3D 0; > int i; > > /* > @@ -358,8 +359,6 @@ static void divvy_up_power(u32 *req_power, u32 *max_p= ower, int num_actors, > if (!total_req_power) > total_req_power =3D 1; > > - capped_extra_power =3D 0; > - extra_power =3D 0; > for (i =3D 0; i < num_actors; i++) { > u64 req_range =3D (u64)req_power[i] * power_range; > > @@ -375,7 +374,7 @@ static void divvy_up_power(u32 *req_power, u32 *max_p= ower, int num_actors, > capped_extra_power +=3D 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 =3D min(extra_power, capped_extra_power); > - if (capped_extra_power > 0) > - for (i =3D 0; i < num_actors; i++) { > - u64 extra_range =3D (u64)extra_actor_power[i] * e= xtra_power; > - granted_power[i] +=3D DIV_ROUND_CLOSEST_ULL(extra= _range, > - capped_extra_pow= er); > - } > + > + for (i =3D 0; i < num_actors; i++) { > + u64 extra_range =3D (u64)extra_actor_power[i] * extra_pow= er; > + > + granted_power[i] +=3D DIV_ROUND_CLOSEST_ULL(extra_range, > + capped_extra_power); > + } > } > > static int allocate_power(struct thermal_zone_device *tz, int control_te= mp) > -- Looks good to me.