summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qdf/inc/qdf_util.h14
-rw-r--r--qdf/linux/src/i_qdf_util.h16
2 files changed, 30 insertions, 0 deletions
diff --git a/qdf/inc/qdf_util.h b/qdf/inc/qdf_util.h
index cc7ae313481b..e6b4a708598a 100644
--- a/qdf/inc/qdf_util.h
+++ b/qdf/inc/qdf_util.h
@@ -467,4 +467,18 @@ uint32_t qdf_get_upper_32_bits(qdf_dma_addr_t addr)
return __qdf_get_upper_32_bits(addr);
}
+/**
+ * qdf_rounddown_pow_of_two() - Round down to nearest power of two
+ * @n: number to be tested
+ *
+ * Test if the input number is power of two, and return the nearest power of two
+ *
+ * Return: number rounded down to the nearest power of two
+ */
+static inline
+unsigned long qdf_rounddown_pow_of_two(unsigned long n)
+{
+ return __qdf_rounddown_pow_of_two(n);
+}
+
#endif /*_QDF_UTIL_H*/
diff --git a/qdf/linux/src/i_qdf_util.h b/qdf/linux/src/i_qdf_util.h
index c66193e39286..fbd2e8433f93 100644
--- a/qdf/linux/src/i_qdf_util.h
+++ b/qdf/linux/src/i_qdf_util.h
@@ -320,5 +320,21 @@ uint32_t __qdf_get_upper_32_bits(__qdf_dma_addr_t addr)
return upper_32_bits(addr);
}
+/**
+ * __qdf_rounddown_pow_of_two() - Round down to nearest power of two
+ * @n: number to be tested
+ *
+ * Test if the input number is power of two, and return the nearest power of two
+ *
+ * Return: number rounded down to the nearest power of two
+ */
+static inline
+unsigned long __qdf_rounddown_pow_of_two(unsigned long n)
+{
+ if (is_power_of_2(n))
+ return n; /* already a power of 2 */
+
+ return __rounddown_pow_of_two(n);
+}
#endif /*_I_QDF_UTIL_H*/