Skip to content

Commit 7b6894e

Browse files
committed
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
2 parents c369299 + d485175 commit 7b6894e

6 files changed

Lines changed: 34 additions & 158 deletions

File tree

Documentation/driver-api/clk.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ the operations defined in clk-provider.h::
7777
void (*disable_unused)(struct clk_hw *hw);
7878
unsigned long (*recalc_rate)(struct clk_hw *hw,
7979
unsigned long parent_rate);
80-
long (*round_rate)(struct clk_hw *hw,
81-
unsigned long rate,
82-
unsigned long *parent_rate);
8380
int (*determine_rate)(struct clk_hw *hw,
8481
struct clk_rate_request *req);
8582
int (*set_parent)(struct clk_hw *hw, u8 index);
@@ -220,9 +217,7 @@ optional or must be evaluated on a case-by-case basis.
220217
+----------------+------+-------------+---------------+-------------+------+
221218
|.recalc_rate | | y | | | |
222219
+----------------+------+-------------+---------------+-------------+------+
223-
|.round_rate | | y [1]_ | | | |
224-
+----------------+------+-------------+---------------+-------------+------+
225-
|.determine_rate | | y [1]_ | | | |
220+
|.determine_rate | | y | | | |
226221
+----------------+------+-------------+---------------+-------------+------+
227222
|.set_rate | | y | | | |
228223
+----------------+------+-------------+---------------+-------------+------+
@@ -238,8 +233,6 @@ optional or must be evaluated on a case-by-case basis.
238233
|.init | | | | | |
239234
+----------------+------+-------------+---------------+-------------+------+
240235

241-
.. [1] either one of round_rate or determine_rate is required.
242-
243236
Finally, register your clock at run-time with a hardware-specific
244237
registration function. This function simply populates struct clk_foo's
245238
data and then passes the common struct clk parameters to the framework

drivers/clk/clk-composite.c

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,10 @@ static int clk_composite_determine_rate_for_parent(struct clk_hw *rate_hw,
4747
struct clk_hw *parent_hw,
4848
const struct clk_ops *rate_ops)
4949
{
50-
long rate;
51-
5250
req->best_parent_hw = parent_hw;
5351
req->best_parent_rate = clk_hw_get_rate(parent_hw);
5452

55-
if (rate_ops->determine_rate)
56-
return rate_ops->determine_rate(rate_hw, req);
57-
58-
rate = rate_ops->round_rate(rate_hw, req->rate,
59-
&req->best_parent_rate);
60-
if (rate < 0)
61-
return rate;
62-
63-
req->rate = rate;
64-
65-
return 0;
53+
return rate_ops->determine_rate(rate_hw, req);
6654
}
6755

