net: hns3: extraction an interface for state init|uninit
authorPeng Li <lipeng321@huawei.com>
Thu, 28 Jun 2018 04:12:25 +0000 (12:12 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 29 Jun 2018 02:06:34 +0000 (11:06 +0900)
Extraction an interface for state init|uninit to make the code
easier to read.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index 2b903f476149c21e137dea83fac408f0f6058c25..805c7807ec72dd104aa3e1645f8c94fadda37620 100644 (file)
@@ -5568,6 +5568,30 @@ static void hclge_pci_uninit(struct hclge_dev *hdev)
        pci_disable_device(pdev);
 }
 
+static void hclge_state_init(struct hclge_dev *hdev)
+{
+       set_bit(HCLGE_STATE_SERVICE_INITED, &hdev->state);
+       set_bit(HCLGE_STATE_DOWN, &hdev->state);
+       clear_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state);
+       clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state);
+       clear_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state);
+       clear_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state);
+}
+
+static void hclge_state_uninit(struct hclge_dev *hdev)
+{
+       set_bit(HCLGE_STATE_DOWN, &hdev->state);
+
+       if (hdev->service_timer.function)
+               del_timer_sync(&hdev->service_timer);
+       if (hdev->service_task.func)
+               cancel_work_sync(&hdev->service_task);
+       if (hdev->rst_service_task.func)
+               cancel_work_sync(&hdev->rst_service_task);
+       if (hdev->mbx_service_task.func)
+               cancel_work_sync(&hdev->mbx_service_task);
+}
+
 static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
 {
        struct pci_dev *pdev = ae_dev->pdev;
@@ -5708,12 +5732,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
        /* Enable MISC vector(vector0) */
        hclge_enable_vector(&hdev->misc_vector, true);
 
-       set_bit(HCLGE_STATE_SERVICE_INITED, &hdev->state);
-       set_bit(HCLGE_STATE_DOWN, &hdev->state);
-       clear_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state);
-       clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state);
-       clear_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state);
-       clear_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state);
+       hclge_state_init(hdev);
 
        pr_info("%s driver initialization finished.\n", HCLGE_DRIVER_NAME);
        return 0;
@@ -5818,16 +5837,7 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
        struct hclge_dev *hdev = ae_dev->priv;
        struct hclge_mac *mac = &hdev->hw.mac;
 
-       set_bit(HCLGE_STATE_DOWN, &hdev->state);
-
-       if (hdev->service_timer.function)
-               del_timer_sync(&hdev->service_timer);
-       if (hdev->service_task.func)
-               cancel_work_sync(&hdev->service_task);
-       if (hdev->rst_service_task.func)
-               cancel_work_sync(&hdev->rst_service_task);
-       if (hdev->mbx_service_task.func)
-               cancel_work_sync(&hdev->mbx_service_task);
+       hclge_state_uninit(hdev);
 
        if (mac->phydev)
                mdiobus_unregister(mac->mdio_bus);