Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: max9485: 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 <bmasney@redhat.com>

+17 -10
+17 -10
drivers/clk/clk-max9485.c
··· 159 159 return 0; 160 160 } 161 161 162 - static long max9485_clkout_round_rate(struct clk_hw *hw, unsigned long rate, 163 - unsigned long *parent_rate) 162 + static int max9485_clkout_determine_rate(struct clk_hw *hw, 163 + struct clk_rate_request *req) 164 164 { 165 165 const struct max9485_rate *curr, *prev = NULL; 166 166 167 167 for (curr = max9485_rates; curr->out != 0; curr++) { 168 168 /* Exact matches */ 169 - if (curr->out == rate) 170 - return rate; 169 + if (curr->out == req->rate) 170 + return 0; 171 171 172 172 /* 173 173 * Find the first entry that has a frequency higher than the 174 174 * requested one. 175 175 */ 176 - if (curr->out > rate) { 176 + if (curr->out > req->rate) { 177 177 unsigned int mid; 178 178 179 179 /* 180 180 * If this is the first entry, clamp the value to the 181 181 * lowest possible frequency. 182 182 */ 183 - if (!prev) 184 - return curr->out; 183 + if (!prev) { 184 + req->rate = curr->out; 185 + 186 + return 0; 187 + } 185 188 186 189 /* 187 190 * Otherwise, determine whether the previous entry or ··· 192 189 */ 193 190 mid = prev->out + ((curr->out - prev->out) / 2); 194 191 195 - return (mid > rate) ? prev->out : curr->out; 192 + req->rate = mid > req->rate ? prev->out : curr->out; 193 + 194 + return 0; 196 195 } 197 196 198 197 prev = curr; 199 198 } 200 199 201 200 /* If the last entry was still too high, clamp the value */ 202 - return prev->out; 201 + req->rate = prev->out; 202 + 203 + return 0; 203 204 } 204 205 205 206 struct max9485_clk { ··· 228 221 .parent_index = -1, 229 222 .ops = { 230 223 .set_rate = max9485_clkout_set_rate, 231 - .round_rate = max9485_clkout_round_rate, 224 + .determine_rate = max9485_clkout_determine_rate, 232 225 .recalc_rate = max9485_clkout_recalc_rate, 233 226 }, 234 227 },