Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp197267lqe; Thu, 4 Apr 2024 04:15:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRG7iIR+ZjNl8ljwdtc6iB4sz9g2CpI5yUK1iMFRNWTfvaYjtxMvE/1nDZssQfFLM9/Nf22Q2+Cwl6csmO/GGUzaPWQ3K04FCpRWP+KQ== X-Google-Smtp-Source: AGHT+IFcSkFpYBdjlfgWRzprd5hcERh6Bk9R6CvjudPqsZAWolXdhC/zhV7nUwbEMQVVfVRcNqZX X-Received: by 2002:a2e:818f:0:b0:2d6:f5c6:e5a1 with SMTP id e15-20020a2e818f000000b002d6f5c6e5a1mr2112565ljg.12.1712229332762; Thu, 04 Apr 2024 04:15:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712229332; cv=pass; d=google.com; s=arc-20160816; b=BzuPQ3w2eKZXNLN7+hZEpU7XUFCc6e4K7X3246Vp+s9+CF/nJud8A14p2rsCI3f4Jl fYRvAbgHxF6n2m3WZdcxVwwlMzRH5Ftr64s/j+iskrkoGSnt1TxvpROPsUlkbnaHafiI 1PpWSu3HL27RL1VHUYA6JTVweQG0n+FiUwghklzeNTlWJAeWu+SpRLl4POnHQ27PLXv9 2QP9s7twtQDCT2CGGxDUjkK5qW7gV/dWywKQoQr3xCDxYVJGQd5fnFb1+QtZ0kqKIcGg ZcQokCOvU2iqFw1yQJ3gukvRzhHLYzk/9cOnlXYBo/eF4gFXg63K7NBGWN5GflVy6bxB LCzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=fqiGW+ybsG9KzkmFiQcnQuoQcOmCYNnBCG9kj+LMJmo=; fh=22oGAZ1Ogq/KP1hvbtQ7bVI0naSO4PC48f/0YrQMvL4=; b=N+wdMVC44AFkNif/tJFQn4n5p9qJBUO5mGffXJ0+IpT6xuWy4/e9FREr7NyVKXv4Y/ 1Wd+ayk3IpIg7ktqJ7AiG0oIydeBXrlSQ6IzNKZBETSTnijFf85HypyIhpfgieROpfdR VAdjdUXxSLgWWqChDlFNXqlDTXyRUtfqo1ebqWa4C1E187lwkeKWWAg0PMr9AZsHoWp8 YJYcvil8caj16QhoatgdXlP9vJzXPGQiG53HWRm9wJZBgCo4KlEUW/HfCtaRHA2sPWXD 76k2kZqa7+u5Uj41cO/the2kk2z4TD6i2Rw15ky+3S9qK5GixdThOzCbEB2fyaP2cfCN iCtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-131298-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131298-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b14-20020a17090636ce00b00a4751926e3esi7616637ejc.26.2024.04.04.04.15.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:15:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131298-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-131298-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131298-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 78DF11F28267 for ; Thu, 4 Apr 2024 11:15:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B764C811E0; Thu, 4 Apr 2024 11:15:24 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 133CF80C09; Thu, 4 Apr 2024 11:15:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712229324; cv=none; b=aMsG51pn8kyvhzLn5/hK8u5H5VIY1DOao8dXwvx2alNCDBs6TWprwjSwulc+F2Drg5iLfUJzyIS5YqWqJ7UExbFiYVWflyba1GNvabonnEGDlMcBf9eiwIaGLj4SOGq3x4HThD0AVAJrRAaf6QSPsnzh//7lyXXrBn2ajIjTw0s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712229324; c=relaxed/simple; bh=Gb6TQcZhy8zvbAqHNSQ5R13gtVldiV+tKWL8vvqYeV0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TZPLdZKv8wgsrhfb7HpW9FEtYlnhS+RHn3qP7gn2p9B9Tg7L81RhQUfNyuUejGIC5hRK7K1jIEZj0r0sKs6Y8KXI6P0rsto1mf70Bn1+3btF9Rzk5ABULd9jYcg/Mzoznuj4upncMhgYwDslptSbrtYbefOMi4aSASYIWQTjlIA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 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 2D4E9FEC; Thu, 4 Apr 2024 04:15:52 -0700 (PDT) Received: from [10.57.73.43] (unknown [10.57.73.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A2B373F7B4; Thu, 4 Apr 2024 04:15:20 -0700 (PDT) Message-ID: <7ebaa870-64d0-4944-bf62-d4ef1a97a1a9@arm.com> Date: Thu, 4 Apr 2024 12:15:22 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/2] thermal: gov_step_wise: Simplify get_target_state() Content-Language: en-US To: "Rafael J. Wysocki" Cc: LKML , Daniel Lezcano , Linux PM References: <5766468.DvuYhMxLoT@kreacher> <4907519.31r3eYUQgx@kreacher> From: Lukasz Luba In-Reply-To: <4907519.31r3eYUQgx@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Rafael, On 4/3/24 19:11, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > The step-wise governor's get_target_state() function contains redundant > braces, redundant parens and a redundant next_target local variable, so > get rid of all that stuff. > > No intentional functional impact. > > Signed-off-by: Rafael J. Wysocki > --- > drivers/thermal/gov_step_wise.c | 27 ++++++++++----------------- > 1 file changed, 10 insertions(+), 17 deletions(-) > > Index: linux-pm/drivers/thermal/gov_step_wise.c > =================================================================== > --- linux-pm.orig/drivers/thermal/gov_step_wise.c > +++ linux-pm/drivers/thermal/gov_step_wise.c > @@ -32,7 +32,6 @@ static unsigned long get_target_state(st > { > struct thermal_cooling_device *cdev = instance->cdev; > unsigned long cur_state; > - unsigned long next_target; > > /* > * We keep this instance the way it is by default. > @@ -40,32 +39,26 @@ static unsigned long get_target_state(st > * cdev in use to determine the next_target. > */ > cdev->ops->get_cur_state(cdev, &cur_state); > - next_target = instance->target; > dev_dbg(&cdev->device, "cur_state=%ld\n", cur_state); > > if (!instance->initialized) { > - if (throttle) { > - next_target = clamp((cur_state + 1), instance->lower, instance->upper); > - } else { > - next_target = THERMAL_NO_TARGET; > - } > + if (throttle) > + return clamp(cur_state + 1, instance->lower, instance->upper); > > - return next_target; > + return THERMAL_NO_TARGET; > } > > if (throttle) { > if (trend == THERMAL_TREND_RAISING) > - next_target = clamp((cur_state + 1), instance->lower, instance->upper); > - } else { > - if (trend == THERMAL_TREND_DROPPING) { > - if (cur_state <= instance->lower) > - next_target = THERMAL_NO_TARGET; > - else > - next_target = clamp((cur_state - 1), instance->lower, instance->upper); > - } > + return clamp(cur_state + 1, instance->lower, instance->upper); > + } else if (trend == THERMAL_TREND_DROPPING) { > + if (cur_state <= instance->lower) > + return THERMAL_NO_TARGET; > + > + return clamp(cur_state - 1, instance->lower, instance->upper); > } > > - return next_target; > + return instance->target; > } > > static void thermal_zone_trip_update(struct thermal_zone_device *tz, > > > LGTM, Reviewed-by: Lukasz Luba Regards, Lukasz