summaryrefslogtreecommitdiffstats
path: root/lib/notifier.c
blob: 9eb734e504b5fa6d535f9bd9490b817929f29785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <common.h>
#include <linux/list.h>
#include <notifier.h>

int notifier_chain_register(struct notifier_head *nh, struct notifier_block *n)
{
	list_add_tail(&n->list, &nh->blocks);
	return 0;
}

int notifier_chain_unregister(struct notifier_head *nh, struct notifier_block *n)
{
	list_del(&n->list);
	return 0;
}

int notifier_call_chain(struct notifier_head *nh, unsigned long val, void *v)
{
	struct notifier_block *entry;

	list_for_each_entry(entry, &nh->blocks, list)
		entry->notifier_call(entry, val, v);

	return 0;
}

/*
 *	Notifier list for code which wants to be called at clock
 *	frequency changes.
 */
static NOTIFIER_HEAD(clock_notifier_list);

/**
 *	clock_register_client - register a client notifier
 *	@nb: notifier block to callback on events
 */
int clock_register_client(struct notifier_block *nb)
{
	return notifier_chain_register(&clock_notifier_list, nb);
}

/**
 *	clock_register_client - unregister a client notifier
 *	@nb: notifier block to callback on events
 */
int clock_unregister_client(struct notifier_block *nb)
{
	return notifier_chain_unregister(&clock_notifier_list, nb);
}

/**
 * clock_register_client - notify clients of clock frequency changes
 *
 */
int clock_notifier_call_chain(void)
{
	return notifier_call_chain(&clock_notifier_list, 0, NULL);
}