From d98e6ec4da2dbef529b50260aa35689723269764 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 11 May 2018 17:03:08 +0300 Subject: [PATCH] DMIC: Move ceil_divide from numbers.c to numbers.h as static inline The DMIC driver needs this function. This inline version is a bit faster and the change does not increase code size. Signed-off-by: Seppo Ingalsuo --- src/include/sof/math/numbers.h | 15 +++++++++++++-- src/math/numbers.c | 14 -------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/include/sof/math/numbers.h b/src/include/sof/math/numbers.h index 7b57d1357..5aacd8b33 100644 --- a/src/include/sof/math/numbers.h +++ b/src/include/sof/math/numbers.h @@ -40,8 +40,19 @@ int gcd(int a, int b); /* Calculate greatest common divisor for a and b */ -/* Divide function that returns ceil() of quotient */ -int ceil_divide(int a, int b); +/* This is a divide function that returns ceil of the quotient. + * E.g. ceil_divide(9, 3) returns 3, ceil_divide(10, 3) returns 4. + */ +static inline int ceil_divide(int a, int b) +{ + int c; + + c = a / b; + if (c * b < a) + c++; + + return c; +} /* Find indices of equal values in a vector of integer values */ int find_equal_int16(int16_t idx[], int16_t vec[], int n, int vec_length, diff --git a/src/math/numbers.c b/src/math/numbers.c index 7e39ac864..e26e4cdee 100644 --- a/src/math/numbers.c +++ b/src/math/numbers.c @@ -49,20 +49,6 @@ int gcd(int a, int b) return a; } -/* This is a divide function that returns ceil of the quotient. - * E.g. ceil_divide(9, 3) returns 3, ceil_divide(10, 3) returns 4. - */ -int ceil_divide(int a, int b) -{ - int c; - - c = a / b; - if (c * b < a) - c++; - - return c; -} - /* This function searches from vec[] (of length vec_length) integer values * of n. The indexes to equal values is returned in idx[]. The function * returns the number of found matches. The max_results should be set to