The upstream Linux kernel community prefers using the BIT macro over
bit-shifting a 1.  Similar to how this is handled in the i40e shared code,
define a macro for OSes that do not already have it and wrap all that in
LINUX_MACROS so that it can be stripped from the Linux driver.

The upstream Linux kernel community prefers avoiding CamelCase in
variables, function names, etc.

Signed-off-by: Wang Xiao W <xiao.w.wang at intel.com>
---
 drivers/net/fm10k/base/fm10k_pf.c   | 12 ++++++------
 drivers/net/fm10k/base/fm10k_tlv.c  | 24 ++++++++++++------------
 drivers/net/fm10k/base/fm10k_type.h | 18 ++++++++++++------
 3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/drivers/net/fm10k/base/fm10k_pf.c 
b/drivers/net/fm10k/base/fm10k_pf.c
index 3ee88b6..7d48210 100644
--- a/drivers/net/fm10k/base/fm10k_pf.c
+++ b/drivers/net/fm10k/base/fm10k_pf.c
@@ -576,8 +576,8 @@ STATIC s32 fm10k_configure_dglort_map_pf(struct fm10k_hw 
*hw,
                return FM10K_ERR_PARAM;

        /* determine count of VSIs and queues */
-       queue_count = 1 << (dglort->rss_l + dglort->pc_l);
-       vsi_count = 1 << (dglort->vsi_l + dglort->queue_l);
+       queue_count = BIT(dglort->rss_l + dglort->pc_l);
+       vsi_count = BIT(dglort->vsi_l + dglort->queue_l);
        glort = dglort->glort;
        q_idx = dglort->queue_b;

@@ -593,8 +593,8 @@ STATIC s32 fm10k_configure_dglort_map_pf(struct fm10k_hw 
*hw,
        }

        /* determine count of PCs and queues */
-       queue_count = 1 << (dglort->queue_l + dglort->rss_l + dglort->vsi_l);
-       pc_count = 1 << dglort->pc_l;
+       queue_count = BIT(dglort->queue_l + dglort->rss_l + dglort->vsi_l);
+       pc_count = BIT(dglort->pc_l);

        /* configure PC for Tx queues */
        for (pc = 0; pc < pc_count; pc++) {
@@ -1001,7 +1001,7 @@ STATIC s32 fm10k_iov_reset_resources_pf(struct fm10k_hw 
*hw,
                return FM10K_ERR_PARAM;

        /* clear event notification of VF FLR */
-       FM10K_WRITE_REG(hw, FM10K_PFVFLREC(vf_idx / 32), 1 << (vf_idx % 32));
+       FM10K_WRITE_REG(hw, FM10K_PFVFLREC(vf_idx / 32), BIT(vf_idx % 32));

        /* force timeout and then disconnect the mailbox */
        vf_info->mbx.timeout = 0;
@@ -1417,7 +1417,7 @@ s32 fm10k_iov_msg_lport_state_pf(struct fm10k_hw *hw, u32 
**results,
                mode = fm10k_iov_supported_xcast_mode_pf(vf_info, mode);

                /* if mode is not currently enabled, enable it */
-               if (!(FM10K_VF_FLAG_ENABLED(vf_info) & (1 << mode)))
+               if (!(FM10K_VF_FLAG_ENABLED(vf_info) & BIT(mode)))
                        fm10k_update_xcast_mode_pf(hw, vf_info->glort, mode);

                /* swap mode back to a bit flag */
diff --git a/drivers/net/fm10k/base/fm10k_tlv.c 
b/drivers/net/fm10k/base/fm10k_tlv.c
index ade87d1..e6150c1 100644
--- a/drivers/net/fm10k/base/fm10k_tlv.c
+++ b/drivers/net/fm10k/base/fm10k_tlv.c
@@ -249,7 +249,7 @@ s32 fm10k_tlv_attr_put_value(u32 *msg, u16 attr_id, s64 
value, u32 len)
        attr = &msg[FM10K_TLV_DWORD_LEN(*msg)];

        if (len < 4) {
-               attr[1] = (u32)value & ((0x1ul << (8 * len)) - 1);
+               attr[1] = (u32)value & (BIT(8 * len) - 1);
        } else {
                attr[1] = (u32)value;
                if (len > 4)
@@ -699,29 +699,29 @@ STATIC void fm10k_tlv_msg_test_generate_data(u32 *msg, 
u32 attr_flags)
 {
        DEBUGFUNC("fm10k_tlv_msg_test_generate_data");

-       if (attr_flags & (1 << FM10K_TEST_MSG_STRING))
+       if (attr_flags & BIT(FM10K_TEST_MSG_STRING))
                fm10k_tlv_attr_put_null_string(msg, FM10K_TEST_MSG_STRING,
                                               test_str);
-       if (attr_flags & (1 << FM10K_TEST_MSG_MAC_ADDR))
+       if (attr_flags & BIT(FM10K_TEST_MSG_MAC_ADDR))
                fm10k_tlv_attr_put_mac_vlan(msg, FM10K_TEST_MSG_MAC_ADDR,
                                            test_mac, test_vlan);
-       if (attr_flags & (1 << FM10K_TEST_MSG_U8))
+       if (attr_flags & BIT(FM10K_TEST_MSG_U8))
                fm10k_tlv_attr_put_u8(msg, FM10K_TEST_MSG_U8,  test_u8);
-       if (attr_flags & (1 << FM10K_TEST_MSG_U16))
+       if (attr_flags & BIT(FM10K_TEST_MSG_U16))
                fm10k_tlv_attr_put_u16(msg, FM10K_TEST_MSG_U16, test_u16);
-       if (attr_flags & (1 << FM10K_TEST_MSG_U32))
+       if (attr_flags & BIT(FM10K_TEST_MSG_U32))
                fm10k_tlv_attr_put_u32(msg, FM10K_TEST_MSG_U32, test_u32);
-       if (attr_flags & (1 << FM10K_TEST_MSG_U64))
+       if (attr_flags & BIT(FM10K_TEST_MSG_U64))
                fm10k_tlv_attr_put_u64(msg, FM10K_TEST_MSG_U64, test_u64);
-       if (attr_flags & (1 << FM10K_TEST_MSG_S8))
+       if (attr_flags & BIT(FM10K_TEST_MSG_S8))
                fm10k_tlv_attr_put_s8(msg, FM10K_TEST_MSG_S8,  test_s8);
-       if (attr_flags & (1 << FM10K_TEST_MSG_S16))
+       if (attr_flags & BIT(FM10K_TEST_MSG_S16))
                fm10k_tlv_attr_put_s16(msg, FM10K_TEST_MSG_S16, test_s16);
-       if (attr_flags & (1 << FM10K_TEST_MSG_S32))
+       if (attr_flags & BIT(FM10K_TEST_MSG_S32))
                fm10k_tlv_attr_put_s32(msg, FM10K_TEST_MSG_S32, test_s32);
-       if (attr_flags & (1 << FM10K_TEST_MSG_S64))
+       if (attr_flags & BIT(FM10K_TEST_MSG_S64))
                fm10k_tlv_attr_put_s64(msg, FM10K_TEST_MSG_S64, test_s64);
-       if (attr_flags & (1 << FM10K_TEST_MSG_LE_STRUCT))
+       if (attr_flags & BIT(FM10K_TEST_MSG_LE_STRUCT))
                fm10k_tlv_attr_put_le_struct(msg, FM10K_TEST_MSG_LE_STRUCT,
                                             test_le, 8);
 }
diff --git a/drivers/net/fm10k/base/fm10k_type.h 
b/drivers/net/fm10k/base/fm10k_type.h
index 5db6345..387d25b 100644
--- a/drivers/net/fm10k/base/fm10k_type.h
+++ b/drivers/net/fm10k/base/fm10k_type.h
@@ -50,6 +50,12 @@ struct fm10k_hw;
 #define FM10K_DEV_ID_SDI_FM10420_DA2   0x15D5
 #endif /* ATWOOD_CHANNEL_HW */

+#ifndef LINUX_MACROS
+#ifndef BIT
+#define BIT(a) (1UL << (a))
+#endif
+#endif /* LINUX_MACROS */
+
 #define FM10K_MAX_QUEUES               256
 #define FM10K_MAX_QUEUES_PF            128
 #define FM10K_MAX_QUEUES_POOL          16
@@ -465,7 +471,7 @@ struct fm10k_hw;
 #define FM10K_VLAN_TABLE_VID_MAX               4096
 #define FM10K_VLAN_TABLE_VSI_MAX               64
 #define FM10K_VLAN_LENGTH_SHIFT                        16
-#define FM10K_VLAN_CLEAR                       (1 << 15)
+#define FM10K_VLAN_CLEAR                       BIT(15)
 #define FM10K_VLAN_ALL \
        ((FM10K_VLAN_TABLE_VID_MAX - 1) << FM10K_VLAN_LENGTH_SHIFT)

@@ -762,10 +768,10 @@ struct fm10k_vf_info {
                                                 */
 };

-#define FM10K_VF_FLAG_ALLMULTI_CAPABLE ((u8)1 << FM10K_XCAST_MODE_ALLMULTI)
-#define FM10K_VF_FLAG_MULTI_CAPABLE    ((u8)1 << FM10K_XCAST_MODE_MULTI)
-#define FM10K_VF_FLAG_PROMISC_CAPABLE  ((u8)1 << FM10K_XCAST_MODE_PROMISC)
-#define FM10K_VF_FLAG_NONE_CAPABLE     ((u8)1 << FM10K_XCAST_MODE_NONE)
+#define FM10K_VF_FLAG_ALLMULTI_CAPABLE (u8)(BIT(FM10K_XCAST_MODE_ALLMULTI))
+#define FM10K_VF_FLAG_MULTI_CAPABLE    (u8)(BIT(FM10K_XCAST_MODE_MULTI))
+#define FM10K_VF_FLAG_PROMISC_CAPABLE  (u8)(BIT(FM10K_XCAST_MODE_PROMISC))
+#define FM10K_VF_FLAG_NONE_CAPABLE     (u8)(BIT(FM10K_XCAST_MODE_NONE))
 #define FM10K_VF_FLAG_CAPABLE(vf_info) ((vf_info)->vf_flags & (u8)0xF)
 #define FM10K_VF_FLAG_ENABLED(vf_info) ((vf_info)->vf_flags >> 4)
 #define FM10K_VF_FLAG_SET_MODE(mode)   ((u8)0x10 << (mode))
@@ -816,7 +822,7 @@ struct fm10k_hw {
        u16 subsystem_vendor_id;
        u8 revision_id;
        u32 flags;
-#define FM10K_HW_FLAG_CLOCK_OWNER      (u32)(1 << 0)
+#define FM10K_HW_FLAG_CLOCK_OWNER      BIT(0)
 };

 /* Number of Transmit and Receive Descriptors must be a multiple of 8 */
-- 
1.9.3

Reply via email to