net/qede/base: improve set field macro
authorRasesh Mody <rasesh.mody@cavium.com>
Thu, 5 Jan 2017 07:03:44 +0000 (23:03 -0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:52 +0000 (19:40 +0100)
Improve robustness of the SET_FIELD macro by using a mask.

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
drivers/net/qede/base/ecore.h

index 907b35b..c9f3b00 100644 (file)
@@ -80,7 +80,7 @@ enum ecore_nvm_cmd {
 #define SET_FIELD(value, name, flag)                                   \
 do {                                                                   \
        (value) &= ~(name##_MASK << name##_SHIFT);                      \
-       (value) |= (((u64)flag) << (name##_SHIFT));                     \
+       (value) |= ((((u64)flag) & (u64)name##_MASK) << (name##_SHIFT));\
 } while (0)
 
 #define GET_FIELD(value, name)                                         \