Commit 74354140 authored by Huazhong Tan's avatar Huazhong Tan Committed by David S. Miller

net: hns3: change hnae3_register_ae_dev() to int

hnae3_register_ae_dev() may fail, and it should return a error code
to its caller, so change hnae3_register_ae_dev() return type to int.

Also, when hnae3_register_ae_dev() return error, hns3_probe() should
do some error handling and return the error code.
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fc0c174f
...@@ -238,7 +238,7 @@ EXPORT_SYMBOL(hnae3_unregister_ae_algo); ...@@ -238,7 +238,7 @@ EXPORT_SYMBOL(hnae3_unregister_ae_algo);
* @ae_dev: the AE device * @ae_dev: the AE device
* NOTE: the duplicated name will not be checked * NOTE: the duplicated name will not be checked
*/ */
void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
{ {
const struct pci_device_id *id; const struct pci_device_id *id;
struct hnae3_ae_algo *ae_algo; struct hnae3_ae_algo *ae_algo;
...@@ -259,6 +259,7 @@ void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) ...@@ -259,6 +259,7 @@ void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
if (!ae_dev->ops) { if (!ae_dev->ops) {
dev_err(&ae_dev->pdev->dev, "ae_dev ops are null\n"); dev_err(&ae_dev->pdev->dev, "ae_dev ops are null\n");
ret = -EOPNOTSUPP;
goto out_err; goto out_err;
} }
...@@ -285,8 +286,15 @@ void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) ...@@ -285,8 +286,15 @@ void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev)
ret); ret);
} }
mutex_unlock(&hnae3_common_lock);
return 0;
out_err: out_err:
list_del(&ae_dev->node);
mutex_unlock(&hnae3_common_lock); mutex_unlock(&hnae3_common_lock);
return ret;
} }
EXPORT_SYMBOL(hnae3_register_ae_dev); EXPORT_SYMBOL(hnae3_register_ae_dev);
......
...@@ -587,7 +587,7 @@ struct hnae3_handle { ...@@ -587,7 +587,7 @@ struct hnae3_handle {
#define hnae3_get_bit(origin, shift) \ #define hnae3_get_bit(origin, shift) \
hnae3_get_field((origin), (0x1 << (shift)), (shift)) hnae3_get_field((origin), (0x1 << (shift)), (shift))
void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev); int 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_dev(struct hnae3_ae_dev *ae_dev);
void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo); void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo);
......
...@@ -1752,9 +1752,13 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1752,9 +1752,13 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
hns3_get_dev_capability(pdev, ae_dev); hns3_get_dev_capability(pdev, ae_dev);
pci_set_drvdata(pdev, ae_dev); pci_set_drvdata(pdev, ae_dev);
hnae3_register_ae_dev(ae_dev); ret = hnae3_register_ae_dev(ae_dev);
if (ret) {
devm_kfree(&pdev->dev, ae_dev);
pci_set_drvdata(pdev, NULL);
}
return 0; return ret;
} }
/* hns3_remove - Device removal routine /* hns3_remove - Device removal routine
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment