提交 ba47f66f 编写于 作者: Y Yonglong Liu 提交者: Xie XiuQi

net: hns3: make some reusable codes into a function

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

In hclge_dcb.c, these pair of codes:
	hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
	hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT);
and
	hclge_notify_client(hdev, HNAE3_INIT_CLIENT);
	hclge_notify_client(hdev, HNAE3_UP_CLIENT);
are called many times, so make them into a function.

Feature or Bugfix:Bugfix
Signed-off-by: NYonglong Liu <liuyonglong@huawei.com>
Reviewed-by: Nlipeng <lipeng321@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 1d0dd370
...@@ -197,6 +197,28 @@ static int hclge_client_setup_tc(struct hclge_dev *hdev) ...@@ -197,6 +197,28 @@ static int hclge_client_setup_tc(struct hclge_dev *hdev)
return 0; return 0;
} }
static int hclge_notify_down_uinit(struct hclge_dev *hdev)
{
int ret;
ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
if (ret)
return ret;
return hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT);
}
static int hclge_notify_init_up(struct hclge_dev *hdev)
{
int ret;
ret = hclge_notify_client(hdev, HNAE3_INIT_CLIENT);
if (ret)
return ret;
return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
}
static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
{ {
struct hclge_vport *vport = hclge_get_vport(h); struct hclge_vport *vport = hclge_get_vport(h);
...@@ -218,11 +240,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) ...@@ -218,11 +240,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
if (netif_msg_ifdown(h)) if (netif_msg_ifdown(h))
netdev_info(netdev, "set ets\n"); netdev_info(netdev, "set ets\n");
ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); ret = hclge_notify_down_uinit(hdev);
if (ret)
return ret;
ret = hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -242,11 +260,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) ...@@ -242,11 +260,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
if (ret) if (ret)
goto err_out; goto err_out;
ret = hclge_notify_client(hdev, HNAE3_INIT_CLIENT); ret = hclge_notify_init_up(hdev);
if (ret)
return ret;
ret = hclge_notify_client(hdev, HNAE3_UP_CLIENT);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -257,10 +271,8 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) ...@@ -257,10 +271,8 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
if (!map_changed) if (!map_changed)
return ret; return ret;
if (hclge_notify_client(hdev, HNAE3_INIT_CLIENT)) (void)hclge_notify_init_up(hdev);
return ret;
hclge_notify_client(hdev, HNAE3_UP_CLIENT);
return ret; return ret;
} }
...@@ -403,11 +415,7 @@ static int hclge_setup_tc(struct hnae3_handle *h, u8 tc, u8 *prio_tc) ...@@ -403,11 +415,7 @@ static int hclge_setup_tc(struct hnae3_handle *h, u8 tc, u8 *prio_tc)
if (ret) if (ret)
return -EINVAL; return -EINVAL;
ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); ret = hclge_notify_down_uinit(hdev);
if (ret)
return ret;
ret = hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT);
if (ret) if (ret)
return ret; return ret;
...@@ -429,17 +437,11 @@ static int hclge_setup_tc(struct hnae3_handle *h, u8 tc, u8 *prio_tc) ...@@ -429,17 +437,11 @@ static int hclge_setup_tc(struct hnae3_handle *h, u8 tc, u8 *prio_tc)
else else
hdev->flag &= ~HCLGE_FLAG_MQPRIO_ENABLE; hdev->flag &= ~HCLGE_FLAG_MQPRIO_ENABLE;
ret = hclge_notify_client(hdev, HNAE3_INIT_CLIENT); return hclge_notify_init_up(hdev);
if (ret)
return ret;
return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
err_out: err_out:
if (hclge_notify_client(hdev, HNAE3_INIT_CLIENT)) (void)hclge_notify_init_up(hdev);
return ret;
hclge_notify_client(hdev, HNAE3_UP_CLIENT);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册