summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@kernel.org>2026-04-12 02:36:44 +0300
committerStephen Boyd <sboyd@kernel.org>2026-04-12 02:36:44 +0300
commit7b6894e99f835a0fe0690ad801c4f7f0a06a4b07 (patch)
treea13e8291cc1e1eb49296dd71db6a626af69c7a35
parentc369299895a591d96745d6492d4888259b004a9e (diff)
parentd4851759742c1322f498021dab882d322fc34a1d (diff)
downloadlinux-7b6894e99f835a0fe0690ad801c4f7f0a06a4b07.tar.xz
Merge tag 'clk-remove-deprecated-apis-v7.1' of ssh://github.com/masneyb/linux into clk-round
Pull round_rate refactoring from Brian Masney: Now that all of the dependencies across the tree have been merged into Linus's tree, here's a small series with the following changes: - Converts clk-composite from round_rate() to determine_rate() - Removes the round_rate() clk op - Removes the deprecated functions divider_round_rate(), divider_round_rate_parent(), and divider_ro_round_rate_parent() since these are just wrappers for the corresponding determine_rate variant * tag 'clk-remove-deprecated-apis-v7.1' of ssh://github.com/masneyb/linux: clk: divider: remove divider_round_rate() and divider_round_rate_parent() clk: divider: remove divider_ro_round_rate_parent() clk: remove round_rate() clk ops clk: composite: convert from round_rate() to determine_rate() clk: test: remove references to clk_ops.round_rate
-rw-r--r--Documentation/driver-api/clk.rst9
-rw-r--r--drivers/clk/clk-composite.c38
-rw-r--r--drivers/clk/clk-divider.c44
-rw-r--r--drivers/clk/clk.c39
-rw-r--r--drivers/clk/clk_test.c16
-rw-r--r--include/linux/clk-provider.h46
6 files changed, 34 insertions, 158 deletions
diff --git a/Documentation/driver-api/clk.rst b/Documentation/driver-api/clk.rst
index 93bab5336dfd..c6aca8186a78 100644
--- a/Documentation/driver-api/clk.rst
+++ b/Documentation/driver-api/clk.rst
@@ -77,9 +77,6 @@ the operations defined in clk-provider.h::
void (*disable_unused)(struct clk_hw *hw);
unsigned long (*recalc_rate)(struct clk_hw *hw,
unsigned long parent_rate);
- long (*round_rate)(struct clk_hw *hw,
- unsigned long rate,
- unsigned long *parent_rate);
int (*determine_rate)(struct clk_hw *hw,
struct clk_rate_request *req);
int (*set_parent)(struct clk_hw *hw, u8 index);
@@ -220,9 +217,7 @@ optional or must be evaluated on a case-by-case basis.
+----------------+------+-------------+---------------+-------------+------+
|.recalc_rate | | y | | | |
+----------------+------+-------------+---------------+-------------+------+
- |.round_rate | | y [1]_ | | | |
- +----------------+------+-------------+---------------+-------------+------+
- |.determine_rate | | y [1]_ | | | |
+ |.determine_rate | | y | | | |
+----------------+------+-------------+---------------+-------------+------+
|.set_rate | | y | | | |
+----------------+------+-------------+---------------+-------------+------+
@@ -238,8 +233,6 @@ optional or must be evaluated on a case-by-case basis.
|.init | | | | | |
+----------------+------+-------------+---------------+-------------+------+
-.. [1] either one of round_rate or determine_rate is required.
-
Finally, register your clock at run-time with a hardware-specific
registration function. This function simply populates struct clk_foo's
data and then passes the common struct clk parameters to the framework
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index 44d010bccfb1..835b1e4e5869 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -47,22 +47,10 @@ static int clk_composite_determine_rate_for_parent(struct clk_hw *rate_hw,
struct clk_hw *parent_hw,
const struct clk_ops *rate_ops)
{
- long rate;
-
req->best_parent_hw = parent_hw;
req->best_parent_rate = clk_hw_get_rate(parent_hw);
- if (rate_ops->determine_rate)
- return rate_ops->determine_rate(rate_hw, req);
-
- rate = rate_ops->round_rate(rate_hw, req->rate,
- &req->best_parent_rate);
- if (rate < 0)
- return rate;
-
- req->rate = rate;
-
- return 0;
+ return rate_ops->determine_rate(rate_hw, req);
}
static int clk_composite_determine_rate(struct clk_hw *hw,
@@ -79,8 +67,7 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
unsigned long best_rate = 0;
int i, ret;
- if (rate_hw && rate_ops &&
- (rate_ops->determine_rate || rate_ops->round_rate) &&
+ if (rate_hw && rate_ops && rate_ops->determine_rate &&
mux_hw && mux_ops && mux_ops->set_parent) {
req->best_parent_hw = NULL;
@@ -150,18 +137,6 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
}
}
-static long clk_composite_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
-{
- struct clk_composite *composite = to_clk_composite(hw);
- const struct clk_ops *rate_ops = composite->rate_ops;
- struct clk_hw *rate_hw = composite->rate_hw;
-
- __clk_hw_set_clk(rate_hw, hw);
-
- return rate_ops->round_rate(rate_hw, rate, prate);
-}
-
static int clk_composite_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
@@ -288,17 +263,14 @@ static struct clk_hw *__clk_hw_register_composite(struct device *dev,
if (rate_ops->determine_rate)
clk_composite_ops->determine_rate =
clk_composite_determine_rate;
- else if (rate_ops->round_rate)
- clk_composite_ops->round_rate =
- clk_composite_round_rate;
- /* .set_rate requires either .round_rate or .determine_rate */
+ /* .set_rate requires .determine_rate */
if (rate_ops->set_rate) {
- if (rate_ops->determine_rate || rate_ops->round_rate)
+ if (rate_ops->determine_rate)
clk_composite_ops->set_rate =
clk_composite_set_rate;
else
- WARN(1, "%s: missing round_rate op is required\n",
+ WARN(1, "%s: missing determine_rate op is required\n",
__func__);
}
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 45e7ebde4a8b..b3b485d23ea8 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -387,50 +387,6 @@ int divider_ro_determine_rate(struct clk_hw *hw, struct clk_rate_request *req,
}
EXPORT_SYMBOL_GPL(divider_ro_determine_rate);
-long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
- unsigned long rate, unsigned long *prate,
- const struct clk_div_table *table,
- u8 width, unsigned long flags)
-{
- 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;
-
- *prate = req.best_parent_rate;
-
- return req.rate;
-}
-EXPORT_SYMBOL_GPL(divider_round_rate_parent);
-
-long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
- unsigned long rate, unsigned long *prate,
- const struct clk_div_table *table, u8 width,
- unsigned long flags, unsigned int val)
-{
- 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;
-
- *prate = req.best_parent_rate;
-
- return req.rate;
-}
-EXPORT_SYMBOL_GPL(divider_ro_round_rate_parent);
-
static int clk_divider_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 47093cda9df3..fd418dc988b1 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1560,8 +1560,6 @@ late_initcall_sync(clk_disable_unused);
static int clk_core_determine_round_nolock(struct clk_core *core,
struct clk_rate_request *req)
{
- long rate;
-
lockdep_assert_held(&prepare_lock);
if (!core)
@@ -1591,13 +1589,6 @@ static int clk_core_determine_round_nolock(struct clk_core *core,
req->rate = core->rate;
} else if (core->ops->determine_rate) {
return core->ops->determine_rate(core->hw, req);
- } else if (core->ops->round_rate) {
- rate = core->ops->round_rate(core->hw, req->rate,
- &req->best_parent_rate);
- if (rate < 0)
- return rate;
-
- req->rate = rate;
} else {
return -EINVAL;
}
@@ -1682,7 +1673,7 @@ EXPORT_SYMBOL_GPL(clk_hw_forward_rate_request);
static bool clk_core_can_round(struct clk_core * const core)
{
- return core->ops->determine_rate || core->ops->round_rate;
+ return core->ops->determine_rate;
}
static int clk_core_round_rate_nolock(struct clk_core *core,
@@ -1750,11 +1741,11 @@ EXPORT_SYMBOL_GPL(__clk_determine_rate);
* use.
*
* Context: prepare_lock must be held.
- * For clk providers to call from within clk_ops such as .round_rate,
+ * For clk providers to call from within clk_ops such as
* .determine_rate.
*
- * Return: returns rounded rate of hw clk if clk supports round_rate operation
- * else returns the parent rate.
+ * Return: returns rounded rate of hw clk if clk supports determine_rate
+ * operation; else returns the parent rate.
*/
unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate)
{
@@ -2569,12 +2560,13 @@ err:
*
* Setting the CLK_SET_RATE_PARENT flag allows the rate change operation to
* propagate up to clk's parent; whether or not this happens depends on the
- * outcome of clk's .round_rate implementation. If *parent_rate is unchanged
- * after calling .round_rate then upstream parent propagation is ignored. If
- * *parent_rate comes back with a new rate for clk's parent then we propagate
- * up to clk's parent and set its rate. Upward propagation will continue
- * until either a clk does not support the CLK_SET_RATE_PARENT flag or
- * .round_rate stops requesting changes to clk's parent_rate.
+ * outcome of clk's .determine_rate implementation. If req->best_parent_rate
+ * is unchanged after calling .determine_rate then upstream parent propagation
+ * is ignored. If req->best_parent_rate comes back with a new rate for clk's
+ * parent then we propagate up to clk's parent and set its rate. Upward
+ * propagation will continue until either a clk does not support the
+ * CLK_SET_RATE_PARENT flag or .determine_rate stops requesting changes to
+ * clk's parent_rate.
*
* Rate changes are accomplished via tree traversal that also recalculates the
* rates for the clocks and fires off POST_RATE_CHANGE notifiers.
@@ -2703,8 +2695,6 @@ static int clk_set_rate_range_nolock(struct clk *clk,
* FIXME:
* There is a catch. It may fail for the usual reason (clock
* broken, clock protected, etc) but also because:
- * - round_rate() was not favorable and fell on the wrong
- * side of the boundary
* - the determine_rate() callback does not really check for
* this corner case when determining the rate
*/
@@ -3915,10 +3905,9 @@ static int __clk_core_init(struct clk_core *core)
}
/* check that clk_ops are sane. See Documentation/driver-api/clk.rst */
- if (core->ops->set_rate &&
- !((core->ops->round_rate || core->ops->determine_rate) &&
- core->ops->recalc_rate)) {
- pr_err("%s: %s must implement .round_rate or .determine_rate in addition to .recalc_rate\n",
+ if (core->ops->set_rate && !core->ops->determine_rate &&
+ core->ops->recalc_rate) {
+ pr_err("%s: %s must implement .determine_rate in addition to .recalc_rate\n",
__func__, core->name);
ret = -EINVAL;
goto out;
diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
index a268d7b5d4cb..b1961daac5e2 100644
--- a/drivers/clk/clk_test.c
+++ b/drivers/clk/clk_test.c
@@ -241,8 +241,8 @@ static void clk_test_get_rate(struct kunit *test)
* Test that, after a call to clk_set_rate(), the rate returned by
* clk_get_rate() matches.
*
- * This assumes that clk_ops.determine_rate or clk_ops.round_rate won't
- * modify the requested rate, which is our case in clk_dummy_rate_ops.
+ * This assumes that clk_ops.determine_rate won't modify the requested rate,
+ * which is our case in clk_dummy_rate_ops.
*/
static void clk_test_set_get_rate(struct kunit *test)
{
@@ -266,8 +266,8 @@ static void clk_test_set_get_rate(struct kunit *test)
* Test that, after several calls to clk_set_rate(), the rate returned
* by clk_get_rate() matches the last one.
*
- * This assumes that clk_ops.determine_rate or clk_ops.round_rate won't
- * modify the requested rate, which is our case in clk_dummy_rate_ops.
+ * This assumes that clk_ops.determine_rate won't modify the requested rate,
+ * which is our case in clk_dummy_rate_ops.
*/
static void clk_test_set_set_get_rate(struct kunit *test)
{
@@ -1675,8 +1675,8 @@ static void clk_range_test_set_range_set_round_rate_consistent_higher(struct kun
* call to clk_set_rate_range(), the rate will be raised to match the
* new minimum.
*
- * This assumes that clk_ops.determine_rate or clk_ops.round_rate won't
- * modify the requested rate, which is our case in clk_dummy_rate_ops.
+ * This assumes that clk_ops.determine_rate won't modify the requested rate,
+ * which is our case in clk_dummy_rate_ops.
*/
static void clk_range_test_set_range_get_rate_raised(struct kunit *test)
{
@@ -1707,8 +1707,8 @@ static void clk_range_test_set_range_get_rate_raised(struct kunit *test)
* call to clk_set_rate_range(), the rate will be lowered to match the
* new maximum.
*
- * This assumes that clk_ops.determine_rate or clk_ops.round_rate won't
- * modify the requested rate, which is our case in clk_dummy_rate_ops.
+ * This assumes that clk_ops.determine_rate won't modify the requested rate,
+ * which is our case in clk_dummy_rate_ops.
*/
static void clk_range_test_set_range_get_rate_lowered(struct kunit *test)
{
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 630705a47129..4d21602d7dbd 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -136,10 +136,6 @@ struct clk_duty {
* 0. Returns the calculated rate. Optional, but recommended - if
* this op is not set then clock rate will be initialized to 0.
*
- * @round_rate: Given a target rate as input, returns the closest rate actually
- * supported by the clock. The parent rate is an input/output
- * parameter.
- *
* @determine_rate: Given a target rate as input, returns the closest rate
* actually supported by the clock, and optionally the parent clock
* that should be used to provide the clock rate.
@@ -163,13 +159,13 @@ struct clk_duty {
*
* @set_rate: Change the rate of this clock. The requested rate is specified
* by the second argument, which should typically be the return
- * of .round_rate call. The third argument gives the parent rate
- * which is likely helpful for most .set_rate implementation.
+ * of .determine_rate call. The third argument gives the parent
+ * rate which is likely helpful for most .set_rate implementation.
* Returns 0 on success, -EERROR otherwise.
*
* @set_rate_and_parent: Change the rate and the parent of this clock. The
* requested rate is specified by the second argument, which
- * should typically be the return of .round_rate call. The
+ * should typically be the return of clk_round_rate() call. The
* third argument gives the parent rate which is likely helpful
* for most .set_rate_and_parent implementation. The fourth
* argument gives the parent index. This callback is optional (and
@@ -244,8 +240,6 @@ struct clk_ops {
void (*restore_context)(struct clk_hw *hw);
unsigned long (*recalc_rate)(struct clk_hw *hw,
unsigned long parent_rate);
- long (*round_rate)(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate);
int (*determine_rate)(struct clk_hw *hw,
struct clk_rate_request *req);
int (*set_parent)(struct clk_hw *hw, u8 index);
@@ -679,7 +673,7 @@ struct clk_div_table {
* @lock: register lock
*
* Clock with an adjustable divider affecting its output frequency. Implements
- * .recalc_rate, .set_rate and .round_rate
+ * .recalc_rate, .set_rate and .determine_rate
*
* @flags:
* CLK_DIVIDER_ONE_BASED - by default the divisor is the value read from the
@@ -739,14 +733,6 @@ extern const struct clk_ops clk_divider_ro_ops;
unsigned long divider_recalc_rate(struct clk_hw *hw, unsigned long parent_rate,
unsigned int val, const struct clk_div_table *table,
unsigned long flags, unsigned long width);
-long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
- unsigned long rate, unsigned long *prate,
- const struct clk_div_table *table,
- u8 width, unsigned long flags);
-long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
- unsigned long rate, unsigned long *prate,
- const struct clk_div_table *table, u8 width,
- unsigned long flags, unsigned int val);
int divider_determine_rate(struct clk_hw *hw, struct clk_rate_request *req,
const struct clk_div_table *table, u8 width,
unsigned long flags);
@@ -1126,7 +1112,7 @@ void of_fixed_factor_clk_setup(struct device_node *node);
*
* Clock with a fixed multiplier and divider. The output frequency is the
* parent clock rate divided by div and multiplied by mult.
- * Implements .recalc_rate, .set_rate, .round_rate and .recalc_accuracy
+ * Implements .recalc_rate, .set_rate, .determine_rate and .recalc_accuracy
*
* Flags:
* * CLK_FIXED_FACTOR_FIXED_ACCURACY - Use the value in @acc instead of the
@@ -1254,7 +1240,7 @@ void clk_hw_unregister_fractional_divider(struct clk_hw *hw);
* @lock: register lock
*
* Clock with an adjustable multiplier affecting its output frequency.
- * Implements .recalc_rate, .set_rate and .round_rate
+ * Implements .recalc_rate, .set_rate and .determine_rate
*
* @flags:
* CLK_MULTIPLIER_ZERO_BYPASS - By default, the multiplier is the value read
@@ -1437,26 +1423,6 @@ static inline void __clk_hw_set_clk(struct clk_hw *dst, struct clk_hw *src)
dst->core = src->core;
}
-static inline long divider_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate,
- const struct clk_div_table *table,
- u8 width, unsigned long flags)
-{
- return divider_round_rate_parent(hw, clk_hw_get_parent(hw),
- rate, prate, table, width, flags);
-}
-
-static inline long divider_ro_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate,
- const struct clk_div_table *table,
- u8 width, unsigned long flags,
- unsigned int val)
-{
- return divider_ro_round_rate_parent(hw, clk_hw_get_parent(hw),
- rate, prate, table, width, flags,
- val);
-}
-
/*
* FIXME clock api without lock protection
*/