Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 574D1C433F5 for ; Fri, 25 Feb 2022 14:35:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5AE0510E3E7; Fri, 25 Feb 2022 14:35:48 +0000 (UTC) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F76C10E3E7 for ; Fri, 25 Feb 2022 14:35:47 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7ECD25C0167; Fri, 25 Feb 2022 09:35:46 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 25 Feb 2022 09:35:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; bh=ArpZV1OOJaCiX1V4IJEQ5ZTlCh+REK 6Z3BMj9kfNFS0=; b=piipEcu2V4rTYNwwR1tZk+VAARRLDApZINvAo/gw5DBQ6S kerwDg8RXM2qL2r3YHiOuJJHKo9hnSLZY0+kYifY2C9L0NyeMxgICqCPbVwpuM73 KDmJ49xyQAjSNq99x/n51cqxL54egAACFJ6r+BfuXNeluX1WGVrkrcY/ySwn5sUK 9hzPOxSXwSa6y/P64NcTnRtEeeLFNbggIlWMlCHX08bIbIr8tVqZCseZTbqzbz/d 8RqBU4N7on4O8wDAlqyYqGTmqLuEPWsY6HyKmOMySKHWAIGMTcfAf0gM5fohPguA EmpILUVBYkt0fHnW0D6pAAg7VMhWrHAoKehGim1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=ArpZV1 OOJaCiX1V4IJEQ5ZTlCh+REK6Z3BMj9kfNFS0=; b=BKgX1xtBrltLwYNoI7OLCI WFRNM5UjTq/b2Vpn84L9tkh8y+TB2UNlReHn98KHEkhS2DQCzPKQN7D5+iQeHG7T kg28mNE1MJka6yMhnQDRe9g1k2eWTEk0x1oWnQ0hJav7YdSQ5V54BlVwM2Wzc01o LLckHNO8BPPYf+fZ1WByXhGqwKHS5L5QQUFuCMU77fhiFBHN4ghN+uISQFJCb8ed jGjJVBRsb/PwwSlfjWccVurNRgFAqcl/Fd09xbj2ETZpO07hVO4WZlsUIHWtRARq VOEtzvlbDmQetPw0tNDs2tOFZao01fYwbkLmnX7HyP32UwJLgIIXXehvv7yGsCJw == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrleeggdeijecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Feb 2022 09:35:45 -0500 (EST) From: Maxime Ripard To: Mike Turquette , Stephen Boyd Subject: [PATCH v7 05/12] clk: Use clamp instead of open-coding our own Date: Fri, 25 Feb 2022 15:35:27 +0100 Message-Id: <20220225143534.405820-6-maxime@cerno.tech> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220225143534.405820-1-maxime@cerno.tech> References: <20220225143534.405820-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dom Cobley , Tim Gover , Dave Stevenson , dri-devel@lists.freedesktop.org, Phil Elwell , Maxime Ripard , linux-clk@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The code in clk_set_rate_range() will, if the current rate is outside of the new range, force it to the minimum or maximum. Since it's running under the condition that the rate is either lower than the minimum, or higher than the maximum, this is equivalent to using clamp, while being less readable. Let's switch to using clamp instead. Signed-off-by: Maxime Ripard --- drivers/clk/clk.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 6c4e10209568..c15ee5070f52 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2388,11 +2388,7 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max) * this corner case when determining the rate */ - if (rate < min) - rate = min; - else - rate = max; - + rate = clamp(clk->core->req_rate, min, max); ret = clk_core_set_rate_nolock(clk->core, rate); if (ret) { /* rollback the changes */ -- 2.35.1