Use 'hlist_for_each_entry' instead of hand writing it. This saves a few lines of code. Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> --- Compile tested only --- arch/x86/kernel/kvm.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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); } } -- 2.30.2