aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-03-11 22:12:34 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-03-16 15:37:47 -0400
commit829ecbcb14edea378a1409203ef0d4a68bbf795a (patch)
tree2eba2d48ef84f54d5b6efe69f02d673b91ec0a29 /drivers
parent1b1247dd75aa5cf5fae54a3bec7280046e9c7957 (diff)
mfd: Use DIV_ROUND_CLOSEST for sm501 clock
Use DIV_ROUND_CLOSEST to replace sm501fb_round_div function. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/sm501.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index f4d86117f44a..d927dd49acb3 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -387,14 +387,6 @@ int sm501_unit_power(struct device *dev, unsigned int unit, unsigned int to)
387 387
388EXPORT_SYMBOL_GPL(sm501_unit_power); 388EXPORT_SYMBOL_GPL(sm501_unit_power);
389 389
390
391/* Perform a rounded division. */
392static long sm501fb_round_div(long num, long denom)
393{
394 /* n / d + 1 / 2 = (2n + d) / 2d */
395 return (2 * num + denom) / (2 * denom);
396}
397
398/* clock value structure. */ 390/* clock value structure. */
399struct sm501_clock { 391struct sm501_clock {
400 unsigned long mclk; 392 unsigned long mclk;
@@ -428,7 +420,7 @@ static int sm501_calc_clock(unsigned long freq,
428 /* try all 8 shift values.*/ 420 /* try all 8 shift values.*/
429 for (shift = 0; shift < 8; shift++) { 421 for (shift = 0; shift < 8; shift++) {
430 /* Calculate difference to requested clock */ 422 /* Calculate difference to requested clock */
431 diff = sm501fb_round_div(mclk, divider << shift) - freq; 423 diff = DIV_ROUND_CLOSEST(mclk, divider << shift) - freq;
432 if (diff < 0) 424 if (diff < 0)
433 diff = -diff; 425 diff = -diff;
434 426