net: hns3: Change return type of hnae3_register_ae_dev
authorFuyun Liang <liangfuyun1@huawei.com>
Tue, 15 May 2018 18:20:08 +0000 (19:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 May 2018 15:33:07 +0000 (11:33 -0400)
If hclge.ko has not been inserted, the value of ret always is zero
in hnae3_register_ae_dev. If hclge.ko has been inserted, the value
of ret is zero or non zero. Different execution ways have different
results. It is confusing.

The ae_dev which is initialized failed can be reinitialized when we
remove hclge.ko and insert it again. For the case initializing client
instance, it is just like the case initializing ae_dev. The main function
of hnae3_register_ae_dev is adding the ae_dev to ad_dev list. Because
adding ae_dev is always ok, we does not need to return any in this
function.

This patch changes the return type of hnae3_register_ae_dev from int
to void.

Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hnae3.c
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

index 21cb0c5e5b31a368872fbcbdd0b2f77b8cf92f32..cb93295c9f629152bbc76fe0377ffa7ee1e71bd6 100644 (file)
@@ -203,7 +203,7 @@ EXPORT_SYMBOL(hnae3_unregister_ae_algo);
  * @ae_dev: the AE device
  * NOTE: the duplicated name will not be checked
  */
-int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
+void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
 {
        const struct pci_device_id *id;
        struct hnae3_ae_algo *ae_algo;
@@ -224,7 +224,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
 
                if (!ae_dev->ops) {
                        dev_err(&ae_dev->pdev->dev, "ae_dev ops are null\n");
-                       ret = -EOPNOTSUPP;
                        goto out_err;
                }
 
@@ -251,8 +250,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
 
 out_err:
        mutex_unlock(&hnae3_common_lock);
-
-       return ret;
 }
 EXPORT_SYMBOL(hnae3_register_ae_dev);
 
index ffec2318cf5081b6ad545dd14d1fb03aa628d273..ea6e6ead28a1e86635b5ac753e4d1faeb5a4375f 100644 (file)
@@ -515,7 +515,7 @@ struct hnae3_handle {
 #define hnae_get_bit(origin, shift) \
        hnae_get_field((origin), (0x1 << (shift)), (shift))
 
-int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev);
+void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev);
 void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev);
 
 void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo);
index af9e90f8710987c578295e7be1265dc11ff5f5d2..ac75b5d6a25275f52ae6c77a52683225481785b1 100644 (file)
@@ -1576,9 +1576,7 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        ae_dev->dev_type = HNAE3_DEV_KNIC;
        pci_set_drvdata(pdev, ae_dev);
 
-       ret = hnae3_register_ae_dev(ae_dev);
-       if (ret)
-               return ret;
+       hnae3_register_ae_dev(ae_dev);
 
        if (hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV))
                hns3_enable_sriov(pdev);