Commit e3afa963 authored by Fuyun Liang's avatar Fuyun Liang Committed by David S. Miller

net: hns3: Add a check for client instance init state

If the client instance is initializd failed, we do not need to uninit it.
This patch adds a state check to check init state of client instance.

Fixes: 38caee9d ("net: hns3: Add support of the HNAE3 framework")
Signed-off-by: default avatarFuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3e249d3b
...@@ -50,13 +50,22 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client, ...@@ -50,13 +50,22 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client,
/* now, (un-)instantiate client by calling lower layer */ /* now, (un-)instantiate client by calling lower layer */
if (is_reg) { if (is_reg) {
ret = ae_dev->ops->init_client_instance(client, ae_dev); ret = ae_dev->ops->init_client_instance(client, ae_dev);
if (ret) if (ret) {
dev_err(&ae_dev->pdev->dev, dev_err(&ae_dev->pdev->dev,
"fail to instantiate client\n"); "fail to instantiate client\n");
return ret; return ret;
} }
hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 1);
return 0;
}
if (hnae_get_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B)) {
ae_dev->ops->uninit_client_instance(client, ae_dev); ae_dev->ops->uninit_client_instance(client, ae_dev);
hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 0);
}
return 0; return 0;
} }
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#define HNAE3_DEV_INITED_B 0x0 #define HNAE3_DEV_INITED_B 0x0
#define HNAE3_DEV_SUPPORT_ROCE_B 0x1 #define HNAE3_DEV_SUPPORT_ROCE_B 0x1
#define HNAE3_DEV_SUPPORT_DCB_B 0x2 #define HNAE3_DEV_SUPPORT_DCB_B 0x2
#define HNAE3_CLIENT_INITED_B 0x3
#define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\ #define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\
BIT(HNAE3_DEV_SUPPORT_ROCE_B)) BIT(HNAE3_DEV_SUPPORT_ROCE_B))
......
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