Skip to contentSkip to conversation

mfd: sm501: Use DIV_ROUND_CLOSEST

PATCH In review Axel Lin 2 participants 2 messages Mar 12, 2012 – Mar 16, 2012 Multifunction devices (MFD)

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 mfd: sm501: Use DIV_ROUND_CLOSEST

Use DIV_ROUND_CLOSEST to replace sm501fb_round_div function.

---
 drivers/mfd/sm501.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)
drivers/mfd/sm501.c +1 -9
index f4d8611..d927dd4 100644
@@ -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;
@@ -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;
 
Signature · 1 line
1.7.5.4
#1 lore raw

Hi Axel,

Quoted 1 line · Axel Lin

Use DIV_ROUND_CLOSEST to replace sm501fb_round_div function.

Patch applied, thanks.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/