Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7143329imm; Wed, 27 Jun 2018 21:29:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpedeYNpnYTW0AEIR+QIahcnKuTnrhpqg10HhgLY0vsF1JfNHan4SFIgv0C0fy7fZXwzr+uy X-Received: by 2002:a63:68c1:: with SMTP id d184-v6mr7395170pgc.239.1530160198390; Wed, 27 Jun 2018 21:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530160198; cv=none; d=google.com; s=arc-20160816; b=Hd3BLvj6on3amHsK+bwt1Hq+Qm4RV6MhqhX7m7Wq3r7fxcMBpD14ILujhqhdqquEXj cJHjFYx68MzNL4dRDn6nfpCNdbDzGcoaqitsEZC5UszY7k438PRclte5vx523i/8jIGn 0WQXweRa3q5ko6FYcERiPf7HPx9sDRKl1aIj1NZYkguztB9HYhgrciW00ONO2BCJsiqB 3P58RV3uy95nuzqpYpNtZH+qUG9nCfDXe0rTJzOWpsJXTe2NDGEpOQfcG5ojtr+V0bET 5HiGNkdEtmBrLLIkyNoB2KQqOyxiOr8q5ElvE+r04g+oTXqfYAlm7clptkfstYGHN69e 9X5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=03mcfntTpBHHYHzfvk6p0CFPduwArJ4oHAdOgznmy7Q=; b=vEBUcyOFpzc0zsh6TMK41w1b0mJAGeeu2zQswfI7rE89/JMuyeg3/GGARaCBX67GER Jt3iR0KmqnW8l9QHZw0cezRDM17UZ7hrCc66JwHcOF8PB8xoVCeHdp4szY+gBvA3+zLj ABolgWJSCUg5S7tBKw4pjDOsJy7Yb6zu6Qk6NaZh1JNSgx122V4I10N8pieOMC6fyAP9 YHTuaD4QCeAZIJHjd/R+4TsIPV9OrObzrqadj2aeFr8uHWZ2Ceckg4cfCtbZqjgKumaw uH0J7rOzpe46dNH/TT74dg7Q1Co8XZG5lbbkDEljUaXd8TRRBPZAdiypYjjOGWeFq0fo LFLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12-v6si3637271pgo.112.2018.06.27.21.29.44; Wed, 27 Jun 2018 21:29:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753285AbeF1DlR (ORCPT + 99 others); Wed, 27 Jun 2018 23:41:17 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9180 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753203AbeF1DlO (ORCPT ); Wed, 27 Jun 2018 23:41:14 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9934686500677; Thu, 28 Jun 2018 11:40:58 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.382.0; Thu, 28 Jun 2018 11:40:53 +0800 From: Peng Li To: CC: , , , , , Subject: [PATCH net-next 07/11] net: hns3: extraction an interface for state init|uninit Date: Thu, 28 Jun 2018 12:12:25 +0800 Message-ID: <1530159149-122284-8-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530159149-122284-1-git-send-email-lipeng321@huawei.com> References: <1530159149-122284-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extraction an interface for state init|uninit to make the code easier to read. Signed-off-by: Peng Li --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 42 +++++++++++++--------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2b903f4..805c780 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -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); -- 2.9.3