summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/ipu-v3/ipu-di.c
diff options
context:
space:
mode:
authorSteve Longerbeam <slongerbeam@gmail.com>2014-12-19 03:00:26 +0100
committerPhilipp Zabel <p.zabel@pengutronix.de>2015-01-07 19:15:04 +0100
commit503f1631ae8f42a386193c92cc4488d35978352e (patch)
treef90982a4e002c56599a7693270d6f035991297dc /drivers/gpu/ipu-v3/ipu-di.c
parentgpu: ipu-v3: Use videomode in struct ipu_di_signal_cfg (diff)
downloadlinux-503f1631ae8f42a386193c92cc4488d35978352e.tar.xz
linux-503f1631ae8f42a386193c92cc4488d35978352e.zip
gpu: ipu-di: Switch to DIV_ROUND_CLOSEST for DI clock divider calc
We can use the DIV_ROUND_CLOSEST() macro when calculating the DI clock divider, rounded to nearest int. Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/gpu/ipu-v3/ipu-di.c')
-rw-r--r--drivers/gpu/ipu-v3/ipu-di.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/gpu/ipu-v3/ipu-di.c b/drivers/gpu/ipu-v3/ipu-di.c
index d95fbd0f6952..b61d6be97602 100644
--- a/drivers/gpu/ipu-v3/ipu-di.c
+++ b/drivers/gpu/ipu-v3/ipu-di.c
@@ -440,8 +440,7 @@ static void ipu_di_config_clock(struct ipu_di *di,
clk_set_rate(clk, sig->mode.pixelclock);
in_rate = clk_get_rate(clk);
- div = (in_rate + sig->mode.pixelclock / 2) /
- sig->mode.pixelclock;
+ div = DIV_ROUND_CLOSEST(in_rate, sig->mode.pixelclock);
if (div == 0)
div = 1;
@@ -459,8 +458,7 @@ static void ipu_di_config_clock(struct ipu_di *di,
unsigned div, error;
clkrate = clk_get_rate(di->clk_ipu);
- div = (clkrate + sig->mode.pixelclock / 2) /
- sig->mode.pixelclock;
+ div = DIV_ROUND_CLOSEST(clkrate, sig->mode.pixelclock);
rate = clkrate / div;
error = rate / (sig->mode.pixelclock / 1000);
@@ -482,8 +480,7 @@ static void ipu_di_config_clock(struct ipu_di *di,
clk_set_rate(clk, sig->mode.pixelclock);
in_rate = clk_get_rate(clk);
- div = (in_rate + sig->mode.pixelclock / 2) /
- sig->mode.pixelclock;
+ div = DIV_ROUND_CLOSEST(in_rate, sig->mode.pixelclock);
if (div == 0)
div = 1;