Files
Marc Zyngier a24ecd1fca kvm tools: init: fix usage of hlist iterators
Commit b67bfe0d42ca ("hlist: drop the node parameter from iterators")
incorrectly changed the way that hlist iterators are used.

This patch fixes util/init.c so it passes parameters to the new
iterators in the right manner.

Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00

68 lines
1.2 KiB
C

#include <linux/list.h>
#include <linux/kernel.h>
#include "kvm/kvm.h"
#include "kvm/util-init.h"
#define PRIORITY_LISTS 10
static struct hlist_head init_lists[PRIORITY_LISTS];
static struct hlist_head exit_lists[PRIORITY_LISTS];
int init_list_add(struct init_item *t, int (*init)(struct kvm *),
int priority, const char *name)
{
t->init = init;
t->fn_name = name;
hlist_add_head(&t->n, &init_lists[priority]);
return 0;
}
int exit_list_add(struct init_item *t, int (*init)(struct kvm *),
int priority, const char *name)
{
t->init = init;
t->fn_name = name;
hlist_add_head(&t->n, &exit_lists[priority]);
return 0;
}
int init_list__init(struct kvm *kvm)
{
unsigned int i;
int r = 0;
struct init_item *t;
for (i = 0; i < ARRAY_SIZE(init_lists); i++)
hlist_for_each_entry(t, &init_lists[i], n) {
r = t->init(kvm);
if (r < 0) {
pr_warning("Failed init: %s\n", t->fn_name);
goto fail;
}
}
fail:
return r;
}
int init_list__exit(struct kvm *kvm)
{
int i;
int r = 0;
struct init_item *t;
for (i = ARRAY_SIZE(exit_lists) - 1; i >= 0; i--)
hlist_for_each_entry(t, &exit_lists[i], n) {
r = t->init(kvm);
if (r < 0) {
pr_warning("%s failed.\n", t->fn_name);
goto fail;
}
}
fail:
return r;
}