6856
static int clk_composite_determine_rate(struct clk_hw *hw,
@@ -79,8 +67,7 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
7967
unsigned long best_rate = 0;
8068
int i, ret;
8169

82-
if (rate_hw && rate_ops &&
83-
(rate_ops->determine_rate || rate_ops->round_rate) &&
70+
if (rate_hw && rate_ops && rate_ops->determine_rate &&
8471
mux_hw && mux_ops && mux_ops->set_parent) {
8572
req->best_parent_hw = NULL;
8673

@@ -150,18 +137,6 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
150137
}
151138
}
152139

153-
static long clk_composite_round_rate(struct clk_hw *hw, unsigned long rate,
154-
unsigned long *prate)
155-
{
156-
struct clk_composite *composite = to_clk_composite(hw);
157-
const struct clk_ops *rate_ops = composite->rate_ops;
158-
struct clk_hw *rate_hw = composite->rate_hw;
159-
160-
__clk_hw_set_clk(rate_hw, hw);
161-
162-
return rate_ops->round_rate(rate_hw, rate, prate);
163-
}
164-
165140
static int clk_composite_set_rate(struct clk_hw *hw, unsigned long rate,
166141
unsigned long parent_rate)
167142
{
@@ -288,17 +263,14 @@ static struct clk_hw *__clk_hw_register_composite(struct device *dev,
288263
if (rate_ops->determine_rate)
289264
clk_composite_ops->determine_rate =
290265
clk_composite_determine_rate;
291-
else if (rate_ops->round_rate)
292-
clk_composite_ops->round_rate =
293-
clk_composite_round_rate;
294266

295-
/* .set_rate requires either .round_rate or .determine_rate */
267+
/* .set_rate requires .determine_rate */
296268
if (rate_ops->set_rate) {
297-
if (rate_ops->determine_rate || rate_ops->round_rate)
269+
if (rate_ops->determine_rate)
298270
clk_composite_ops->set_rate =
299271
clk_composite_set_rate;
300272
else
301-
WARN(1, "%s: missing round_rate op is required\n",
273+
WARN(1, "%s: missing determine_rate op is required\n",
302274
__func__);
303275
}
304276

drivers/clk/clk-divider.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -387,50 +387,6 @@ int divider_ro_determine_rate(struct clk_hw *hw, struct clk_rate_request *req,
387387
}
388388
EXPORT_SYMBOL_GPL(divider_ro_determine_rate);
389389

390-
long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
391-
unsigned long rate, unsigned long *prate,
392-
const struct clk_div_table *table,
393-
u8 width, unsigned long flags)
394-
{
395-
struct clk_rate_request req;
396-
int ret;
397-
398-
clk_hw_init_rate_request(hw, &req, rate);
399-
req.best_parent_rate = *prate;
400-
req.best_parent_hw = parent;
401-
402-
ret = divider_determine_rate(hw, &req, table, width, flags);
403-
if (ret)
404-
return ret;
405-
406-
*prate = req.best_parent_rate;
407-
408-
return req.rate;
409-
}
410-
EXPORT_SYMBOL_GPL(divider_round_rate_parent);
411-
412-
long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
413-
unsigned long rate, unsigned long *prate,
414-
const struct clk_div_table *table, u8 width,
415-
unsigned long flags, unsigned int val)
416-
{
417-
struct clk_rate_request req;
418-
int ret;
419-
420-
clk_hw_init_rate_request(hw, &req, rate);
421-
req.best_parent_rate = *prate;
422-
req.best_parent_hw = parent;
423-
424-
ret = divider_ro_determine_rate(hw, &req, table, width, flags, val);
425-
if (ret)
426-
return ret;
427-
428-
*prate = req.best_parent_rate;
429-
430-
return req.rate;
431-
}
432-
EXPORT_SYMBOL_GPL(divider_ro_round_rate_parent);
433-
434390
static int clk_divider_determine_rate(struct clk_hw *hw,
435391
struct clk_rate_request *req)
436392
{

drivers/clk/clk.c

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,6 @@ late_initcall_sync(clk_disable_unused);
15601560
static int clk_core_determine_round_nolock(struct clk_core *core,
15611561
struct clk_rate_request *req)
15621562
{
1563-
long rate;
1564-
15651563
lockdep_assert_held(&prepare_lock);
15661564

15671565
if (!core)
@@ -1591,13 +1589,6 @@ static int clk_core_determine_round_nolock(struct clk_core *core,
15911589
req->rate = core->rate;
15921590
} else if (core->ops->determine_rate) {
15931591
return core->ops->determine_rate(core->hw, req);
1594-
} else if (core->ops->round_rate) {
1595-
rate = core->ops->round_rate(core->hw, req->rate,
1596-
&req->best_parent_rate);
1597-
if (rate < 0)
1598-
return rate;
1599-
1600-
req->rate = rate;
16011592
} else {
16021593
return -EINVAL;
16031594
}
@@ -1682,7 +1673,7 @@ EXPORT_SYMBOL_GPL(clk_hw_forward_rate_request);
16821673

16831674
static bool clk_core_can_round(struct clk_core * const core)
16841675
{
1685-
return core->ops->determine_rate || core->ops->round_rate;
1676+
return core->ops->determine_rate;
16861677
}
16871678

16881679
static int clk_core_round_rate_nolock(struct clk_core *core,
@@ -1750,11 +1741,11 @@ EXPORT_SYMBOL_GPL(__clk_determine_rate);
17501741
* use.
17511742
*
17521743
* Context: prepare_lock must be held.
1753-
* For clk providers to call from within clk_ops such as .round_rate,
1744+
* For clk providers to call from within clk_ops such as
17541745
* .determine_rate.
17551746
*
1756-
* Return: returns rounded rate of hw clk if clk supports round_rate operation
1757-
* else returns the parent rate.
1747+
* Return: returns rounded rate of hw clk if clk supports determine_rate
1748+
* operation; else returns the parent rate.
17581749
*/
17591750
unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate)
17601751
{
@@ -2569,12 +2560,13 @@ static int clk_core_set_rate_nolock(struct clk_core *core,
25692560
*
25702561
* Setting the CLK_SET_RATE_PARENT flag allows the rate change operation to
25712562
* propagate up to clk's parent; whether or not this happens depends on the
2572-
* outcome of clk's .round_rate implementation. If *parent_rate is unchanged
2573-
* after calling .round_rate then upstream parent propagation is ignored. If
2574-
* *parent_rate comes back with a new rate for clk's parent then we propagate
2575-
* up to clk's parent and set its rate. Upward propagation will continue
2576-
* until either a clk does not support the CLK_SET_RATE_PARENT flag or
2577-
* .round_rate stops requesting changes to clk's parent_rate.
2563+
* outcome of clk's .determine_rate implementation. If req->best_parent_rate
2564+
* is unchanged after calling .determine_rate then upstream parent propagation
2565+
* is ignored. If req->best_parent_rate comes back with a new rate for clk's
2566+
* parent then we propagate up to clk's parent and set its rate. Upward
2567+
* propagation will continue until either a clk does not support the
2568+
* CLK_SET_RATE_PARENT flag or .determine_rate stops requesting changes to
2569+
* clk's parent_rate.
25782570
*
25792571
* Rate changes are accomplished via tree traversal that also recalculates the
25802572
* 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,
27032695
* FIXME:
27042696
* There is a catch. It may fail for the usual reason (clock
27052697
* broken, clock protected, etc) but also because:
2706-
* - round_rate() was not favorable and fell on the wrong
2707-
* side of the boundary
27082698
* - the determine_rate() callback does not really check for
27092699
* this corner case when determining the rate
27102700
*/
@@ -3915,10 +3905,9 @@ static int __clk_core_init(struct clk_core *core)
39153905
}
39163906

39173907
/* check that clk_ops are sane. See Documentation/driver-api/clk.rst */
3918-
if (core->ops->set_rate &&
3919-
!((core->ops->round_rate || core->ops->determine_rate) &&
3920-
core->ops->recalc_rate)) {
3921-
pr_err("%s: %s must implement .round_rate or .determine_rate in addition to .recalc_rate\n",
3908+
if (core->ops->set_rate && !core->ops->determine_rate &&
3909+
core->ops->recalc_rate) {
3910+
pr_err("%s: %s must implement .determine_rate in addition to .recalc_rate\n",
39223911
__func__, core->name);
39233912
ret = -EINVAL;
39243913
goto out;

drivers/clk/clk_test.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ static void clk_test_get_rate(struct kunit *test)
241241
* Test that, after a call to clk_set_rate(), the rate returned by
242242
* clk_get_rate() matches.
243243
*
244-
* This assumes that clk_ops.determine_rate or clk_ops.round_rate won't
245-
* modify the requested rate, which is our case in clk_dummy_rate_ops.
244+
* This assumes that clk_ops.determine_rate won't modify the requested rate,
245+
* which is our case in clk_dummy_rate_ops.
246246
*/
247247
static void clk_test_set_get_rate(struct kunit *test)
248248
{
@@ -266,8 +266,8 @@ static void clk_test_set_get_rate(struct kunit *test)
266266
* Test that, after several calls to clk_set_rate(), the rate returned
267267
* by clk_get_rate() matches the last one.
268268
*
269-
* This assumes that clk_ops.determine_rate or clk_ops.round_rate won't
270-
* modify the requested rate, which is our case in clk_dummy_rate_ops.
269+
* This assumes that clk_ops.determine_rate won't modify the requested rate,
270+
* which is our case in clk_dummy_rate_ops.
271271
*/
272272
static void clk_test_set_set_get_rate(struct kunit *test)
273273
{
@@ -1675,8 +1675,8 @@ static void clk_range_test_set_range_set_round_rate_consistent_higher(struct kun
16751675
* call to clk_set_rate_range(), the rate will be raised to match the
16761676
* new minimum.
16771677
*
1678-
* This assumes that clk_ops.determine_rate or clk_ops.round_rate won't
1679-
* modify the requested rate, which is our case in clk_dummy_rate_ops.
1678+
* This assumes that clk_ops.determine_rate won't modify the requested rate,
1679+
* which is our case in clk_dummy_rate_ops.
16801680
*/
16811681
static void clk_range_test_set_range_get_rate_raised(struct kunit *test)
16821682
{
@@ -1707,8 +1707,8 @@ static void clk_range_test_set_range_get_rate_raised(struct kunit *test)
17071707
* call to clk_set_rate_range(), the rate will be lowered to match the
17081708
* new maximum.
17091709
*
1710-
* This assumes that clk_ops.determine_rate or clk_ops.round_rate won't
1711-
* modify the requested rate, which is our case in clk_dummy_rate_ops.
1710+
* This assumes that clk_ops.determine_rate won't modify the requested rate,
1711+
* which is our case in clk_dummy_rate_ops.
17121712
*/
17131713
static void clk_range_test_set_range_get_rate_lowered(struct kunit *test)
17141714
{

include/linux/clk-provider.h

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ struct clk_duty {
136136
* 0. Returns the calculated rate. Optional, but recommended - if
137137
* this op is not set then clock rate will be initialized to 0.
138138
*
139-
* @round_rate: Given a target rate as input, returns the closest rate actually
140-
* supported by the clock. The parent rate is an input/output
141-
* parameter.
142-
*
143139
* @determine_rate: Given a target rate as input, returns the closest rate
144140
* actually supported by the clock, and optionally the parent clock
145141
* that should be used to provide the clock rate.
@@ -163,13 +159,13 @@ struct clk_duty {
163159
*
164160
* @set_rate: Change the rate of this clock. The requested rate is specified
165161
* by the second argument, which should typically be the return
166-
* of .round_rate call. The third argument gives the parent rate
167-
* which is likely helpful for most .set_rate implementation.
162+
* of .determine_rate call. The third argument gives the parent
163+
* rate which is likely helpful for most .set_rate implementation.
168164
* Returns 0 on success, -EERROR otherwise.
169165
*
170166
* @set_rate_and_parent: Change the rate and the parent of this clock. The
171167
* requested rate is specified by the second argument, which
172-
* should typically be the return of .round_rate call. The
168+
* should typically be the return of clk_round_rate() call. The
173169
* third argument gives the parent rate which is likely helpful
174170
* for most .set_rate_and_parent implementation. The fourth
175171
* argument gives the parent index. This callback is optional (and
@@ -244,8 +240,6 @@ struct clk_ops {
244240
void (*restore_context)(struct clk_hw *hw);
245241
unsigned long (*recalc_rate)(struct clk_hw *hw,
246242
unsigned long parent_rate);
247-
long (*round_rate)(struct clk_hw *hw, unsigned long rate,
248-
unsigned long *parent_rate);
249243
int (*determine_rate)(struct clk_hw *hw,
250244
struct clk_rate_request *req);
251245
int (*set_parent)(struct clk_hw *hw, u8 index);
@@ -679,7 +673,7 @@ struct clk_div_table {
679673
* @lock: register lock
680674
*
681675
* Clock with an adjustable divider affecting its output frequency. Implements
682-
* .recalc_rate, .set_rate and .round_rate
676+
* .recalc_rate, .set_rate and .determine_rate
683677
*
684678
* @flags:
685679
* 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;
739733
unsigned long divider_recalc_rate(struct clk_hw *hw, unsigned long parent_rate,
740734
unsigned int val, const struct clk_div_table *table,
741735
unsigned long flags, unsigned long width);
742-
long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
743-
unsigned long rate, unsigned long *prate,
744-
const struct clk_div_table *table,
745-
u8 width, unsigned long flags);
746-
long divider_ro_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
747-
unsigned long rate, unsigned long *prate,
748-
const struct clk_div_table *table, u8 width,
749-
unsigned long flags, unsigned int val);
750736
int divider_determine_rate(struct clk_hw *hw, struct clk_rate_request *req,
751737
const struct clk_div_table *table, u8 width,
752738
unsigned long flags);
@@ -1126,7 +1112,7 @@ void of_fixed_factor_clk_setup(struct device_node *node);
11261112
*
11271113
* Clock with a fixed multiplier and divider. The output frequency is the
11281114
* parent clock rate divided by div and multiplied by mult.
1129-
* Implements .recalc_rate, .set_rate, .round_rate and .recalc_accuracy
1115+
* Implements .recalc_rate, .set_rate, .determine_rate and .recalc_accuracy
11301116
*
11311117
* Flags:
11321118
* * 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);
12541240
* @lock: register lock
12551241
*
12561242
* Clock with an adjustable multiplier affecting its output frequency.
1257-
* Implements .recalc_rate, .set_rate and .round_rate
1243+
* Implements .recalc_rate, .set_rate and .determine_rate
12581244
*
12591245
* @flags:
12601246
* 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)
14371423
dst->core = src->core;
14381424
}
14391425

1440-
static inline long divider_round_rate(struct clk_hw *hw, unsigned long rate,
1441-
unsigned long *prate,
1442-
const struct clk_div_table *table,
1443-
u8 width, unsigned long flags)
1444-
{
1445-
return divider_round_rate_parent(hw, clk_hw_get_parent(hw),
1446-
rate, prate, table, width, flags);
1447-
}
1448-
1449-
static inline long divider_ro_round_rate(struct clk_hw *hw, unsigned long rate,
1450-
unsigned long *prate,
1451-
const struct clk_div_table *table,
1452-
u8 width, unsigned long flags,
1453-
unsigned int val)
1454-
{
1455-
return divider_ro_round_rate_parent(hw, clk_hw_get_parent(hw),
1456-
rate, prate, table, width, flags,
1457-
val);
1458-
}
1459-
14601426
/*
14611427
* FIXME clock api without lock protection
14621428
*/

0 commit comments

Comments
 (0)