Skip to content

Commit 80395c3

Browse files
masneybwens
authored andcommitted
clk: sunxi-ng: ccu_nm: 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. I manually fixed up one minor formatting issue that occurred after applying the semantic patch: req->rate = ccu_nm_find_best(&nm->common, req->best_parent_rate, req->rate, &_nm); I manually changed it to: req->rate = ccu_nm_find_best(&nm->common, req->best_parent_rate, req->rate, &_nm); Signed-off-by: Brian Masney <[email protected]> Reviewed-by: Maxime Ripard <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Chen-Yu Tsai <[email protected]>
1 parent 8bc614c commit 80395c3

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

drivers/clk/sunxi-ng/ccu_nm.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,52 +116,53 @@ static unsigned long ccu_nm_recalc_rate(struct clk_hw *hw,
116116
return rate;
117117
}
118118

119-
static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
120-
unsigned long *parent_rate)
119+
static int ccu_nm_determine_rate(struct clk_hw *hw,
120+
struct clk_rate_request *req)
121121
{
122122
struct ccu_nm *nm = hw_to_ccu_nm(hw);
123123
struct _ccu_nm _nm;
124124

125125
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
126-
rate *= nm->fixed_post_div;
126+
req->rate *= nm->fixed_post_div;
127127

128-
if (rate < nm->min_rate) {
129-
rate = nm->min_rate;
128+
if (req->rate < nm->min_rate) {
129+
req->rate = nm->min_rate;
130130
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
131-
rate /= nm->fixed_post_div;
132-
return rate;
131+
req->rate /= nm->fixed_post_div;
132+
return 0;
133133
}
134134

135-
if (nm->max_rate && rate > nm->max_rate) {
136-
rate = nm->max_rate;
135+
if (nm->max_rate && req->rate > nm->max_rate) {
136+
req->rate = nm->max_rate;
137137
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
138-
rate /= nm->fixed_post_div;
139-
return rate;
138+
req->rate /= nm->fixed_post_div;
139+
return 0;
140140
}
141141

142-
if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) {
142+
if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, req->rate)) {
143143
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
144-
rate /= nm->fixed_post_div;
145-
return rate;
144+
req->rate /= nm->fixed_post_div;
145+
return 0;
146146
}
147147

148-
if (ccu_sdm_helper_has_rate(&nm->common, &nm->sdm, rate)) {
148+
if (ccu_sdm_helper_has_rate(&nm->common, &nm->sdm, req->rate)) {
149149
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
150-
rate /= nm->fixed_post_div;
151-
return rate;
150+
req->rate /= nm->fixed_post_div;
151+
return 0;
152152
}
153153

154154
_nm.min_n = nm->n.min ?: 1;
155155
_nm.max_n = nm->n.max ?: 1 << nm->n.width;
156156
_nm.min_m = 1;
157157
_nm.max_m = nm->m.max ?: 1 << nm->m.width;
158158

159-
rate = ccu_nm_find_best(&nm->common, *parent_rate, rate, &_nm);
159+
req->rate = ccu_nm_find_best(&nm->common, req->best_parent_rate,
160+
req->rate, &_nm);
160161

161162
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
162-
rate /= nm->fixed_post_div;
163+
req->rate /= nm->fixed_post_div;
163164

164-
return rate;
165+
return 0;
165166
}
166167

167168
static int ccu_nm_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -233,7 +234,7 @@ const struct clk_ops ccu_nm_ops = {
233234
.is_enabled = ccu_nm_is_enabled,
234235

235236
.recalc_rate = ccu_nm_recalc_rate,
236-
.round_rate = ccu_nm_round_rate,
237+
.determine_rate = ccu_nm_determine_rate,
237238
.set_rate = ccu_nm_set_rate,
238239
};
239240
EXPORT_SYMBOL_NS_GPL(ccu_nm_ops, "SUNXI_CCU");

0 commit comments

Comments
 (0)