From 8e25a3077a790708a4543989657c5e7d5bc24ecb Mon Sep 17 00:00:00 2001 From: Karunakar Dasineni Date: Thu, 24 Oct 2019 14:13:19 -0700 Subject: [PATCH] qcacmn: Add qdf API to find last set bit Add qdf wrapper for Linux fls() to find last set bit. Change-Id: I089fee397d619515c768521bda1f4d4c35526fe0 --- qdf/inc/qdf_util.h | 13 +++++++++++++ qdf/linux/src/i_qdf_util.h | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/qdf/inc/qdf_util.h b/qdf/inc/qdf_util.h index ec990c505c..a89e48dc99 100644 --- a/qdf/inc/qdf_util.h +++ b/qdf/inc/qdf_util.h @@ -761,4 +761,17 @@ int qdf_hex_str_to_binary(u8 *dst, const char *src, size_t count) return __qdf_hex_str_to_binary(dst, src, count); } +/** + * qdf_fls() - find last set bit in a given 32 bit input + * @x: 32 bit mask + * + * Return: zero if the input is zero, otherwise returns the bit + * position of the last set bit, where the LSB is 1 and MSB is 32. + */ +static inline +int qdf_fls(uint32_t x) +{ + return __qdf_fls(x); +} + #endif /*_QDF_UTIL_H*/ diff --git a/qdf/linux/src/i_qdf_util.h b/qdf/linux/src/i_qdf_util.h index 469320e6e0..67469c355e 100644 --- a/qdf/linux/src/i_qdf_util.h +++ b/qdf/linux/src/i_qdf_util.h @@ -472,4 +472,17 @@ int __qdf_hex_str_to_binary(u8 *dst, const char *src, size_t count) return hex2bin(dst, src, count); } +/** + * __qdf_fls() - find last set bit in a given 32 bit input + * @x: 32 bit mask + * + * Return: zero if the input is zero, otherwise returns the bit + * position of the last set bit, where the LSB is 1 and MSB is 32. + */ +static inline +int __qdf_fls(uint32_t x) +{ + return fls(x); +} + #endif /*_I_QDF_UTIL_H*/