Thread (13 messages) flat view 13 messages, 2 authors, 2018-07-02
STALE2980d

Revision v1 of 3 in this series.

Revisions (3)
  1. v1 [diff vs current]
  2. v1 current
  3. v2 [diff vs current]

[PATCH net-next 05/10] net: hns3: using modulo for cyclic counters in hclge_cmd_send

From: Peng Li <hidden>
Date: 2018-06-29 10:54:48
Also in: lkml
Subsystem: hisilicon network subsystem 3 driver (hns3), hisilicon network subsystem driver, networking drivers, the rest · Maintainers: Jian Shen, Jijie Shao, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

From: Huazhong Tan <redacted>

There are some codes in hclge_cmd.c which can be simplified by
used %= operator.

Signed-off-by: Huazhong Tan <redacted>
Signed-off-by: Peng Li <redacted>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
index 0839e84..28556a9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
@@ -228,8 +228,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
 		desc_to_use = &hw->cmq.csq.desc[hw->cmq.csq.next_to_use];
 		*desc_to_use = desc[handle];
 		(hw->cmq.csq.next_to_use)++;
-		if (hw->cmq.csq.next_to_use == hw->cmq.csq.desc_num)
-			hw->cmq.csq.next_to_use = 0;
+		hw->cmq.csq.next_to_use %= hw->cmq.csq.desc_num;
 		handle++;
 	}
 
@@ -269,8 +268,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
 			hw->cmq.last_status = desc_ret;
 			ntc++;
 			handle++;
-			if (ntc == hw->cmq.csq.desc_num)
-				ntc = 0;
+			ntc %= hw->cmq.csq.desc_num;
 		}
 	}
 
-- 
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help