Skip to content

Commit a3da8ad

Browse files
Julia Cartwrightdavem330
authored andcommitted
net: macb: kill useless use of list_empty()
The list_for_each_entry() macro already handles the case where the list is empty (by not executing the loop body). It's not necessary to handle this case specially, so stop doing so. Cc: Rafal Ozieblo <[email protected]> Acked-by: Nicolas Ferre <[email protected]> Signed-off-by: Julia Cartwright <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9a63b25 commit a3da8ad

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,24 +2812,20 @@ static int gem_add_flow_filter(struct net_device *netdev,
28122812
htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
28132813

28142814
/* find correct place to add in list */
2815-
if (list_empty(&bp->rx_fs_list.list))
2816-
list_add(&newfs->list, &bp->rx_fs_list.list);
2817-
else {
2818-
list_for_each_entry(item, &bp->rx_fs_list.list, list) {
2819-
if (item->fs.location > newfs->fs.location) {
2820-
list_add_tail(&newfs->list, &item->list);
2821-
added = true;
2822-
break;
2823-
} else if (item->fs.location == fs->location) {
2824-
netdev_err(netdev, "Rule not added: location %d not free!\n",
2825-
fs->location);
2826-
ret = -EBUSY;
2827-
goto err;
2828-
}
2815+
list_for_each_entry(item, &bp->rx_fs_list.list, list) {
2816+
if (item->fs.location > newfs->fs.location) {
2817+
list_add_tail(&newfs->list, &item->list);
2818+
added = true;
2819+
break;
2820+
} else if (item->fs.location == fs->location) {
2821+
netdev_err(netdev, "Rule not added: location %d not free!\n",
2822+
fs->location);
2823+
ret = -EBUSY;
2824+
goto err;
28292825
}
2830-
if (!added)
2831-
list_add_tail(&newfs->list, &bp->rx_fs_list.list);
28322826
}
2827+
if (!added)
2828+
list_add_tail(&newfs->list, &bp->rx_fs_list.list);
28332829

28342830
gem_prog_cmp_regs(bp, fs);
28352831
bp->rx_fs_list.count++;
@@ -2851,9 +2847,6 @@ static int gem_del_flow_filter(struct net_device *netdev,
28512847
struct ethtool_rx_fs_item *item;
28522848
struct ethtool_rx_flow_spec *fs;
28532849

2854-
if (list_empty(&bp->rx_fs_list.list))
2855-
return -EINVAL;
2856-
28572850
list_for_each_entry(item, &bp->rx_fs_list.list, list) {
28582851
if (item->fs.location == cmd->fs.location) {
28592852
/* disable screener regs for the flow entry */

0 commit comments

Comments
 (0)