Skip to contentSkip to conversation

atm: Use list_for_each_entry() to simplify code in resources.c

PATCH Applied Wang Hai 2 participants 2 messages Jun 10, 2021

Subsystems (3)
lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 atm: Use list_for_each_entry() to simplify code in resources.c

Convert list_for_each() to list_for_each_entry() where applicable. This simplifies the code.

---
 net/atm/resources.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
net/atm/resources.c +2 -5
index 53236986dfe0..2b2d33eeaf20 100644
@@ -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;
@@ -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);
Signature · 1 line
2.17.1
#1 lore raw
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Thu, 10 Jun 2021 21:03:55 +0800 you wrote:

Convert list_for_each() to list_for_each_entry() where applicable. This simplifies the code.

---
 net/atm/resources.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Here is the summary with links:
- [net-next] atm: Use list_for_each_entry() to simplify code in resources.c

    https://git.kernel.org/netdev/net-next/c/73e42909ef2d

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html