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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2D89C433F5 for ; Thu, 12 May 2022 16:05:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356224AbiELQFG (ORCPT ); Thu, 12 May 2022 12:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356213AbiELQE7 (ORCPT ); Thu, 12 May 2022 12:04:59 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EECE362A0B for ; Thu, 12 May 2022 09:04:57 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 002F45C018B; Thu, 12 May 2022 12:04:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 12 May 2022 12:04:57 -0400 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=fm3; t=1652371496; x=1652457896; bh=78 mjLpgZpR0U86TTOmeBJjXTX7xn4htRFYw9i6mT6R8=; b=IkzqgUhXzQbLR55kbj woY+pzHtmfkmIWbt5RAvxICp4cjF7KU895/PeohZ38XsHXYbC+jmYQmD7Sx0sda/ GsUV+Giein3RSp5Yyo2a/0od4R9NP8xXMaUsgJkC67dS9g4TUb0c/9vyqwOtDa0W TAPfMk2tWZNtcQX54Ssvbi2bb2rpw0pfX0OHXNHWK0fqoP99aujlhD9rL20fgqXs SbOIeEsqZAr1xT963q32APv0/uhzIwKPZEsxqC40N0kudgGTH+l3VSmuIMtcvQbP oipYAaUJKmI+f5tfKlDCsidV4j5umyPA4xabsvb7tNGZLZ7Sd0qIP8S1XfsIBydM C5yg== 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=fm1; t= 1652371496; x=1652457896; bh=78mjLpgZpR0U86TTOmeBJjXTX7xn4htRFYw 9i6mT6R8=; b=OgMOQ/LPci2f9Rj4sGuWfW2vc7GzS8wBxfp+uxIuKm/teB6ZarH DvARKkJoPwoj5hAS7Ytn1y3BmRglfxcQOuJT46ZPyTS4lO1xx1fL84mZP2Tq4crT E1C1NkcLp818NrxjPT9bPMw1HJhA2U798ttGhj3JDs0ZtzpWBX+MsvCgB8l9rr66 /dEb8obofJI62o32EE/guE3N+/eDwvmybHV2mD70Ikrc1pHxBSczEo5FyJm7HCNP NYOqcWN0lWhnHbudi8CFRxJUGyKB0BJvpB2el/NMriCAg0JhM7jankXsSkzZ4iCp 5DMR6WV4Rn46B7hxLZpUdzJCT13HEbr/K6g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrgeejgdelgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepleekfeetudfhkeejiefhtedugfeuvdevkeekteetkefhkefhtdelgfefuddv jefhnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 May 2022 12:04:56 -0400 (EDT) From: Maxime Ripard To: Mike Turquette , Stephen Boyd , linux-clk@vger.kernel.org Cc: Naresh Kamboju , Alexander Stein , Jerome Brunet , Dmitry Baryshkov , Marek Szyprowski , Yassine Oudjana , Tony Lindgren , Neil Armstrong , Maxime Ripard Subject: [PATCH v4 18/28] clk: Introduce clk_hw_init_rate_request() Date: Thu, 12 May 2022 18:04:02 +0200 Message-Id: <20220512160412.1317123-19-maxime@cerno.tech> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512160412.1317123-1-maxime@cerno.tech> References: <20220512160412.1317123-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org clk-divider instantiates clk_rate_request internally for its round_rate implementations to share the code with its determine_rate implementations. However, it's missing a few fields (min_rate, max_rate) that would be initialized properly if it was using clk_core_init_rate_req(). Let's create the clk_hw_init_rate_request() function for clock providers to be able to share the code to instation clk_rate_requests with the framework. This will also be useful for some tests introduced in later patches. Tested-by: Alexander Stein # imx8mp Tested-by: Marek Szyprowski # exynos4210, meson g12b Signed-off-by: Maxime Ripard --- drivers/clk/clk-divider.c | 20 ++++++++++---------- drivers/clk/clk.c | 20 ++++++++++++++++++++ include/linux/clk-provider.h | 6 ++++++ 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index f6b2bf558486..a2c2b5203b0a 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -386,13 +386,13 @@ long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent, const struct clk_div_table *table, u8 width, unsigned long flags) { - struct clk_rate_request req = { - .rate = rate, - .best_parent_rate = *prate, - .best_parent_hw = parent, - }; + struct clk_rate_request req; int ret; + clk_hw_init_rate_request(hw, &req, rate); + req.best_parent_rate = *prate; + req.best_parent_hw = parent; + ret = divider_determine_rate(hw, &req, table, width, flags); if (ret) return ret; @@ -408,13 +408,13 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent, const struct clk_div_table *table, u8 width, unsigned long flags, unsigned int val) { - struct clk_rate_request req = { - .rate = rate, - .best_parent_rate = *prate, - .best_parent_hw = parent, - }; + struct clk_rate_request req; int ret; + clk_hw_init_rate_request(hw, &req, rate); + req.best_parent_rate = *prate; + req.best_parent_hw = parent; + ret = divider_ro_determine_rate(hw, &req, table, width, flags, val); if (ret) return ret; diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index e5ebcfcfe4eb..8952c5c71af2 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1400,6 +1400,26 @@ static void clk_core_init_rate_req(struct clk_core * const core, } } +/** + * clk_hw_init_rate_request - Initializes a clk_rate_request + * @hw: the clk for which we want to submit a rate request + * @req: the clk_rate_request structure we want to initialise + * @rate: the rate which is to be requested + * + * Initializes a clk_rate_request structure to submit to + * __clk_determine_rate() or similar functions. + */ +void clk_hw_init_rate_request(const struct clk_hw *hw, + struct clk_rate_request *req, + unsigned long rate) +{ + if (WARN_ON(!hw || !req)) + return; + + clk_core_init_rate_req(hw->core, req, rate); +} +EXPORT_SYMBOL_GPL(clk_hw_init_rate_request); + static bool clk_core_can_round(struct clk_core * const core) { return core->ops->determine_rate || core->ops->round_rate; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 58e5baa49db0..c8f25924fa05 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -42,6 +42,8 @@ struct dentry; * struct clk_rate_request - Structure encoding the clk constraints that * a clock user might require. * + * Should be initialized by calling clk_hw_init_rate_request(). + * * @rate: Requested clock rate. This field will be adjusted by * clock drivers according to hardware capabilities. * @min_rate: Minimum rate imposed by clk users. @@ -60,6 +62,10 @@ struct clk_rate_request { struct clk_hw *best_parent_hw; }; +void clk_hw_init_rate_request(const struct clk_hw *hw, + struct clk_rate_request *req, + unsigned long rate); + /** * struct clk_duty - Struture encoding the duty cycle ratio of a clock * -- 2.36.1