Skip to content

Commit 62021be

Browse files
masneybbebarino
authored andcommitted
clk: imx: pllv4: convert from round_rate() to determine_rate()
The round_rate() clk ops is deprecated, so migrate this driver from round_rate() to determine_rate() using the Coccinelle semantic patch on the cover letter of this series. Signed-off-by: Brian Masney <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent b2826d2 commit 62021be

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

drivers/clk/imx/clk-pllv4.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@ static unsigned long clk_pllv4_recalc_rate(struct clk_hw *hw,
9595
return (parent_rate * mult) + (u32)temp64;
9696
}
9797

98-
static long clk_pllv4_round_rate(struct clk_hw *hw, unsigned long rate,
99-
unsigned long *prate)
98+
static int clk_pllv4_determine_rate(struct clk_hw *hw,
99+
struct clk_rate_request *req)
100100
{
101101
struct clk_pllv4 *pll = to_clk_pllv4(hw);
102-
unsigned long parent_rate = *prate;
102+
unsigned long parent_rate = req->best_parent_rate;
103103
unsigned long round_rate, i;
104104
u32 mfn, mfd = DEFAULT_MFD;
105105
bool found = false;
106106
u64 temp64;
107107
u32 mult;
108108

109109
if (pll->use_mult_range) {
110-
temp64 = (u64)rate;
110+
temp64 = (u64) req->rate;
111111
do_div(temp64, parent_rate);
112112
mult = temp64;
113113
if (mult >= pllv4_mult_range[1] &&
@@ -118,7 +118,7 @@ static long clk_pllv4_round_rate(struct clk_hw *hw, unsigned long rate,
118118
} else {
119119
for (i = 0; i < ARRAY_SIZE(pllv4_mult_table); i++) {
120120
round_rate = parent_rate * pllv4_mult_table[i];
121-
if (rate >= round_rate) {
121+
if (req->rate >= round_rate) {
122122
found = true;
123123
break;
124124
}
@@ -127,14 +127,16 @@ static long clk_pllv4_round_rate(struct clk_hw *hw, unsigned long rate,
127127

128128
if (!found) {
129129
pr_warn("%s: unable to round rate %lu, parent rate %lu\n",
130-
clk_hw_get_name(hw), rate, parent_rate);
130+
clk_hw_get_name(hw), req->rate, parent_rate);
131+
req->rate = 0;
132+
131133
return 0;
132134
}
133135

134136
if (parent_rate <= MAX_MFD)
135137
mfd = parent_rate;
136138

137-
temp64 = (u64)(rate - round_rate);
139+
temp64 = (u64)(req->rate - round_rate);
138140
temp64 *= mfd;
139141
do_div(temp64, parent_rate);
140142
mfn = temp64;
@@ -145,14 +147,19 @@ static long clk_pllv4_round_rate(struct clk_hw *hw, unsigned long rate,
145147
* pair of mfn/mfd, we simply return the round_rate without using
146148
* the frac part.
147149
*/
148-
if (mfn >= mfd)
149-
return round_rate;
150+
if (mfn >= mfd) {
151+
req->rate = round_rate;
152+
153+
return 0;
154+
}
150155

151156
temp64 = (u64)parent_rate;
152157
temp64 *= mfn;
153158
do_div(temp64, mfd);
154159

155-
return round_rate + (u32)temp64;
160+
req->rate = round_rate + (u32)temp64;
161+
162+
return 0;
156163
}
157164

158165
static bool clk_pllv4_is_valid_mult(struct clk_pllv4 *pll, unsigned int mult)
@@ -229,7 +236,7 @@ static void clk_pllv4_unprepare(struct clk_hw *hw)
229236

230237
static const struct clk_ops clk_pllv4_ops = {
231238
.recalc_rate = clk_pllv4_recalc_rate,
232-
.round_rate = clk_pllv4_round_rate,
239+
.determine_rate = clk_pllv4_determine_rate,
233240
.set_rate = clk_pllv4_set_rate,
234241
.prepare = clk_pllv4_prepare,
235242
.unprepare = clk_pllv4_unprepare,

0 commit comments

Comments
 (0)