diff options
author | Leifu Zhao <leifu.zhao@intel.com> | 2019-10-22 12:08:06 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-31 10:46:48 +0000 |
commit | 605efb789928c1061802996c81ec3621edb0eafc (patch) | |
tree | 85a450b8cb5a346315b4bcc6afa05876075865b2 /include/math_util.h | |
parent | 316a8dbad0f3b7f8c21b232ac0872f10cfc3a798 (diff) | |
download | chrome-ec-605efb789928c1061802996c81ec3621edb0eafc.tar.gz |
common: add ceil_for function to math_util.h
During code review for tgl rvp enablement, found it is better to
add ceil_for function to math_util.h.
BUG=none
BRANCH=none
TEST=successfully compile for arcada
Signed-off-by: Leifu Zhao <leifu.zhao@intel.com>
Change-Id: Iee350881c88e923c7a70317a9b8d75ee6104dba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1873349
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Leifu Zhao <leifu.zhao@intel.corp-partner.google.com>
Auto-Submit: Leifu Zhao <leifu.zhao@intel.corp-partner.google.com>
Commit-Queue: Leifu Zhao <leifu.zhao@intel.corp-partner.google.com>
Tested-by: Leifu Zhao <leifu.zhao@intel.corp-partner.google.com>
Diffstat (limited to 'include/math_util.h')
-rw-r--r-- | include/math_util.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/math_util.h b/include/math_util.h index 98dfdbec84..124801ff5d 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -114,6 +114,17 @@ static inline fp_t fp_abs(fp_t a) return (a >= INT_TO_FP(0) ? a : -a); } +/* + * Return the smallest positive X where M * X >= N. + * + * For example, if n = 88 and m = 9, then it returns 10 + * (i.e. 9 * 10 >= 88). + */ +static inline int ceil_for(int n, int m) +{ + return (((n - 1) / m) + 1); +} + /** * Square root */ |