Skip to content

Commit c35e84b

Browse files
mripardbebarino
authored andcommitted
clk: Introduce clk_hw_init_rate_request()
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 <alexander.stein@ew.tq-group.com> # imx8mp Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> # exynos4210, meson g12b Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220816112530.1837489-17-maxime@cerno.tech Tested-by: Linux Kernel Functional Testing <lkft@linaro.org> Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 8cd9c39 commit c35e84b

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

drivers/clk/clk-divider.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
386386
const struct clk_div_table *table,
387387
u8 width, unsigned long flags)
388388
{
389-
struct clk_rate_request req = {
390-
.rate = rate,
391-
.best_parent_rate = *prate,
392-
.best_parent_hw = parent,
393-
};
389+
struct clk_rate_request req;
394390
int ret;
395391

392+
clk_hw_init_rate_request(hw, &req, rate);
393+
req.best_parent_rate = *prate;
394+
req.best_parent_hw = parent;
395+
396396
ret = divider_determine_rate(hw, &req, table, width, flags);
397397
if (ret)
398398
return ret;
@@ -408,13 +408,13 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
408408
const struct clk_div_table *table, u8 width,
409409
unsigned long flags, unsigned int val)
410410
{
411-
struct clk_rate_request req = {
412-
.rate = rate,
413-
.best_parent_rate = *prate,
414-
.best_parent_hw = parent,
415-
};
411+
struct clk_rate_request req;
416412
int ret;
417413

414+
clk_hw_init_rate_request(hw, &req, rate);
415+
req.best_parent_rate = *prate;
416+
req.best_parent_hw = parent;
417+
418418
ret = divider_ro_determine_rate(hw, &req, table, width, flags, val);
419419
if (ret)
420420
return ret;

drivers/clk/clk.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,26 @@ static void clk_core_init_rate_req(struct clk_core * const core,
14001400
}
14011401
}
14021402

1403+
/**
1404+
* clk_hw_init_rate_request - Initializes a clk_rate_request
1405+
* @hw: the clk for which we want to submit a rate request
1406+
* @req: the clk_rate_request structure we want to initialise
1407+
* @rate: the rate which is to be requested
1408+
*
1409+
* Initializes a clk_rate_request structure to submit to
1410+
* __clk_determine_rate() or similar functions.
1411+
*/
1412+
void clk_hw_init_rate_request(const struct clk_hw *hw,
1413+
struct clk_rate_request *req,
1414+
unsigned long rate)
1415+
{
1416+
if (WARN_ON(!hw || !req))
1417+
return;
1418+
1419+
clk_core_init_rate_req(hw->core, req, rate);
1420+
}
1421+
EXPORT_SYMBOL_GPL(clk_hw_init_rate_request);
1422+
14031423
static bool clk_core_can_round(struct clk_core * const core)
14041424
{
14051425
return core->ops->determine_rate || core->ops->round_rate;

include/linux/clk-provider.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ struct dentry;
4242
* struct clk_rate_request - Structure encoding the clk constraints that
4343
* a clock user might require.
4444
*
45+
* Should be initialized by calling clk_hw_init_rate_request().
46+
*
4547
* @rate: Requested clock rate. This field will be adjusted by
4648
* clock drivers according to hardware capabilities.
4749
* @min_rate: Minimum rate imposed by clk users.
@@ -60,6 +62,10 @@ struct clk_rate_request {
6062
struct clk_hw *best_parent_hw;
6163
};
6264

65+
void clk_hw_init_rate_request(const struct clk_hw *hw,
66+
struct clk_rate_request *req,
67+
unsigned long rate);
68+
6369
/**
6470
* struct clk_duty - Struture encoding the duty cycle ratio of a clock
6571
*

0 commit comments

Comments
 (0)