From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6F206C19F2D for ; Wed, 10 Aug 2022 01:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=iDZ6+akMlARJMqhZ7cFmCjWUgjeV/AS16HB3+b6k6KU=; b=Jf66+wUsdYfrDz 1TD710d6MBp2lAVjcS6tq6K5rDrkxZXVDfJdRguT0CRu1IhI6qe37Lbwj0EdaXBifJQCBC1pHY0LE H4N91V+y/84+bCeAkcdzX9hOym7/jVZZOhnitmxZvyIi1qcnO2aeJz4oeVGiF7PsnTxJRIwzoXJxo UdnKy0/XK50MXgkb6J6J1bYgVpVB6O31rO+Z/44Y/xpN3aNQT64+dKpwQaH0FANPo2ccYyg0yUMbx Fx8dPT1o+lzBm9aFhREO7OnsYLd46JgH/rmvVsVpHJsNMhUw+z5x3kbIizrUjZnxw+Bqz+bWezZdq FruWMcrn5ubow2wFdXKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLai4-0089MT-TO; Wed, 10 Aug 2022 01:40:37 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLai0-0089GW-2Q for linux-arm-kernel@lists.infradead.org; Wed, 10 Aug 2022 01:40:34 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 0C60D5C0279; Tue, 9 Aug 2022 21:40:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 09 Aug 2022 21:40:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm2; t=1660095626; x=1660182026; bh=HbNBRJbRBFm3jhvzvtzDhklvn z1h/RDiPgNM6S1lCOs=; b=XMg4KnU6zR9ZtIGpxJ3kAKJ7k0dYTZ9pnYWdZW1v2 rJWwyGYs5fT1Y9LXtbkskFqSJEp87cZdVdbsUlu6kskCXqC5AFrBWtDhPhKpAjJz e62zK2f8wZ3CXEFiVeshZZrt05u/8GjiKT9vfe+BhhZB3ZLb2CUpN+eAh1UmqQeG ZgbaaB1f1rtEM+2EzPyMRkudi1SuSU/ZyTL46jd9q6LDcllV89MYOeeUqXwiF8Yq S+r6y7Kk/crm7MqxVj6hWrvbVrdCBDp+3anKYJ9Wf/reQsPkflk2kfT184LmUOH0 9Ke+t80OwpGvYXmk+Gd9s9FYKVnk9se2GajRoLS9DkIDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1660095626; x=1660182026; bh=HbNBRJbRBFm3jhvzvtzDhklvnz1h/RDiPgN M6S1lCOs=; b=yNGG+zBxLzBI/dOaH2dXM4jhniKVX5CXV/wlLHdvHXRDmdfcUmG ZuzsDUP6ZtgFG3dIo+fL7RParwG+z0JmdV2Y/i4oXh12YzV4mPtPjuYuoHV101hi 49T/pM0RSGEvYH82rADFU8/nf60t0A3AfUvRSHIUsA8Atw2HzktRpCfnGmkyr2JD HLjzObOQZQvbSlrfF++Heeo7G+tPTivLpdYMu8PnVIWGbfT9vimP4+b92X1hL+VA g6FHtC7aoxs9bBJWy7G/aUTLQd0MV8aDROpNFPq0oHyn2YEgt3XdcsttKK0zJOvI TwJqceu1+l/HtNsXp/qDwOjwCngInanOkkA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeguddghedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepkeevlefhjeeuleeltedvjedvfeefteegleehueejffehgffffeekhefh hfekkeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Aug 2022 21:40:25 -0400 (EDT) From: Samuel Holland To: Chen-Yu Tsai , Jernej Skrabec Cc: Samuel Holland , Michael Turquette , Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [PATCH] clk: sunxi-ng: mp: Avoid computing the rate twice Date: Tue, 9 Aug 2022 20:40:24 -0500 Message-Id: <20220810014024.27568-1-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220809_184032_219258_F69CC0A3 X-CRM114-Status: GOOD ( 11.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ccu_mp_find_best() already computes a best_rate at the same time as the best m and p factors. Return it so the caller does not need to duplicate the division. Signed-off-by: Samuel Holland --- drivers/clk/sunxi-ng/ccu_mp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c index 57cf2d615148..cc94a694cb67 100644 --- a/drivers/clk/sunxi-ng/ccu_mp.c +++ b/drivers/clk/sunxi-ng/ccu_mp.c @@ -10,9 +10,9 @@ #include "ccu_gate.h" #include "ccu_mp.h" -static void ccu_mp_find_best(unsigned long parent, unsigned long rate, - unsigned int max_m, unsigned int max_p, - unsigned int *m, unsigned int *p) +static unsigned long ccu_mp_find_best(unsigned long parent, unsigned long rate, + unsigned int max_m, unsigned int max_p, + unsigned int *m, unsigned int *p) { unsigned long best_rate = 0; unsigned int best_m = 0, best_p = 0; @@ -35,6 +35,8 @@ static void ccu_mp_find_best(unsigned long parent, unsigned long rate, *m = best_m; *p = best_p; + + return best_rate; } static unsigned long ccu_mp_find_best_with_parent_adj(struct clk_hw *hw, @@ -109,8 +111,7 @@ static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux, max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); if (!clk_hw_can_set_rate_parent(&cmp->common.hw)) { - ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p); - rate = *parent_rate / p / m; + rate = ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p); } else { rate = ccu_mp_find_best_with_parent_adj(hw, parent_rate, rate, max_m, max_p); -- 2.35.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel