Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2884818lqz; Wed, 3 Apr 2024 11:14:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaDUJ2qF8GTJ/VyRG5J2m7s2Q2clxkDtRyVduF/HYu+4cjkllAiwaC4Pd+Uzf0aUlhyEWXdfO57Xarn2axhQTL8plAaONcG8zGoJ924A== X-Google-Smtp-Source: AGHT+IE2pSkmpVhpGWJFL9hVtBU3+905SorgAbirtVWxlF634yGBcO/YmhWu7ifA5AkILIvXItgA X-Received: by 2002:a17:906:388b:b0:a51:799c:6dbc with SMTP id q11-20020a170906388b00b00a51799c6dbcmr62686ejd.28.1712168094732; Wed, 03 Apr 2024 11:14:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712168094; cv=pass; d=google.com; s=arc-20160816; b=Qq50Zjtz21OBcaczQ3eny0DoAgRMmWKeszpzqn+0CPPHcE2GjP0CG9HvpTPTBuTs33 2TSd/zO5wT9K35gxOlcvjT8aKiDI6lEaGAXatBlw9xRwt4vwOheYP3eYshc6RSbNrrU1 8lwCj1A0svdxy/lXVQK/7//+HaoMgcb8S+gSQIeDoOU2tYV76HlxY0oUyWwcLIWP3f/L Mm2J+GRcKoFw4i2y+VM2v2VO9CRZvfBvUhM0J6EpYSeYCdo8igKrrW+E+kacUNHaJvCE aQVWFgxHBs1+NeQOy+9xE+1kW1lovZR+ccHtbA2RmB9mCWhoAj/UzuasdMigpsYyar7d vyQw== ARC-Message-Signature: i=2; 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:dkim-signature; bh=ek8ljZWVyLTppvqMKescAPv84OpPwjxMf/QwIIjxnrM=; fh=pZcN3lnDPmzrIpxf+h+NFKrBfIYpRY/C7vEftEJzZns=; b=XaO7zHxjaP02wAYgdsqdLwyXwBoUbVjSY5wdgSztjn89yW3SE15VsHySA8p3WVCPHq ujdsDmuucBbkkAJCHdheXvse2oMb3mNuWCVpUN33wZKxdoeRnG/ib/4JUnBNdV9faRd/ hyCqaLR/GFo3pDSjVz9+LzOq1zhzo3NdYU7sIvO42evZF9ncPm0Za/AnXXa7UrVXB/Ra XNbsDZHoite/G2X3IPZfma+pSaYDEq6yslLEnel/uSr3/SYMJV42yryIl2Ph0Q5qsdYm zznGz3MY/bDza5cxbB6ZvGnTyMUdN7dirhwswvxObt0cKsyJAC9ckUhwNgwk4LsrmvBm nN7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rjwysocki.net header.s=dkim header.b=cArjfyC4; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net dkim=pass dkdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-130427-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130427-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u20-20020a17090617d400b00a46c78444e4si6778737eje.788.2024.04.03.11.14.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 11:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130427-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rjwysocki.net header.s=dkim header.b=cArjfyC4; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net dkim=pass dkdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-130427-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130427-linux.lists.archive=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8B6CC1F22CEB for ; Wed, 3 Apr 2024 18:12:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8099315383A; Wed, 3 Apr 2024 18:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="cArjfyC4" Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 947AB1534E6; Wed, 3 Apr 2024 18:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712167933; cv=none; b=KQ+6qTjVgkiZcCZN2Cdm0zfuGCIhGHWZ70rRN6gvULefsKD0K2//b+ueDMWhP6mpwnOU6G4HWSH4DUxIhMArb+k06p8l+QzVCnW6q36VCUkiHfF5C8dAKmpT9zaij7Wz/GdbeoN8LmB+yfy2Hu4m/t2bfsBARyOvA9XwlZY4RxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712167933; c=relaxed/simple; bh=qGMeKA42r0NipAvaOzYcoKIIUuiGOzHMBG4lHVRRTO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OY6RxDVVoqaUt/XXQ/MYYQRYF8BmFhNdWTL5bGytin9deuKIaG65GW4/ZX8q6tFaRFb/7MeXtZXmWU2aQnnk6PlwPlFCFCYRXGTVj7qOyF3zyEplxWqFOKGMoQn8aMcmwA1luChX8RrMOY5+TDX/tpPLMpValscvZDgWBhsoTg8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=cArjfyC4; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 6.0.0) id 170218018de553b5; Wed, 3 Apr 2024 20:12:08 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 1116E662F36; Wed, 3 Apr 2024 20:12:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1712167928; bh=qGMeKA42r0NipAvaOzYcoKIIUuiGOzHMBG4lHVRRTO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cArjfyC4p1Hp7lYMOPDDhzdiJ9aRbpvRjafjZzB5FL40/2m6Uj0vYS4TAam6cd8Ls Af2+o60s6d6xd8qUDjeTAX+cmE84OtyC9fOAj5ko3c7O7leBo1aQnpjEgpl3YuFv56 5vsPyuK+Tl3a3lFfVcYGmgjBEs6V+ecEeqiS35hym+uaq8m7Wb7ao0KwtuXL25mIsY pxII73qxJjTWPihE32WeF5xtAdgU7qhWO8+aqbudh3dK1HJRpz6oPsK3z0Qf8ehy+h cSWxXsuw2yp51G1Y2Ph/MH/F7D64dUn1J8PRrom45y0IhGXJT7BV69uQvKOcuW5mVB QNXDOJVAltLbQ== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Lukasz Luba , Daniel Lezcano Subject: [PATCH v1 1/2] thermal: gov_step_wise: Simplify get_target_state() Date: Wed, 03 Apr 2024 20:11:10 +0200 Message-ID: <4907519.31r3eYUQgx@kreacher> In-Reply-To: <5766468.DvuYhMxLoT@kreacher> References: <5766468.DvuYhMxLoT@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudefiedgjeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepgedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 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,