Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 829ecbcb authored by Axel Lin's avatar Axel Lin Committed by Samuel Ortiz
Browse files

mfd: Use DIV_ROUND_CLOSEST for sm501 clock



Use DIV_ROUND_CLOSEST to replace sm501fb_round_div function.

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 1b1247dd
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -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;