Skip to content
Snippets Groups Projects
Commit d25924c5 authored by Fancy Fang's avatar Fancy Fang Committed by Leonard Crestez
Browse files

MLK-21252 drm/bridge: sec-dsim: resolve OVERFLOW_BEFORE_WIDEN warns


Coverity reports the 'OVERFLOW_BEFORE_WIDEN' warns which can
cause potential expression overflow for multiplying two 32bit
integers and assign the result to a 64bit integer, since no
automatic integer type promotion exists before the multiply
operation, so requires explicit type casting for either one
of operands.

Signed-off-by: default avatarFancy Fang <chen.fang@nxp.com>
parent feace499
No related branches found
No related tags found
No related merge requests found
...@@ -1190,10 +1190,10 @@ struct dsim_pll_pms *sec_mipi_dsim_calc_pmsk(struct sec_mipi_dsim *dsim) ...@@ -1190,10 +1190,10 @@ struct dsim_pll_pms *sec_mipi_dsim_calc_pmsk(struct sec_mipi_dsim *dsim)
* Fvco: [1050MHz ~ 2100MHz] (Fvco = ((m + k / 65536) * Fin) / p) * Fvco: [1050MHz ~ 2100MHz] (Fvco = ((m + k / 65536) * Fin) / p)
* So, m = Fvco * p / Fin and Fvco > Fin; * So, m = Fvco * p / Fin and Fvco > Fin;
*/ */
pfvco = fvco_range->min * prange->min; pfvco = (uint64_t)fvco_range->min * prange->min;
mrange->min = max_t(uint32_t, mrange->min, mrange->min = max_t(uint32_t, mrange->min,
DIV_ROUND_UP_ULL(pfvco, fin)); DIV_ROUND_UP_ULL(pfvco, fin));
pfvco = fvco_range->max * prange->max; pfvco = (uint64_t)fvco_range->max * prange->max;
mrange->max = min_t(uint32_t, mrange->max, mrange->max = min_t(uint32_t, mrange->max,
DIV_ROUND_UP_ULL(pfvco, fin)); DIV_ROUND_UP_ULL(pfvco, fin));
...@@ -1206,7 +1206,7 @@ struct dsim_pll_pms *sec_mipi_dsim_calc_pmsk(struct sec_mipi_dsim *dsim) ...@@ -1206,7 +1206,7 @@ struct dsim_pll_pms *sec_mipi_dsim_calc_pmsk(struct sec_mipi_dsim *dsim)
/* first determine 'm', then can determine 'p', last determine 's' */ /* first determine 'm', then can determine 'p', last determine 's' */
for (m = mrange->min; m <= mrange->max; m++) { for (m = mrange->min; m <= mrange->max; m++) {
/* p = m * Fin / Fvco */ /* p = m * Fin / Fvco */
mfin = m * fin; mfin = (uint64_t)m * fin;
pr_new.min = max_t(uint32_t, prange->min, pr_new.min = max_t(uint32_t, prange->min,
DIV_ROUND_UP_ULL(mfin, fvco_range->max)); DIV_ROUND_UP_ULL(mfin, fvco_range->max));
pr_new.max = min_t(uint32_t, prange->max, pr_new.max = min_t(uint32_t, prange->max,
...@@ -1217,7 +1217,7 @@ struct dsim_pll_pms *sec_mipi_dsim_calc_pmsk(struct sec_mipi_dsim *dsim) ...@@ -1217,7 +1217,7 @@ struct dsim_pll_pms *sec_mipi_dsim_calc_pmsk(struct sec_mipi_dsim *dsim)
for (p = pr_new.min; p <= pr_new.max; p++) { for (p = pr_new.min; p <= pr_new.max; p++) {
/* s = order_pow_of_two((m * Fin) / (p * Fout)) */ /* s = order_pow_of_two((m * Fin) / (p * Fout)) */
pfout = p * fout; pfout = (uint64_t)p * fout;
raw_s = DIV_ROUND_CLOSEST_ULL(mfin, pfout); raw_s = DIV_ROUND_CLOSEST_ULL(mfin, pfout);
s_pow_2 = rounddown_pow_of_two(raw_s); s_pow_2 = rounddown_pow_of_two(raw_s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment