]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
UBUNTU: SAUCE: {topost} net: hns3: extraction an interface for state state init|uninit
authorPeng Li <lipeng321@huawei.com>
Fri, 13 Apr 2018 02:05:32 +0000 (10:05 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 6 Jun 2018 18:41:40 +0000 (14:41 -0400)
BugLink: https://bugs.launchpad.net/bugs/1768670
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: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index bc5dbc80d6b849e99b5ab27170958db5c97bde64..82c6b6c863dc5cf455ef0e812bf41d006b91050e 100644 (file)
@@ -5612,6 +5612,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;
@@ -5750,12 +5774,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;
@@ -5860,16 +5879,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);