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

clk: vt8500: 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>

+35 -24
+35 -24
drivers/clk/clk-vt8500.c
··· 128 128 return parent_rate / div; 129 129 } 130 130 131 - static long vt8500_dclk_round_rate(struct clk_hw *hw, unsigned long rate, 132 - unsigned long *prate) 131 + static int vt8500_dclk_determine_rate(struct clk_hw *hw, 132 + struct clk_rate_request *req) 133 133 { 134 134 struct clk_device *cdev = to_clk_device(hw); 135 135 u32 divisor; 136 136 137 - if (rate == 0) 137 + if (req->rate == 0) 138 138 return 0; 139 139 140 - divisor = *prate / rate; 140 + divisor = req->best_parent_rate / req->rate; 141 141 142 142 /* If prate / rate would be decimal, incr the divisor */ 143 - if (rate * divisor < *prate) 143 + if (req->rate * divisor < req->best_parent_rate) 144 144 divisor++; 145 145 146 146 /* 147 147 * If this is a request for SDMMC we have to adjust the divisor 148 148 * when >31 to use the fixed predivisor 149 149 */ 150 - if ((cdev->div_mask == 0x3F) && (divisor > 31)) { 150 + if ((cdev->div_mask == 0x3F) && (divisor > 31)) 151 151 divisor = 64 * ((divisor / 64) + 1); 152 - } 153 152 154 - return *prate / divisor; 153 + req->rate = req->best_parent_rate / divisor; 154 + 155 + return 0; 155 156 } 156 157 157 158 static int vt8500_dclk_set_rate(struct clk_hw *hw, unsigned long rate, ··· 203 202 }; 204 203 205 204 static const struct clk_ops vt8500_divisor_clk_ops = { 206 - .round_rate = vt8500_dclk_round_rate, 205 + .determine_rate = vt8500_dclk_determine_rate, 207 206 .set_rate = vt8500_dclk_set_rate, 208 207 .recalc_rate = vt8500_dclk_recalc_rate, 209 208 }; ··· 212 211 .enable = vt8500_dclk_enable, 213 212 .disable = vt8500_dclk_disable, 214 213 .is_enabled = vt8500_dclk_is_enabled, 215 - .round_rate = vt8500_dclk_round_rate, 214 + .determine_rate = vt8500_dclk_determine_rate, 216 215 .set_rate = vt8500_dclk_set_rate, 217 216 .recalc_rate = vt8500_dclk_recalc_rate, 218 217 }; ··· 595 594 return 0; 596 595 } 597 596 598 - static long vtwm_pll_round_rate(struct clk_hw *hw, unsigned long rate, 599 - unsigned long *prate) 597 + static int vtwm_pll_determine_rate(struct clk_hw *hw, 598 + struct clk_rate_request *req) 600 599 { 601 600 struct clk_pll *pll = to_clk_pll(hw); 602 601 u32 filter, mul, div1, div2; ··· 605 604 606 605 switch (pll->type) { 607 606 case PLL_TYPE_VT8500: 608 - ret = vt8500_find_pll_bits(rate, *prate, &mul, &div1); 607 + ret = vt8500_find_pll_bits(req->rate, req->best_parent_rate, 608 + &mul, &div1); 609 609 if (!ret) 610 - round_rate = VT8500_BITS_TO_FREQ(*prate, mul, div1); 610 + round_rate = VT8500_BITS_TO_FREQ(req->best_parent_rate, 611 + mul, div1); 611 612 break; 612 613 case PLL_TYPE_WM8650: 613 - ret = wm8650_find_pll_bits(rate, *prate, &mul, &div1, &div2); 614 + ret = wm8650_find_pll_bits(req->rate, req->best_parent_rate, 615 + &mul, &div1, &div2); 614 616 if (!ret) 615 - round_rate = WM8650_BITS_TO_FREQ(*prate, mul, div1, div2); 617 + round_rate = WM8650_BITS_TO_FREQ(req->best_parent_rate, 618 + mul, div1, div2); 616 619 break; 617 620 case PLL_TYPE_WM8750: 618 - ret = wm8750_find_pll_bits(rate, *prate, &filter, &mul, &div1, &div2); 621 + ret = wm8750_find_pll_bits(req->rate, req->best_parent_rate, 622 + &filter, &mul, &div1, &div2); 619 623 if (!ret) 620 - round_rate = WM8750_BITS_TO_FREQ(*prate, mul, div1, div2); 624 + round_rate = WM8750_BITS_TO_FREQ(req->best_parent_rate, 625 + mul, div1, div2); 621 626 break; 622 627 case PLL_TYPE_WM8850: 623 - ret = wm8850_find_pll_bits(rate, *prate, &mul, &div1, &div2); 628 + ret = wm8850_find_pll_bits(req->rate, req->best_parent_rate, 629 + &mul, &div1, &div2); 624 630 if (!ret) 625 - round_rate = WM8850_BITS_TO_FREQ(*prate, mul, div1, div2); 631 + round_rate = WM8850_BITS_TO_FREQ(req->best_parent_rate, 632 + mul, div1, div2); 626 633 break; 627 634 default: 628 - ret = -EINVAL; 635 + return -EINVAL; 629 636 } 630 637 631 638 if (ret) 632 - return ret; 639 + req->rate = ret; 640 + else 641 + req->rate = round_rate; 633 642 634 - return round_rate; 643 + return 0; 635 644 } 636 645 637 646 static unsigned long vtwm_pll_recalc_rate(struct clk_hw *hw, ··· 676 665 } 677 666 678 667 static const struct clk_ops vtwm_pll_ops = { 679 - .round_rate = vtwm_pll_round_rate, 668 + .determine_rate = vtwm_pll_determine_rate, 680 669 .set_rate = vtwm_pll_set_rate, 681 670 .recalc_rate = vtwm_pll_recalc_rate, 682 671 };