diff mbox series

x86/kvm: Use 'hlist_for_each_entry' to simplify code

Message ID 29796ca9a5d4255c2a0260c2f5c829539a6e7d88.1619600757.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State New, archived
Headers show
Series x86/kvm: Use 'hlist_for_each_entry' to simplify code | expand

Commit Message

Christophe JAILLET April 28, 2021, 9:08 a.m. UTC
Use 'hlist_for_each_entry' instead of hand writing it.
This saves a few lines of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 arch/x86/kernel/kvm.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index d307c22e5c18..35f5a0898b92 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -89,14 +89,11 @@  static struct kvm_task_sleep_head {
 static struct kvm_task_sleep_node *_find_apf_task(struct kvm_task_sleep_head *b,
 						  u32 token)
 {
-	struct hlist_node *p;
+	struct kvm_task_sleep_node *n;
 
-	hlist_for_each(p, &b->list) {
-		struct kvm_task_sleep_node *n =
-			hlist_entry(p, typeof(*n), link);
+	hlist_for_each_entry(n, &b->list, link)
 		if (n->token == token)
 			return n;
-	}
 
 	return NULL;
 }
@@ -169,14 +166,12 @@  static void apf_task_wake_all(void)
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++) {
 		struct kvm_task_sleep_head *b = &async_pf_sleepers[i];
 		struct kvm_task_sleep_node *n;
-		struct hlist_node *p, *next;
+		struct hlist_node *next;
 
 		raw_spin_lock(&b->lock);
-		hlist_for_each_safe(p, next, &b->list) {
-			n = hlist_entry(p, typeof(*n), link);
+		hlist_for_each_entry_safe(n, next, &b->list, link)
 			if (n->cpu == smp_processor_id())
 				apf_task_wake_one(n);
-		}
 		raw_spin_unlock(&b->lock);
 	}
 }