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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88E47C05027 for ; Mon, 20 Feb 2023 06:01:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1449A8586B; Mon, 20 Feb 2023 07:00:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="UbKISlBf"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="Un90/xSN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E6D098580F; Mon, 20 Feb 2023 06:59:58 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CFEC18586B for ; Mon, 20 Feb 2023 06:59:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id ADA343200C97; Mon, 20 Feb 2023 00:59:52 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 20 Feb 2023 00:59:53 -0500 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 :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1676872792; x=1676959192; bh=ZX wBQkFDaEjblM3ybdQ2ZaoB8v/hC1p8iHxBu31BLTA=; b=UbKISlBf3QraBKurF7 6frbUMnRQ2ZZmKentCtrfRiYIP6Qvd0F0KNIuNJokR7nC/vUPSaJtN9FwDf8gyvm 2aoLwLl0L9w+wYLle44DN6g0kDP2LAm5z3y3Eh6TJC8FDy6PYhpY+e9zgR3w1gtr vmznleBJvPH84wDmefFz7lN5cyhtyyTarJH31Ic3PbJmxHG7eEpZ8ODm82GpwodR gNJAa/RuoArf3dl2gDuIg/2KiZdQ4Rg3wY0SikWd5smXobO8sJ9riQzr1Ojm6eo8 LiqQ67o6y6SMrAJpiMw7hIYmebm7h7c3yE1Pw1SiU2jfJn+2/TGNlFbpUpbtbzKd uT7w== 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: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=fm1; t=1676872792; x=1676959192; bh=ZXwBQkFDaEjbl M3ybdQ2ZaoB8v/hC1p8iHxBu31BLTA=; b=Un90/xSNXB1527UU92asn+v5ORCp6 PON4qSLdKf5ecKD+m3HZ9Auz5ysKfkMG414adzYraE7VPcm9jZMuic8NeQhW/zG5 1S14nWshLqzrxg2uo/ew2QWEXky7VVOC1cGZn+dN3kFPP0s/gBchRnvWmFNdmx9E V8gxsg+H+U+LJRj7w3edusazm49WkcCUa1Crjb5vMVyoypmPB3EBX3i8XO+4BuEB 6PAsYOjTmm/Brj2ynLcKHplk6b2rjhsWWf1XtZuVYYRLjHNDvz6y0I9a7Ao4ndA0 waU/enh4XUo2y71jG4QaYFZJj2wpYrvRLBUXXwhLCqoSt8/QgjhAJcCiA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudejgedgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 20 Feb 2023 00:59:51 -0500 (EST) From: Samuel Holland To: Lukasz Majewski , Sean Anderson , Simon Glass Cc: Samuel Holland , Dario Binacchi , Jean-Jacques Hiblot , Michal Suchanek , Neil Armstrong , Peng Fan , u-boot@lists.denx.de Subject: [PATCH 4/6] clk: Fix rate caching in clk_get_parent_rate() Date: Sun, 19 Feb 2023 23:59:37 -0600 Message-Id: <20230220055940.41890-5-samuel@sholland.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230220055940.41890-1-samuel@sholland.org> References: <20230220055940.41890-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean clk_get_rate() can return an error value. Recompute the rate if the cached value is an error value. Fixes: 4aa78300a025 ("dm: clk: Define clk_get_parent_rate() for clk operations") Signed-off-by: Samuel Holland --- drivers/clk/clk-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 5bce976b060..9d052e5a814 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -520,7 +520,8 @@ ulong clk_get_parent_rate(struct clk *clk) return -ENOSYS; /* Read the 'rate' if not already set or if proper flag set*/ - if (!pclk->rate || pclk->flags & CLK_GET_RATE_NOCACHE) + if (!pclk->rate || IS_ERR_VALUE(pclk->rate) || + pclk->flags & CLK_GET_RATE_NOCACHE) pclk->rate = clk_get_rate(pclk); return pclk->rate; -- 2.39.2