net: hns3: fix incorrect type in assignment.
authorGuojia Liao <liaoguojia@huawei.com>
Wed, 28 Aug 2019 14:23:11 +0000 (22:23 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 29 Aug 2019 23:57:43 +0000 (16:57 -0700)
This patch fixes some incorrect type in assignment reported by sparse.
Those sparse warning as below:
- warning : restricted __le16 degrades to integer
- warning : cast from restricted __le32
- warning : expected restricted __le32
- warning : cast from restricted __be32
- warning : cast from restricted __be16
- warning : cast to restricted __le16

Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Reviewed-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c

index 2425b3f53ad8470b46dfb4e973d25d8ba16e1c87..d986c362eff4c4e797759a51c64edb3cc4250338 100644 (file)
@@ -930,32 +930,44 @@ static int hclge_config_ppu_error_interrupts(struct hclge_dev *hdev, u32 cmd,
        /* configure PPU error interrupts */
        if (cmd == HCLGE_PPU_MPF_ECC_INT_CMD) {
                hclge_cmd_setup_basic_desc(&desc[0], cmd, false);
-               desc[0].flag |= HCLGE_CMD_FLAG_NEXT;
+               desc[0].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
                hclge_cmd_setup_basic_desc(&desc[1], cmd, false);
                if (en) {
-                       desc[0].data[0] = HCLGE_PPU_MPF_ABNORMAL_INT0_EN;
-                       desc[0].data[1] = HCLGE_PPU_MPF_ABNORMAL_INT1_EN;
-                       desc[1].data[3] = HCLGE_PPU_MPF_ABNORMAL_INT3_EN;
-                       desc[1].data[4] = HCLGE_PPU_MPF_ABNORMAL_INT2_EN;
+                       desc[0].data[0] =
+                               cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT0_EN);
+                       desc[0].data[1] =
+                               cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT1_EN);
+                       desc[1].data[3] =
+                               cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT3_EN);
+                       desc[1].data[4] =
+                               cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT2_EN);
                }
 
-               desc[1].data[0] = HCLGE_PPU_MPF_ABNORMAL_INT0_EN_MASK;
-               desc[1].data[1] = HCLGE_PPU_MPF_ABNORMAL_INT1_EN_MASK;
-               desc[1].data[2] = HCLGE_PPU_MPF_ABNORMAL_INT2_EN_MASK;
-               desc[1].data[3] |= HCLGE_PPU_MPF_ABNORMAL_INT3_EN_MASK;
+               desc[1].data[0] =
+                       cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT0_EN_MASK);
+               desc[1].data[1] =
+                       cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT1_EN_MASK);
+               desc[1].data[2] =
+                       cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT2_EN_MASK);
+               desc[1].data[3] |=
+                       cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT3_EN_MASK);
                desc_num = 2;
        } else if (cmd == HCLGE_PPU_MPF_OTHER_INT_CMD) {
                hclge_cmd_setup_basic_desc(&desc[0], cmd, false);
                if (en)
-                       desc[0].data[0] = HCLGE_PPU_MPF_ABNORMAL_INT2_EN2;
+                       desc[0].data[0] =
+                               cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT2_EN2);
 
-               desc[0].data[2] = HCLGE_PPU_MPF_ABNORMAL_INT2_EN2_MASK;
+               desc[0].data[2] =
+                       cpu_to_le32(HCLGE_PPU_MPF_ABNORMAL_INT2_EN2_MASK);
        } else if (cmd == HCLGE_PPU_PF_OTHER_INT_CMD) {
                hclge_cmd_setup_basic_desc(&desc[0], cmd, false);
                if (en)
-                       desc[0].data[0] = HCLGE_PPU_PF_ABNORMAL_INT_EN;
+                       desc[0].data[0] =
+                               cpu_to_le32(HCLGE_PPU_PF_ABNORMAL_INT_EN);
 
-               desc[0].data[2] = HCLGE_PPU_PF_ABNORMAL_INT_EN_MASK;
+               desc[0].data[2] =
+                       cpu_to_le32(HCLGE_PPU_PF_ABNORMAL_INT_EN_MASK);
        } else {
                dev_err(dev, "Invalid cmd to configure PPU error interrupts\n");
                return -EINVAL;
index 6a96987bd8f0018e0f5f9f88bb680601effd1678..a108191c9e50a1ad575b6111975ba8166c54882d 100644 (file)
@@ -277,9 +277,9 @@ void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev)
 
                switch (msg_q[0]) {
                case HCLGE_MBX_LINK_STAT_CHANGE:
-                       link_status = le16_to_cpu(msg_q[1]);
+                       link_status = msg_q[1];
                        memcpy(&speed, &msg_q[2], sizeof(speed));
-                       duplex = (u8)le16_to_cpu(msg_q[4]);
+                       duplex = (u8)msg_q[4];
 
                        /* update upper layer with new link link status */
                        hclgevf_update_link_status(hdev, link_status);
@@ -287,7 +287,7 @@ void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev)
 
                        break;
                case HCLGE_MBX_LINK_STAT_MODE:
-                       idx = (u8)le16_to_cpu(msg_q[1]);
+                       idx = (u8)msg_q[1];
                        if (idx)
                                memcpy(&hdev->hw.mac.supported, &msg_q[2],
                                       sizeof(unsigned long));
@@ -301,14 +301,14 @@ void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev)
                         * has been completely reset. After this stack should
                         * eventually be re-initialized.
                         */
-                       reset_type = le16_to_cpu(msg_q[1]);
+                       reset_type = (enum hnae3_reset_type)msg_q[1];
                        set_bit(reset_type, &hdev->reset_pending);
                        set_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state);
                        hclgevf_reset_task_schedule(hdev);
 
                        break;
                case HCLGE_MBX_PUSH_VLAN_INFO:
-                       state = le16_to_cpu(msg_q[1]);
+                       state = msg_q[1];
                        vlan_info = &msg_q[1];
                        hclgevf_update_port_base_vlan_info(hdev, state,
                                                           (u8 *)vlan_info, 8);