net: hns3: remove always exist devlink pointer check
authorLeon Romanovsky <leonro@nvidia.com>
Sat, 14 Aug 2021 09:57:31 +0000 (12:57 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sat, 14 Aug 2021 12:59:10 +0000 (13:59 +0100)
The devlink pointer always exists after hclge_devlink_init() succeed.
Remove that check together with NULL setting after release and ensure
that devlink_register is last command prior to call to devlink_reload_enable().

Fixes: b741269b2759 ("net: hns3: add support for registering devlink for PF")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c

index 448f29aa4e6bfc18f1bd77d8a3637accc66cfd7f..e4aad695abcc1835f90dfd67c4dc4c4fee29bfba 100644 (file)
@@ -118,6 +118,7 @@ int hclge_devlink_init(struct hclge_dev *hdev)
 
        priv = devlink_priv(devlink);
        priv->hdev = hdev;
+       hdev->devlink = devlink;
 
        ret = devlink_register(devlink);
        if (ret) {
@@ -126,8 +127,6 @@ int hclge_devlink_init(struct hclge_dev *hdev)
                goto out_reg_fail;
        }
 
-       hdev->devlink = devlink;
-
        devlink_reload_enable(devlink);
 
        return 0;
@@ -141,14 +140,9 @@ void hclge_devlink_uninit(struct hclge_dev *hdev)
 {
        struct devlink *devlink = hdev->devlink;
 
-       if (!devlink)
-               return;
-
        devlink_reload_disable(devlink);
 
        devlink_unregister(devlink);
 
        devlink_free(devlink);
-
-       hdev->devlink = NULL;
 }
index 1e6061fb8ed49bb882f0236610a6789c9d801143..f478770299c6cd53fbc4d167eeeaead1c4a23d24 100644 (file)
@@ -120,6 +120,7 @@ int hclgevf_devlink_init(struct hclgevf_dev *hdev)
 
        priv = devlink_priv(devlink);
        priv->hdev = hdev;
+       hdev->devlink = devlink;
 
        ret = devlink_register(devlink);
        if (ret) {
@@ -128,8 +129,6 @@ int hclgevf_devlink_init(struct hclgevf_dev *hdev)
                goto out_reg_fail;
        }
 
-       hdev->devlink = devlink;
-
        devlink_reload_enable(devlink);
 
        return 0;
@@ -143,14 +142,9 @@ void hclgevf_devlink_uninit(struct hclgevf_dev *hdev)
 {
        struct devlink *devlink = hdev->devlink;
 
-       if (!devlink)
-               return;
-
        devlink_reload_disable(devlink);
 
        devlink_unregister(devlink);
 
        devlink_free(devlink);
-
-       hdev->devlink = NULL;
 }