Add basic support for mini2440 board to barebox.
[barebox-mini2440.git] / lib / notifier.c
bloba2aac53c2007fe081fc040ad44c78cacf5a2d1f0
1 #include <common.h>
2 #include <linux/list.h>
3 #include <notifier.h>
5 int notifier_chain_register(struct notifier_head *nh, struct notifier_block *n)
7 list_add_tail(&n->list, &nh->blocks);
8 return 0;
11 int notifier_chain_unregister(struct notifier_head *nh, struct notifier_block *n)
13 list_del(&n->list);
14 return 0;
17 int notifier_call_chain(struct notifier_head *nh, unsigned long val, void *v)
19 struct notifier_block *entry;
21 list_for_each_entry(entry, &nh->blocks, list)
22 entry->notifier_call(entry, val, v);
24 return 0;
28 * Notifier list for code which wants to be called at clock
29 * frequency changes.
31 static NOTIFIER_HEAD(clock_notifier_list);
33 /**
34 * clock_register_client - register a client notifier
35 * @nb: notifier block to callback on events
37 int clock_register_client(struct notifier_block *nb)
39 return notifier_chain_register(&clock_notifier_list, nb);
42 /**
43 * clock_register_client - unregister a client notifier
44 * @nb: notifier block to callback on events
46 int clock_unregister_client(struct notifier_block *nb)
48 return notifier_chain_unregister(&clock_notifier_list, nb);
51 /**
52 * clock_register_client - notify clients of clock frequency changes
55 int clock_notifier_call_chain(void)
57 return notifier_call_chain(&clock_notifier_list, 0, NULL);