[Sound-open-firmware] [PATCH 7/7] [v3]DMIC: Move ceil_divide from numbers.c to numbers.h as static inline
Seppo Ingalsuo
seppo.ingalsuo at linux.intel.com
Fri May 11 16:03:08 CEST 2018
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 <seppo.ingalsuo at linux.intel.com>
---
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 7b57d13..5aacd8b 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 7e39ac8..e26e4cd 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
--
2.14.1
More information about the Sound-open-firmware
mailing list