提交 78595dfc 编写于 作者: W Wang Hai 提交者: David S. Miller

ethernet/qlogic: Use list_for_each_entry() to simplify code in qlcnic_hw.c

Convert list_for_each() to list_for_each_entry() where
applicable. This simplifies the code.
Reported-by: NHulk Robot <hulkci@huawei.com>
Signed-off-by: NWang Hai <wanghai38@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b55b1d50
...@@ -460,12 +460,10 @@ int qlcnic_82xx_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr, ...@@ -460,12 +460,10 @@ int qlcnic_82xx_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr,
int qlcnic_nic_del_mac(struct qlcnic_adapter *adapter, const u8 *addr) int qlcnic_nic_del_mac(struct qlcnic_adapter *adapter, const u8 *addr)
{ {
struct qlcnic_mac_vlan_list *cur; struct qlcnic_mac_vlan_list *cur;
struct list_head *head;
int err = -EINVAL; int err = -EINVAL;
/* Delete MAC from the existing list */ /* Delete MAC from the existing list */
list_for_each(head, &adapter->mac_list) { list_for_each_entry(cur, &adapter->mac_list, list) {
cur = list_entry(head, struct qlcnic_mac_vlan_list, list);
if (ether_addr_equal(addr, cur->mac_addr)) { if (ether_addr_equal(addr, cur->mac_addr)) {
err = qlcnic_sre_macaddr_change(adapter, cur->mac_addr, err = qlcnic_sre_macaddr_change(adapter, cur->mac_addr,
0, QLCNIC_MAC_DEL); 0, QLCNIC_MAC_DEL);
...@@ -483,11 +481,9 @@ int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, const u8 *addr, u16 vlan, ...@@ -483,11 +481,9 @@ int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, const u8 *addr, u16 vlan,
enum qlcnic_mac_type mac_type) enum qlcnic_mac_type mac_type)
{ {
struct qlcnic_mac_vlan_list *cur; struct qlcnic_mac_vlan_list *cur;
struct list_head *head;
/* look up if already exists */ /* look up if already exists */
list_for_each(head, &adapter->mac_list) { list_for_each_entry(cur, &adapter->mac_list, list) {
cur = list_entry(head, struct qlcnic_mac_vlan_list, list);
if (ether_addr_equal(addr, cur->mac_addr) && if (ether_addr_equal(addr, cur->mac_addr) &&
cur->vlan_id == vlan) cur->vlan_id == vlan)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册