Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
mfd: Use DIV_ROUND_CLOSEST for sm501 clock
Browse files Browse the repository at this point in the history
Use DIV_ROUND_CLOSEST to replace sm501fb_round_div function.

Signed-off-by: Axel Lin <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
AxelLin authored and Samuel Ortiz committed Mar 16, 2012
1 parent 1b1247d commit 829ecbc
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions drivers/mfd/sm501.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,6 @@ int sm501_unit_power(struct device *dev, unsigned int unit, unsigned int to)

EXPORT_SYMBOL_GPL(sm501_unit_power);


/* Perform a rounded division. */
static long sm501fb_round_div(long num, long denom)
{
/* n / d + 1 / 2 = (2n + d) / 2d */
return (2 * num + denom) / (2 * denom);
}

/* clock value structure. */
struct sm501_clock {
unsigned long mclk;
Expand Down Expand Up @@ -428,7 +420,7 @@ static int sm501_calc_clock(unsigned long freq,
/* try all 8 shift values.*/
for (shift = 0; shift < 8; shift++) {
/* Calculate difference to requested clock */
diff = sm501fb_round_div(mclk, divider << shift) - freq;
diff = DIV_ROUND_CLOSEST(mclk, divider << shift) - freq;
if (diff < 0)
diff = -diff;

Expand Down

0 comments on commit 829ecbc

Please sign in to comment.