Skip to content

Commit

Permalink
atm: Use list_for_each_entry() to simplify code in resources.c
Browse files Browse the repository at this point in the history
Convert list_for_each() to list_for_each_entry() where
applicable. This simplifies the code.

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Wang Hai <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Wang Hai authored and davem330 committed Jun 10, 2021
1 parent 3e98ae0 commit 73e4290
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions net/atm/resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ static struct atm_dev *__alloc_atm_dev(const char *type)
static struct atm_dev *__atm_dev_lookup(int number)
{
struct atm_dev *dev;
struct list_head *p;

list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
list_for_each_entry(dev, &atm_devs, dev_list) {
if (dev->number == number) {
atm_dev_hold(dev);
return dev;
Expand Down Expand Up @@ -215,8 +213,7 @@ int atm_getnames(void __user *buf, int __user *iobuf_len)
return -ENOMEM;
}
tmp_p = tmp_buf;
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
list_for_each_entry(dev, &atm_devs, dev_list) {
*tmp_p++ = dev->number;
}
mutex_unlock(&atm_dev_mutex);
Expand Down

0 comments on commit 73e4290

Please sign in to comment.