summaryrefslogtreecommitdiff
path: root/drivers/media/i2c/ccs-pll.c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2020-09-01 13:11:11 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-12-07 15:37:25 +0100
commit9c1a0d9e9188e7dc2f8f723ce87885e17636ede8 (patch)
treeb37f61dc1f0bcdd78c739934e7ee17c6f5486ed1 /drivers/media/i2c/ccs-pll.c
parent9454432af0c874eba7abb1abb76bbf62950a9087 (diff)
media: ccs-pll: End search if there are no better values available
The VT divisor search can be ended if we've already found the value that corresponds exactly the total divisor, as there are no better (lower) values available. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/i2c/ccs-pll.c')
-rw-r--r--drivers/media/i2c/ccs-pll.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/media/i2c/ccs-pll.c b/drivers/media/i2c/ccs-pll.c
index ea0f84fc8a90..22e29127804a 100644
--- a/drivers/media/i2c/ccs-pll.c
+++ b/drivers/media/i2c/ccs-pll.c
@@ -352,6 +352,7 @@ __ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,
sys_div <= max_sys_div;
sys_div += 2 - (sys_div & 1)) {
uint16_t pix_div = DIV_ROUND_UP(vt_div, sys_div);
+ uint16_t rounded_div;
if (pix_div < lim->vt_bk.min_pix_clk_div
|| pix_div > lim->vt_bk.max_pix_clk_div) {
@@ -363,10 +364,15 @@ __ccs_pll_calculate(struct device *dev, const struct ccs_pll_limits *lim,
continue;
}
+ rounded_div = roundup(vt_div, best_pix_div);
+
/* Check if this one is better. */
- if (pix_div * sys_div
- <= roundup(vt_div, best_pix_div))
+ if (pix_div * sys_div <= rounded_div)
best_pix_div = pix_div;
+
+ /* Bail out if we've already found the best value. */
+ if (vt_div == rounded_div)
+ break;
}
if (best_pix_div < INT_MAX >> 1)
break;