Commit 4ae11681 authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville

rt2x00: Use __builtin_choose_expr() instead of ?:

To really force the FIELD macros to determine
the first bit of the register field we should
use the __builtin_choose_expr() function.
Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent a26cbc65
...@@ -145,23 +145,27 @@ struct rt2x00_field32 { ...@@ -145,23 +145,27 @@ struct rt2x00_field32 {
* compile-time rather then run-time. * compile-time rather then run-time.
*/ */
#define compile_ffs2(__x) \ #define compile_ffs2(__x) \
( ((__x) & 0x1) ? 0 : 1 ) __builtin_choose_expr(((__x) & 0x1), 0, 1)
#define compile_ffs4(__x) \ #define compile_ffs4(__x) \
( ((__x) & 0x3) ? \ __builtin_choose_expr(((__x) & 0x3), \
compile_ffs2(__x) : (compile_ffs2((__x) >> 2) + 2) ) (compile_ffs2((__x))), \
(compile_ffs2((__x) >> 2) + 2))
#define compile_ffs8(__x) \ #define compile_ffs8(__x) \
( ((__x) & 0xf) ? \ __builtin_choose_expr(((__x) & 0xf), \
compile_ffs4(__x) : (compile_ffs4((__x) >> 4) + 4) ) (compile_ffs4((__x))), \
(compile_ffs4((__x) >> 4) + 4))
#define compile_ffs16(__x) \ #define compile_ffs16(__x) \
( ((__x) & 0xff) ? \ __builtin_choose_expr(((__x) & 0xff), \
compile_ffs8(__x) : (compile_ffs8((__x) >> 8) + 8) ) (compile_ffs8((__x))), \
(compile_ffs8((__x) >> 8) + 8))
#define compile_ffs32(__x) \ #define compile_ffs32(__x) \
( ((__x) & 0xffff) ? \ __builtin_choose_expr(((__x) & 0xffff), \
compile_ffs16(__x) : (compile_ffs16((__x) >> 16) + 16) ) (compile_ffs16((__x))), \
(compile_ffs16((__x) >> 16) + 16))
/* /*
* This macro will check the requirements for the FIELD{8,16,32} macros * This macro will check the requirements for the FIELD{8,16,32} macros
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment