net: hns3: add optimization in the hclge_hw_error_set_state
authorShiju Jose <shiju.jose@huawei.com>
Fri, 7 Dec 2018 21:08:03 +0000 (21:08 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 7 Dec 2018 23:57:01 +0000 (15:57 -0800)
1. This patch adds minor loop optimization in the
   hclge_hw_error_set_state function.
2. Adds logging module's name if it fails to configure the
   error interrupts.

Signed-off-by: Shiju Jose <shiju.jose@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/hns3pf/hclge_err.c

index 2d07be873a31f5b5d2f6bdd3ab880df407c72c03..d1c9f7ac90215d6cd6a8a93b073e5bb9449c3d13 100644 (file)
@@ -586,18 +586,16 @@ static const struct hclge_hw_blk hw_blk[] = {
 
 int hclge_hw_error_set_state(struct hclge_dev *hdev, bool state)
 {
+       const struct hclge_hw_blk *module = hw_blk;
        int ret = 0;
-       int i = 0;
 
-       while (hw_blk[i].name) {
-               if (!hw_blk[i].config_err_int) {
-                       i++;
-                       continue;
+       while (module->name) {
+               if (module->config_err_int) {
+                       ret = module->config_err_int(hdev, state);
+                       if (ret)
+                               return ret;
                }
-               ret = hw_blk[i].config_err_int(hdev, state);
-               if (ret)
-                       return ret;
-               i++;
+               module++;
        }
 
        return ret;