diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2006-03-27 04:16:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-27 11:44:50 -0500 |
commit | e041c683412d5bf44dc2b109053e3b837b71742d (patch) | |
tree | 9d271066ef379da0c0fb3b8cb4137abd5d2ebba0 /drivers | |
parent | 76b81e2b0e2241accebcc68e126bc5ab958661b9 (diff) |
[PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
We noticed that notifier chains in the kernel fall into two basic usage
classes:
"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;
"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.
We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.
With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)
There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)
Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.
Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.
ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain
BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain
It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)
The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.
[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/memory.c | 8 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 4 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 7 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_watchdog.c | 6 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 61 | ||||
-rw-r--r-- | drivers/firmware/dcdbas.c | 19 | ||||
-rw-r--r-- | drivers/macintosh/adb.c | 11 | ||||
-rw-r--r-- | drivers/macintosh/adbhid.c | 3 | ||||
-rw-r--r-- | drivers/macintosh/via-pmu.c | 2 | ||||
-rw-r--r-- | drivers/macintosh/via-pmu68k.c | 7 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_core.c | 8 | ||||
-rw-r--r-- | drivers/misc/ibmasm/heartbeat.c | 5 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 2 | ||||
-rw-r--r-- | drivers/parisc/led.c | 14 | ||||
-rw-r--r-- | drivers/parisc/power.c | 6 | ||||
-rw-r--r-- | drivers/scsi/gdth.c | 9 | ||||
-rw-r--r-- | drivers/usb/core/notify.c | 65 | ||||
-rw-r--r-- | drivers/video/fbmem.c | 31 |
18 files changed, 113 insertions, 155 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 105a0d61eb1f..dd547af4681a 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -47,16 +47,16 @@ static struct kset_uevent_ops memory_uevent_ops = { | |||
47 | .uevent = memory_uevent, | 47 | .uevent = memory_uevent, |
48 | }; | 48 | }; |
49 | 49 | ||
50 | static struct notifier_block *memory_chain; | 50 | static BLOCKING_NOTIFIER_HEAD(memory_chain); |
51 | 51 | ||
52 | int register_memory_notifier(struct notifier_block *nb) | 52 | int register_memory_notifier(struct notifier_block *nb) |
53 | { | 53 | { |
54 | return notifier_chain_register(&memory_chain, nb); | 54 | return blocking_notifier_chain_register(&memory_chain, nb); |
55 | } | 55 | } |
56 | 56 | ||
57 | void unregister_memory_notifier(struct notifier_block *nb) | 57 | void unregister_memory_notifier(struct notifier_block *nb) |
58 | { | 58 | { |
59 | notifier_chain_unregister(&memory_chain, nb); | 59 | blocking_notifier_chain_unregister(&memory_chain, nb); |
60 | } | 60 | } |
61 | 61 | ||
62 | /* | 62 | /* |
@@ -140,7 +140,7 @@ static ssize_t show_mem_state(struct sys_device *dev, char *buf) | |||
140 | 140 | ||
141 | static inline int memory_notify(unsigned long val, void *v) | 141 | static inline int memory_notify(unsigned long val, void *v) |
142 | { | 142 | { |
143 | return notifier_call_chain(&memory_chain, val, v); | 143 | return blocking_notifier_call_chain(&memory_chain, val, v); |
144 | } | 144 | } |
145 | 145 | ||
146 | /* | 146 | /* |
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index b8fb87c6c29f..40eb005b9d77 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -3744,7 +3744,7 @@ static int ipmi_init_msghandler(void) | |||
3744 | ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES; | 3744 | ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES; |
3745 | add_timer(&ipmi_timer); | 3745 | add_timer(&ipmi_timer); |
3746 | 3746 | ||
3747 | notifier_chain_register(&panic_notifier_list, &panic_block); | 3747 | atomic_notifier_chain_register(&panic_notifier_list, &panic_block); |
3748 | 3748 | ||
3749 | initialized = 1; | 3749 | initialized = 1; |
3750 | 3750 | ||
@@ -3764,7 +3764,7 @@ static __exit void cleanup_ipmi(void) | |||
3764 | if (!initialized) | 3764 | if (!initialized) |
3765 | return; | 3765 | return; |
3766 | 3766 | ||
3767 | notifier_chain_unregister(&panic_notifier_list, &panic_block); | 3767 | atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block); |
3768 | 3768 | ||
3769 | /* This can't be called if any interfaces exist, so no worry about | 3769 | /* This can't be called if any interfaces exist, so no worry about |
3770 | shutting down the interfaces. */ | 3770 | shutting down the interfaces. */ |
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 12f858dc9994..35fbd4d8ed4b 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -237,10 +237,10 @@ struct smi_info | |||
237 | 237 | ||
238 | static int try_smi_init(struct smi_info *smi); | 238 | static int try_smi_init(struct smi_info *smi); |
239 | 239 | ||
240 | static struct notifier_block *xaction_notifier_list; | 240 | static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list); |
241 | static int register_xaction_notifier(struct notifier_block * nb) | 241 | static int register_xaction_notifier(struct notifier_block * nb) |
242 | { | 242 | { |
243 | return notifier_chain_register(&xaction_notifier_list, nb); | 243 | return atomic_notifier_chain_register(&xaction_notifier_list, nb); |
244 | } | 244 | } |
245 | 245 | ||
246 | static void si_restart_short_timer(struct smi_info *smi_info); | 246 | static void si_restart_short_timer(struct smi_info *smi_info); |
@@ -302,7 +302,8 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info) | |||
302 | do_gettimeofday(&t); | 302 | do_gettimeofday(&t); |
303 | printk("**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec); | 303 | printk("**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec); |
304 | #endif | 304 | #endif |
305 | err = notifier_call_chain(&xaction_notifier_list, 0, smi_info); | 305 | err = atomic_notifier_call_chain(&xaction_notifier_list, |
306 | 0, smi_info); | ||
306 | if (err & NOTIFY_STOP_MASK) { | 307 | if (err & NOTIFY_STOP_MASK) { |
307 | rv = SI_SM_CALL_WITHOUT_DELAY; | 308 | rv = SI_SM_CALL_WITHOUT_DELAY; |
308 | goto out; | 309 | goto out; |
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 616539310d9a..7ece9f3c8f70 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c | |||
@@ -1158,7 +1158,8 @@ static int __init ipmi_wdog_init(void) | |||
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | register_reboot_notifier(&wdog_reboot_notifier); | 1160 | register_reboot_notifier(&wdog_reboot_notifier); |
1161 | notifier_chain_register(&panic_notifier_list, &wdog_panic_notifier); | 1161 | atomic_notifier_chain_register(&panic_notifier_list, |
1162 | &wdog_panic_notifier); | ||
1162 | 1163 | ||
1163 | printk(KERN_INFO PFX "driver initialized\n"); | 1164 | printk(KERN_INFO PFX "driver initialized\n"); |
1164 | 1165 | ||
@@ -1176,7 +1177,8 @@ static __exit void ipmi_unregister_watchdog(void) | |||
1176 | release_nmi(&ipmi_nmi_handler); | 1177 | release_nmi(&ipmi_nmi_handler); |
1177 | #endif | 1178 | #endif |
1178 | 1179 | ||
1179 | notifier_chain_unregister(&panic_notifier_list, &wdog_panic_notifier); | 1180 | atomic_notifier_chain_unregister(&panic_notifier_list, |
1181 | &wdog_panic_notifier); | ||
1180 | unregister_reboot_notifier(&wdog_reboot_notifier); | 1182 | unregister_reboot_notifier(&wdog_reboot_notifier); |
1181 | 1183 | ||
1182 | if (! watchdog_user) | 1184 | if (! watchdog_user) |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index aed80e6aec6d..9b6ae7dc8b8a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -52,9 +52,8 @@ static void handle_update(void *data); | |||
52 | * changes to devices when the CPU clock speed changes. | 52 | * changes to devices when the CPU clock speed changes. |
53 | * The mutex locks both lists. | 53 | * The mutex locks both lists. |
54 | */ | 54 | */ |
55 | static struct notifier_block *cpufreq_policy_notifier_list; | 55 | static BLOCKING_NOTIFIER_HEAD(cpufreq_policy_notifier_list); |
56 | static struct notifier_block *cpufreq_transition_notifier_list; | 56 | static BLOCKING_NOTIFIER_HEAD(cpufreq_transition_notifier_list); |
57 | static DECLARE_RWSEM (cpufreq_notifier_rwsem); | ||
58 | 57 | ||
59 | 58 | ||
60 | static LIST_HEAD(cpufreq_governor_list); | 59 | static LIST_HEAD(cpufreq_governor_list); |
@@ -247,8 +246,6 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) | |||
247 | dprintk("notification %u of frequency transition to %u kHz\n", | 246 | dprintk("notification %u of frequency transition to %u kHz\n", |
248 | state, freqs->new); | 247 | state, freqs->new); |
249 | 248 | ||
250 | down_read(&cpufreq_notifier_rwsem); | ||
251 | |||
252 | policy = cpufreq_cpu_data[freqs->cpu]; | 249 | policy = cpufreq_cpu_data[freqs->cpu]; |
253 | switch (state) { | 250 | switch (state) { |
254 | 251 | ||
@@ -266,20 +263,19 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) | |||
266 | freqs->old = policy->cur; | 263 | freqs->old = policy->cur; |
267 | } | 264 | } |
268 | } | 265 | } |
269 | notifier_call_chain(&cpufreq_transition_notifier_list, | 266 | blocking_notifier_call_chain(&cpufreq_transition_notifier_list, |
270 | CPUFREQ_PRECHANGE, freqs); | 267 | CPUFREQ_PRECHANGE, freqs); |
271 | adjust_jiffies(CPUFREQ_PRECHANGE, freqs); | 268 | adjust_jiffies(CPUFREQ_PRECHANGE, freqs); |
272 | break; | 269 | break; |
273 | 270 | ||
274 | case CPUFREQ_POSTCHANGE: | 271 | case CPUFREQ_POSTCHANGE: |
275 | adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); | 272 | adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); |
276 | notifier_call_chain(&cpufreq_transition_notifier_list, | 273 | blocking_notifier_call_chain(&cpufreq_transition_notifier_list, |
277 | CPUFREQ_POSTCHANGE, freqs); | 274 | CPUFREQ_POSTCHANGE, freqs); |
278 | if (likely(policy) && likely(policy->cpu == freqs->cpu)) | 275 | if (likely(policy) && likely(policy->cpu == freqs->cpu)) |
279 | policy->cur = freqs->new; | 276 | policy->cur = freqs->new; |
280 | break; | 277 | break; |
281 | } | 278 | } |
282 | up_read(&cpufreq_notifier_rwsem); | ||
283 | } | 279 | } |
284 | EXPORT_SYMBOL_GPL(cpufreq_notify_transition); | 280 | EXPORT_SYMBOL_GPL(cpufreq_notify_transition); |
285 | 281 | ||
@@ -1007,7 +1003,7 @@ static int cpufreq_suspend(struct sys_device * sysdev, pm_message_t pmsg) | |||
1007 | freqs.old = cpu_policy->cur; | 1003 | freqs.old = cpu_policy->cur; |
1008 | freqs.new = cur_freq; | 1004 | freqs.new = cur_freq; |
1009 | 1005 | ||
1010 | notifier_call_chain(&cpufreq_transition_notifier_list, | 1006 | blocking_notifier_call_chain(&cpufreq_transition_notifier_list, |
1011 | CPUFREQ_SUSPENDCHANGE, &freqs); | 1007 | CPUFREQ_SUSPENDCHANGE, &freqs); |
1012 | adjust_jiffies(CPUFREQ_SUSPENDCHANGE, &freqs); | 1008 | adjust_jiffies(CPUFREQ_SUSPENDCHANGE, &freqs); |
1013 | 1009 | ||
@@ -1088,7 +1084,8 @@ static int cpufreq_resume(struct sys_device * sysdev) | |||
1088 | freqs.old = cpu_policy->cur; | 1084 | freqs.old = cpu_policy->cur; |
1089 | freqs.new = cur_freq; | 1085 | freqs.new = cur_freq; |
1090 | 1086 | ||
1091 | notifier_call_chain(&cpufreq_transition_notifier_list, | 1087 | blocking_notifier_call_chain( |
1088 | &cpufreq_transition_notifier_list, | ||
1092 | CPUFREQ_RESUMECHANGE, &freqs); | 1089 | CPUFREQ_RESUMECHANGE, &freqs); |
1093 | adjust_jiffies(CPUFREQ_RESUMECHANGE, &freqs); | 1090 | adjust_jiffies(CPUFREQ_RESUMECHANGE, &freqs); |
1094 | 1091 | ||
@@ -1125,24 +1122,24 @@ static struct sysdev_driver cpufreq_sysdev_driver = { | |||
1125 | * changes in cpufreq policy. | 1122 | * changes in cpufreq policy. |
1126 | * | 1123 | * |
1127 | * This function may sleep, and has the same return conditions as | 1124 | * This function may sleep, and has the same return conditions as |
1128 | * notifier_chain_register. | 1125 | * blocking_notifier_chain_register. |
1129 | */ | 1126 | */ |
1130 | int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list) | 1127 | int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list) |
1131 | { | 1128 | { |
1132 | int ret; | 1129 | int ret; |
1133 | 1130 | ||
1134 | down_write(&cpufreq_notifier_rwsem); | ||
1135 | switch (list) { | 1131 | switch (list) { |
1136 | case CPUFREQ_TRANSITION_NOTIFIER: | 1132 | case CPUFREQ_TRANSITION_NOTIFIER: |
1137 | ret = notifier_chain_register(&cpufreq_transition_notifier_list, nb); | 1133 | ret = blocking_notifier_chain_register( |
1134 | &cpufreq_transition_notifier_list, nb); | ||
1138 | break; | 1135 | break; |
1139 | case CPUFREQ_POLICY_NOTIFIER: | 1136 | case CPUFREQ_POLICY_NOTIFIER: |
1140 | ret = notifier_chain_register(&cpufreq_policy_notifier_list, nb); | 1137 | ret = blocking_notifier_chain_register( |
1138 | &cpufreq_policy_notifier_list, nb); | ||
1141 | break; | 1139 | break; |
1142 | default: | 1140 | default: |
1143 | ret = -EINVAL; | 1141 | ret = -EINVAL; |
1144 | } | 1142 | } |
1145 | up_write(&cpufreq_notifier_rwsem); | ||
1146 | 1143 | ||
1147 | return ret; | 1144 | return ret; |
1148 | } | 1145 | } |
@@ -1157,24 +1154,24 @@ EXPORT_SYMBOL(cpufreq_register_notifier); | |||
1157 | * Remove a driver from the CPU frequency notifier list. | 1154 | * Remove a driver from the CPU frequency notifier list. |
1158 | * | 1155 | * |
1159 | * This function may sleep, and has the same return conditions as | 1156 | * This function may sleep, and has the same return conditions as |
1160 | * notifier_chain_unregister. | 1157 | * blocking_notifier_chain_unregister. |
1161 | */ | 1158 | */ |
1162 | int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list) | 1159 | int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list) |
1163 | { | 1160 | { |
1164 | int ret; | 1161 | int ret; |
1165 | 1162 | ||
1166 | down_write(&cpufreq_notifier_rwsem); | ||
1167 | switch (list) { | 1163 | switch (list) { |
1168 | case CPUFREQ_TRANSITION_NOTIFIER: | 1164 | case CPUFREQ_TRANSITION_NOTIFIER: |
1169 | ret = notifier_chain_unregister(&cpufreq_transition_notifier_list, nb); | 1165 | ret = blocking_notifier_chain_unregister( |
1166 | &cpufreq_transition_notifier_list, nb); | ||
1170 | break; | 1167 | break; |
1171 | case CPUFREQ_POLICY_NOTIFIER: | 1168 | case CPUFREQ_POLICY_NOTIFIER: |
1172 | ret = notifier_chain_unregister(&cpufreq_policy_notifier_list, nb); | 1169 | ret = blocking_notifier_chain_unregister( |
1170 | &cpufreq_policy_notifier_list, nb); | ||
1173 | break; | 1171 | break; |
1174 | default: | 1172 | default: |
1175 | ret = -EINVAL; | 1173 | ret = -EINVAL; |
1176 | } | 1174 | } |
1177 | up_write(&cpufreq_notifier_rwsem); | ||
1178 | 1175 | ||
1179 | return ret; | 1176 | return ret; |
1180 | } | 1177 | } |
@@ -1346,29 +1343,23 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_poli | |||
1346 | if (ret) | 1343 | if (ret) |
1347 | goto error_out; | 1344 | goto error_out; |
1348 | 1345 | ||
1349 | down_read(&cpufreq_notifier_rwsem); | ||
1350 | |||
1351 | /* adjust if necessary - all reasons */ | 1346 | /* adjust if necessary - all reasons */ |
1352 | notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_ADJUST, | 1347 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1353 | policy); | 1348 | CPUFREQ_ADJUST, policy); |
1354 | 1349 | ||
1355 | /* adjust if necessary - hardware incompatibility*/ | 1350 | /* adjust if necessary - hardware incompatibility*/ |
1356 | notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_INCOMPATIBLE, | 1351 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1357 | policy); | 1352 | CPUFREQ_INCOMPATIBLE, policy); |
1358 | 1353 | ||
1359 | /* verify the cpu speed can be set within this limit, | 1354 | /* verify the cpu speed can be set within this limit, |
1360 | which might be different to the first one */ | 1355 | which might be different to the first one */ |
1361 | ret = cpufreq_driver->verify(policy); | 1356 | ret = cpufreq_driver->verify(policy); |
1362 | if (ret) { | 1357 | if (ret) |
1363 | up_read(&cpufreq_notifier_rwsem); | ||
1364 | goto error_out; | 1358 | goto error_out; |
1365 | } | ||
1366 | 1359 | ||
1367 | /* notification of the new policy */ | 1360 | /* notification of the new policy */ |
1368 | notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_NOTIFY, | 1361 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1369 | policy); | 1362 | CPUFREQ_NOTIFY, policy); |
1370 | |||
1371 | up_read(&cpufreq_notifier_rwsem); | ||
1372 | 1363 | ||
1373 | data->min = policy->min; | 1364 | data->min = policy->min; |
1374 | data->max = policy->max; | 1365 | data->max = policy->max; |
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index d6543fc4a923..339f405ff708 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -484,26 +484,15 @@ static void dcdbas_host_control(void) | |||
484 | static int dcdbas_reboot_notify(struct notifier_block *nb, unsigned long code, | 484 | static int dcdbas_reboot_notify(struct notifier_block *nb, unsigned long code, |
485 | void *unused) | 485 | void *unused) |
486 | { | 486 | { |
487 | static unsigned int notify_cnt = 0; | ||
488 | |||
489 | switch (code) { | 487 | switch (code) { |
490 | case SYS_DOWN: | 488 | case SYS_DOWN: |
491 | case SYS_HALT: | 489 | case SYS_HALT: |
492 | case SYS_POWER_OFF: | 490 | case SYS_POWER_OFF: |
493 | if (host_control_on_shutdown) { | 491 | if (host_control_on_shutdown) { |
494 | /* firmware is going to perform host control action */ | 492 | /* firmware is going to perform host control action */ |
495 | if (++notify_cnt == 2) { | 493 | printk(KERN_WARNING "Please wait for shutdown " |
496 | printk(KERN_WARNING | 494 | "action to complete...\n"); |
497 | "Please wait for shutdown " | 495 | dcdbas_host_control(); |
498 | "action to complete...\n"); | ||
499 | dcdbas_host_control(); | ||
500 | } | ||
501 | /* | ||
502 | * register again and initiate the host control | ||
503 | * action on the second notification to allow | ||
504 | * everyone that registered to be notified | ||
505 | */ | ||
506 | register_reboot_notifier(nb); | ||
507 | } | 496 | } |
508 | break; | 497 | break; |
509 | } | 498 | } |
@@ -514,7 +503,7 @@ static int dcdbas_reboot_notify(struct notifier_block *nb, unsigned long code, | |||
514 | static struct notifier_block dcdbas_reboot_nb = { | 503 | static struct notifier_block dcdbas_reboot_nb = { |
515 | .notifier_call = dcdbas_reboot_notify, | 504 | .notifier_call = dcdbas_reboot_notify, |
516 | .next = NULL, | 505 | .next = NULL, |
517 | .priority = 0 | 506 | .priority = INT_MIN |
518 | }; | 507 | }; |
519 | 508 | ||
520 | static DCDBAS_BIN_ATTR_RW(smi_data); | 509 | static DCDBAS_BIN_ATTR_RW(smi_data); |
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index d2ead1776c16..34fcabac5fdb 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -80,7 +80,7 @@ static struct adb_driver *adb_driver_list[] = { | |||
80 | static struct class *adb_dev_class; | 80 | static struct class *adb_dev_class; |
81 | 81 | ||
82 | struct adb_driver *adb_controller; | 82 | struct adb_driver *adb_controller; |
83 | struct notifier_block *adb_client_list = NULL; | 83 | BLOCKING_NOTIFIER_HEAD(adb_client_list); |
84 | static int adb_got_sleep; | 84 | static int adb_got_sleep; |
85 | static int adb_inited; | 85 | static int adb_inited; |
86 | static pid_t adb_probe_task_pid; | 86 | static pid_t adb_probe_task_pid; |
@@ -354,7 +354,8 @@ adb_notify_sleep(struct pmu_sleep_notifier *self, int when) | |||
354 | /* Stop autopoll */ | 354 | /* Stop autopoll */ |
355 | if (adb_controller->autopoll) | 355 | if (adb_controller->autopoll) |
356 | adb_controller->autopoll(0); | 356 | adb_controller->autopoll(0); |
357 | ret = notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL); | 357 | ret = blocking_notifier_call_chain(&adb_client_list, |
358 | ADB_MSG_POWERDOWN, NULL); | ||
358 | if (ret & NOTIFY_STOP_MASK) { | 359 | if (ret & NOTIFY_STOP_MASK) { |
359 | up(&adb_probe_mutex); | 360 | up(&adb_probe_mutex); |
360 | return PBOOK_SLEEP_REFUSE; | 361 | return PBOOK_SLEEP_REFUSE; |
@@ -391,7 +392,8 @@ do_adb_reset_bus(void) | |||
391 | if (adb_controller->autopoll) | 392 | if (adb_controller->autopoll) |
392 | adb_controller->autopoll(0); | 393 | adb_controller->autopoll(0); |
393 | 394 | ||
394 | nret = notifier_call_chain(&adb_client_list, ADB_MSG_PRE_RESET, NULL); | 395 | nret = blocking_notifier_call_chain(&adb_client_list, |
396 | ADB_MSG_PRE_RESET, NULL); | ||
395 | if (nret & NOTIFY_STOP_MASK) { | 397 | if (nret & NOTIFY_STOP_MASK) { |
396 | if (adb_controller->autopoll) | 398 | if (adb_controller->autopoll) |
397 | adb_controller->autopoll(autopoll_devs); | 399 | adb_controller->autopoll(autopoll_devs); |
@@ -426,7 +428,8 @@ do_adb_reset_bus(void) | |||
426 | } | 428 | } |
427 | up(&adb_handler_sem); | 429 | up(&adb_handler_sem); |
428 | 430 | ||
429 | nret = notifier_call_chain(&adb_client_list, ADB_MSG_POST_RESET, NULL); | 431 | nret = blocking_notifier_call_chain(&adb_client_list, |
432 | ADB_MSG_POST_RESET, NULL); | ||
430 | if (nret & NOTIFY_STOP_MASK) | 433 | if (nret & NOTIFY_STOP_MASK) |
431 | return -EBUSY; | 434 | return -EBUSY; |
432 | 435 | ||
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index c0b46bceb5df..f5779a73184d 100644 --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c | |||
@@ -1214,7 +1214,8 @@ static int __init adbhid_init(void) | |||
1214 | 1214 | ||
1215 | adbhid_probe(); | 1215 | adbhid_probe(); |
1216 | 1216 | ||
1217 | notifier_chain_register(&adb_client_list, &adbhid_adb_notifier); | 1217 | blocking_notifier_chain_register(&adb_client_list, |
1218 | &adbhid_adb_notifier); | ||
1218 | 1219 | ||
1219 | return 0; | 1220 | return 0; |
1220 | } | 1221 | } |
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 4f5f3abc9cb3..0b5ff553e39a 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -187,7 +187,7 @@ extern int disable_kernel_backlight; | |||
187 | 187 | ||
188 | int __fake_sleep; | 188 | int __fake_sleep; |
189 | int asleep; | 189 | int asleep; |
190 | struct notifier_block *sleep_notifier_list; | 190 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); |
191 | 191 | ||
192 | #ifdef CONFIG_ADB | 192 | #ifdef CONFIG_ADB |
193 | static int adb_dev_map = 0; | 193 | static int adb_dev_map = 0; |
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c index f08e52f2107b..35b70323e7e3 100644 --- a/drivers/macintosh/via-pmu68k.c +++ b/drivers/macintosh/via-pmu68k.c | |||
@@ -102,7 +102,7 @@ static int pmu_kind = PMU_UNKNOWN; | |||
102 | static int pmu_fully_inited = 0; | 102 | static int pmu_fully_inited = 0; |
103 | 103 | ||
104 | int asleep; | 104 | int asleep; |
105 | struct notifier_block *sleep_notifier_list; | 105 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); |
106 | 106 | ||
107 | static int pmu_probe(void); | 107 | static int pmu_probe(void); |
108 | static int pmu_init(void); | 108 | static int pmu_init(void); |
@@ -913,7 +913,8 @@ int powerbook_sleep(void) | |||
913 | struct adb_request sleep_req; | 913 | struct adb_request sleep_req; |
914 | 914 | ||
915 | /* Notify device drivers */ | 915 | /* Notify device drivers */ |
916 | ret = notifier_call_chain(&sleep_notifier_list, PBOOK_SLEEP, NULL); | 916 | ret = blocking_notifier_call_chain(&sleep_notifier_list, |
917 | PBOOK_SLEEP, NULL); | ||
917 | if (ret & NOTIFY_STOP_MASK) | 918 | if (ret & NOTIFY_STOP_MASK) |
918 | return -EBUSY; | 919 | return -EBUSY; |
919 | 920 | ||
@@ -984,7 +985,7 @@ int powerbook_sleep(void) | |||
984 | enable_irq(i); | 985 | enable_irq(i); |
985 | 986 | ||
986 | /* Notify drivers */ | 987 | /* Notify drivers */ |
987 | notifier_call_chain(&sleep_notifier_list, PBOOK_WAKE, NULL); | 988 | blocking_notifier_call_chain(&sleep_notifier_list, PBOOK_WAKE, NULL); |
988 | 989 | ||
989 | /* reenable ADB autopoll */ | 990 | /* reenable ADB autopoll */ |
990 | pmu_adb_autopoll(adb_dev_map); | 991 | pmu_adb_autopoll(adb_dev_map); |
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c index 6c0ba04bc57a..ab3faa702d58 100644 --- a/drivers/macintosh/windfarm_core.c +++ b/drivers/macintosh/windfarm_core.c | |||
@@ -52,7 +52,7 @@ | |||
52 | static LIST_HEAD(wf_controls); | 52 | static LIST_HEAD(wf_controls); |
53 | static LIST_HEAD(wf_sensors); | 53 | static LIST_HEAD(wf_sensors); |
54 | static DEFINE_MUTEX(wf_lock); | 54 | static DEFINE_MUTEX(wf_lock); |
55 | static struct notifier_block *wf_client_list; | 55 | static BLOCKING_NOTIFIER_HEAD(wf_client_list); |
56 | static int wf_client_count; | 56 | static int wf_client_count; |
57 | static unsigned int wf_overtemp; | 57 | static unsigned int wf_overtemp; |
58 | static unsigned int wf_overtemp_counter; | 58 | static unsigned int wf_overtemp_counter; |
@@ -68,7 +68,7 @@ static struct platform_device wf_platform_device = { | |||
68 | 68 | ||
69 | static inline void wf_notify(int event, void *param) | 69 | static inline void wf_notify(int event, void *param) |
70 | { | 70 | { |
71 | notifier_call_chain(&wf_client_list, event, param); | 71 | blocking_notifier_call_chain(&wf_client_list, event, param); |
72 | } | 72 | } |
73 | 73 | ||
74 | int wf_critical_overtemp(void) | 74 | int wf_critical_overtemp(void) |
@@ -398,7 +398,7 @@ int wf_register_client(struct notifier_block *nb) | |||
398 | struct wf_sensor *sr; | 398 | struct wf_sensor *sr; |
399 | 399 | ||
400 | mutex_lock(&wf_lock); | 400 | mutex_lock(&wf_lock); |
401 | rc = notifier_chain_register(&wf_client_list, nb); | 401 | rc = blocking_notifier_chain_register(&wf_client_list, nb); |
402 | if (rc != 0) | 402 | if (rc != 0) |
403 | goto bail; | 403 | goto bail; |
404 | wf_client_count++; | 404 | wf_client_count++; |
@@ -417,7 +417,7 @@ EXPORT_SYMBOL_GPL(wf_register_client); | |||
417 | int wf_unregister_client(struct notifier_block *nb) | 417 | int wf_unregister_client(struct notifier_block *nb) |
418 | { | 418 | { |
419 | mutex_lock(&wf_lock); | 419 | mutex_lock(&wf_lock); |
420 | notifier_chain_unregister(&wf_client_list, nb); | 420 | blocking_notifier_chain_unregister(&wf_client_list, nb); |
421 | wf_client_count++; | 421 | wf_client_count++; |
422 | if (wf_client_count == 0) | 422 | if (wf_client_count == 0) |
423 | wf_stop_thread(); | 423 | wf_stop_thread(); |
diff --git a/drivers/misc/ibmasm/heartbeat.c b/drivers/misc/ibmasm/heartbeat.c index f295401fac21..7fd7a43e38de 100644 --- a/drivers/misc/ibmasm/heartbeat.c +++ b/drivers/misc/ibmasm/heartbeat.c | |||
@@ -52,12 +52,13 @@ static struct notifier_block panic_notifier = { panic_happened, NULL, 1 }; | |||
52 | 52 | ||
53 | void ibmasm_register_panic_notifier(void) | 53 | void ibmasm_register_panic_notifier(void) |
54 | { | 54 | { |
55 | notifier_chain_register(&panic_notifier_list, &panic_notifier); | 55 | atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier); |
56 | } | 56 | } |
57 | 57 | ||
58 | void ibmasm_unregister_panic_notifier(void) | 58 | void ibmasm_unregister_panic_notifier(void) |
59 | { | 59 | { |
60 | notifier_chain_unregister(&panic_notifier_list, &panic_notifier); | 60 | atomic_notifier_chain_unregister(&panic_notifier_list, |
61 | &panic_notifier); | ||
61 | } | 62 | } |
62 | 63 | ||
63 | 64 | ||
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 2d0ac169a86c..f13a539dc169 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -3159,7 +3159,7 @@ static int bond_slave_netdev_event(unsigned long event, struct net_device *slave | |||
3159 | * bond_netdev_event: handle netdev notifier chain events. | 3159 | * bond_netdev_event: handle netdev notifier chain events. |
3160 | * | 3160 | * |
3161 | * This function receives events for the netdev chain. The caller (an | 3161 | * This function receives events for the netdev chain. The caller (an |
3162 | * ioctl handler calling notifier_call_chain) holds the necessary | 3162 | * ioctl handler calling blocking_notifier_call_chain) holds the necessary |
3163 | * locks for us to safely manipulate the slave devices (RTNL lock, | 3163 | * locks for us to safely manipulate the slave devices (RTNL lock, |
3164 | * dev_probe_lock). | 3164 | * dev_probe_lock). |
3165 | */ | 3165 | */ |
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index 3627a2d7f79f..298f2ddb2c17 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c | |||
@@ -499,11 +499,16 @@ static int led_halt(struct notifier_block *, unsigned long, void *); | |||
499 | static struct notifier_block led_notifier = { | 499 | static struct notifier_block led_notifier = { |
500 | .notifier_call = led_halt, | 500 | .notifier_call = led_halt, |
501 | }; | 501 | }; |
502 | static int notifier_disabled = 0; | ||
502 | 503 | ||
503 | static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) | 504 | static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) |
504 | { | 505 | { |
505 | char *txt; | 506 | char *txt; |
506 | 507 | ||
508 | if (notifier_disabled) | ||
509 | return NOTIFY_OK; | ||
510 | |||
511 | notifier_disabled = 1; | ||
507 | switch (event) { | 512 | switch (event) { |
508 | case SYS_RESTART: txt = "SYSTEM RESTART"; | 513 | case SYS_RESTART: txt = "SYSTEM RESTART"; |
509 | break; | 514 | break; |
@@ -527,7 +532,6 @@ static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) | |||
527 | if (led_func_ptr) | 532 | if (led_func_ptr) |
528 | led_func_ptr(0xff); /* turn all LEDs ON */ | 533 | led_func_ptr(0xff); /* turn all LEDs ON */ |
529 | 534 | ||
530 | unregister_reboot_notifier(&led_notifier); | ||
531 | return NOTIFY_OK; | 535 | return NOTIFY_OK; |
532 | } | 536 | } |
533 | 537 | ||
@@ -758,6 +762,12 @@ not_found: | |||
758 | return 1; | 762 | return 1; |
759 | } | 763 | } |
760 | 764 | ||
765 | static void __exit led_exit(void) | ||
766 | { | ||
767 | unregister_reboot_notifier(&led_notifier); | ||
768 | return; | ||
769 | } | ||
770 | |||
761 | #ifdef CONFIG_PROC_FS | 771 | #ifdef CONFIG_PROC_FS |
762 | module_init(led_create_procfs) | 772 | module_init(led_create_procfs) |
763 | #endif | 773 | #endif |
diff --git a/drivers/parisc/power.c b/drivers/parisc/power.c index 54b2b7f20b96..0bcab83b4080 100644 --- a/drivers/parisc/power.c +++ b/drivers/parisc/power.c | |||
@@ -251,7 +251,8 @@ static int __init power_init(void) | |||
251 | } | 251 | } |
252 | 252 | ||
253 | /* Register a call for panic conditions. */ | 253 | /* Register a call for panic conditions. */ |
254 | notifier_chain_register(&panic_notifier_list, &parisc_panic_block); | 254 | atomic_notifier_chain_register(&panic_notifier_list, |
255 | &parisc_panic_block); | ||
255 | 256 | ||
256 | tasklet_enable(&power_tasklet); | 257 | tasklet_enable(&power_tasklet); |
257 | 258 | ||
@@ -264,7 +265,8 @@ static void __exit power_exit(void) | |||
264 | return; | 265 | return; |
265 | 266 | ||
266 | tasklet_disable(&power_tasklet); | 267 | tasklet_disable(&power_tasklet); |
267 | notifier_chain_unregister(&panic_notifier_list, &parisc_panic_block); | 268 | atomic_notifier_chain_unregister(&panic_notifier_list, |
269 | &parisc_panic_block); | ||
268 | power_tasklet.func = NULL; | 270 | power_tasklet.func = NULL; |
269 | pdc_soft_power_button(0); | 271 | pdc_soft_power_button(0); |
270 | } | 272 | } |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 62e3cda859af..7f7013e80a88 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -671,7 +671,7 @@ static struct file_operations gdth_fops = { | |||
671 | static struct notifier_block gdth_notifier = { | 671 | static struct notifier_block gdth_notifier = { |
672 | gdth_halt, NULL, 0 | 672 | gdth_halt, NULL, 0 |
673 | }; | 673 | }; |
674 | 674 | static int notifier_disabled = 0; | |
675 | 675 | ||
676 | static void gdth_delay(int milliseconds) | 676 | static void gdth_delay(int milliseconds) |
677 | { | 677 | { |
@@ -4595,13 +4595,13 @@ static int __init gdth_detect(struct scsi_host_template *shtp) | |||
4595 | add_timer(&gdth_timer); | 4595 | add_timer(&gdth_timer); |
4596 | #endif | 4596 | #endif |
4597 | major = register_chrdev(0,"gdth",&gdth_fops); | 4597 | major = register_chrdev(0,"gdth",&gdth_fops); |
4598 | notifier_disabled = 0; | ||
4598 | register_reboot_notifier(&gdth_notifier); | 4599 | register_reboot_notifier(&gdth_notifier); |
4599 | } | 4600 | } |
4600 | gdth_polling = FALSE; | 4601 | gdth_polling = FALSE; |
4601 | return gdth_ctr_vcount; | 4602 | return gdth_ctr_vcount; |
4602 | } | 4603 | } |
4603 | 4604 | ||
4604 | |||
4605 | static int gdth_release(struct Scsi_Host *shp) | 4605 | static int gdth_release(struct Scsi_Host *shp) |
4606 | { | 4606 | { |
4607 | int hanum; | 4607 | int hanum; |
@@ -5632,10 +5632,14 @@ static int gdth_halt(struct notifier_block *nb, ulong event, void *buf) | |||
5632 | char cmnd[MAX_COMMAND_SIZE]; | 5632 | char cmnd[MAX_COMMAND_SIZE]; |
5633 | #endif | 5633 | #endif |
5634 | 5634 | ||
5635 | if (notifier_disabled) | ||
5636 | return NOTIFY_OK; | ||
5637 | |||
5635 | TRACE2(("gdth_halt() event %d\n",(int)event)); | 5638 | TRACE2(("gdth_halt() event %d\n",(int)event)); |
5636 | if (event != SYS_RESTART && event != SYS_HALT && event != SYS_POWER_OFF) | 5639 | if (event != SYS_RESTART && event != SYS_HALT && event != SYS_POWER_OFF) |
5637 | return NOTIFY_DONE; | 5640 | return NOTIFY_DONE; |
5638 | 5641 | ||
5642 | notifier_disabled = 1; | ||
5639 | printk("GDT-HA: Flushing all host drives .. "); | 5643 | printk("GDT-HA: Flushing all host drives .. "); |
5640 | for (hanum = 0; hanum < gdth_ctr_count; ++hanum) { | 5644 | for (hanum = 0; hanum < gdth_ctr_count; ++hanum) { |
5641 | gdth_flush(hanum); | 5645 | gdth_flush(hanum); |
@@ -5679,7 +5683,6 @@ static int gdth_halt(struct notifier_block *nb, ulong event, void *buf) | |||
5679 | #ifdef GDTH_STATISTICS | 5683 | #ifdef GDTH_STATISTICS |
5680 | del_timer(&gdth_timer); | 5684 | del_timer(&gdth_timer); |
5681 | #endif | 5685 | #endif |
5682 | unregister_reboot_notifier(&gdth_notifier); | ||
5683 | return NOTIFY_OK; | 5686 | return NOTIFY_OK; |
5684 | } | 5687 | } |
5685 | 5688 | ||
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c index 4b55285de9a0..fe0ed54fa0ae 100644 --- a/drivers/usb/core/notify.c +++ b/drivers/usb/core/notify.c | |||
@@ -16,57 +16,7 @@ | |||
16 | #include <linux/mutex.h> | 16 | #include <linux/mutex.h> |
17 | #include "usb.h" | 17 | #include "usb.h" |
18 | 18 | ||
19 | 19 | static BLOCKING_NOTIFIER_HEAD(usb_notifier_list); | |
20 | static struct notifier_block *usb_notifier_list; | ||
21 | static DEFINE_MUTEX(usb_notifier_lock); | ||
22 | |||
23 | static void usb_notifier_chain_register(struct notifier_block **list, | ||
24 | struct notifier_block *n) | ||
25 | { | ||
26 | mutex_lock(&usb_notifier_lock); | ||
27 | while (*list) { | ||
28 | if (n->priority > (*list)->priority) | ||
29 | break; | ||
30 | list = &((*list)->next); | ||
31 | } | ||
32 | n->next = *list; | ||
33 | *list = n; | ||
34 | mutex_unlock(&usb_notifier_lock); | ||
35 | } | ||
36 | |||
37 | static void usb_notifier_chain_unregister(struct notifier_block **nl, | ||
38 | struct notifier_block *n) | ||
39 | { | ||
40 | mutex_lock(&usb_notifier_lock); | ||
41 | while ((*nl)!=NULL) { | ||
42 | if ((*nl)==n) { | ||
43 | *nl = n->next; | ||
44 | goto exit; | ||
45 | } | ||
46 | nl=&((*nl)->next); | ||
47 | } | ||
48 | exit: | ||
49 | mutex_unlock(&usb_notifier_lock); | ||
50 | } | ||
51 | |||
52 | static int usb_notifier_call_chain(struct notifier_block **n, | ||
53 | unsigned long val, void *v) | ||
54 | { | ||
55 | int ret=NOTIFY_DONE; | ||
56 | struct notifier_block *nb = *n; | ||
57 | |||
58 | mutex_lock(&usb_notifier_lock); | ||
59 | while (nb) { | ||
60 | ret = nb->notifier_call(nb,val,v); | ||
61 | if (ret&NOTIFY_STOP_MASK) { | ||
62 | goto exit; | ||
63 | } | ||
64 | nb = nb->next; | ||
65 | } | ||
66 | exit: | ||
67 | mutex_unlock(&usb_notifier_lock); | ||
68 | return ret; | ||
69 | } | ||
70 | 20 | ||
71 | /** | 21 | /** |
72 | * usb_register_notify - register a notifier callback whenever a usb change happens | 22 | * usb_register_notify - register a notifier callback whenever a usb change happens |
@@ -76,7 +26,7 @@ exit: | |||
76 | */ | 26 | */ |
77 | void usb_register_notify(struct notifier_block *nb) | 27 | void usb_register_notify(struct notifier_block *nb) |
78 | { | 28 | { |
79 | usb_notifier_chain_register(&usb_notifier_list, nb); | 29 | blocking_notifier_chain_register(&usb_notifier_list, nb); |
80 | } | 30 | } |
81 | EXPORT_SYMBOL_GPL(usb_register_notify); | 31 | EXPORT_SYMBOL_GPL(usb_register_notify); |
82 | 32 | ||
@@ -89,27 +39,28 @@ EXPORT_SYMBOL_GPL(usb_register_notify); | |||
89 | */ | 39 | */ |
90 | void usb_unregister_notify(struct notifier_block *nb) | 40 | void usb_unregister_notify(struct notifier_block *nb) |
91 | { | 41 | { |
92 | usb_notifier_chain_unregister(&usb_notifier_list, nb); | 42 | blocking_notifier_chain_unregister(&usb_notifier_list, nb); |
93 | } | 43 | } |
94 | EXPORT_SYMBOL_GPL(usb_unregister_notify); | 44 | EXPORT_SYMBOL_GPL(usb_unregister_notify); |
95 | 45 | ||
96 | 46 | ||
97 | void usb_notify_add_device(struct usb_device *udev) | 47 | void usb_notify_add_device(struct usb_device *udev) |
98 | { | 48 | { |
99 | usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_ADD, udev); | 49 | blocking_notifier_call_chain(&usb_notifier_list, USB_DEVICE_ADD, udev); |
100 | } | 50 | } |
101 | 51 | ||
102 | void usb_notify_remove_device(struct usb_device *udev) | 52 | void usb_notify_remove_device(struct usb_device *udev) |
103 | { | 53 | { |
104 | usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_REMOVE, udev); | 54 | blocking_notifier_call_chain(&usb_notifier_list, |
55 | USB_DEVICE_REMOVE, udev); | ||
105 | } | 56 | } |
106 | 57 | ||
107 | void usb_notify_add_bus(struct usb_bus *ubus) | 58 | void usb_notify_add_bus(struct usb_bus *ubus) |
108 | { | 59 | { |
109 | usb_notifier_call_chain(&usb_notifier_list, USB_BUS_ADD, ubus); | 60 | blocking_notifier_call_chain(&usb_notifier_list, USB_BUS_ADD, ubus); |
110 | } | 61 | } |
111 | 62 | ||
112 | void usb_notify_remove_bus(struct usb_bus *ubus) | 63 | void usb_notify_remove_bus(struct usb_bus *ubus) |
113 | { | 64 | { |
114 | usb_notifier_call_chain(&usb_notifier_list, USB_BUS_REMOVE, ubus); | 65 | blocking_notifier_call_chain(&usb_notifier_list, USB_BUS_REMOVE, ubus); |
115 | } | 66 | } |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 07d882b14396..b1a8dca76430 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -55,7 +55,7 @@ | |||
55 | 55 | ||
56 | #define FBPIXMAPSIZE (1024 * 8) | 56 | #define FBPIXMAPSIZE (1024 * 8) |
57 | 57 | ||
58 | static struct notifier_block *fb_notifier_list; | 58 | static BLOCKING_NOTIFIER_HEAD(fb_notifier_list); |
59 | struct fb_info *registered_fb[FB_MAX]; | 59 | struct fb_info *registered_fb[FB_MAX]; |
60 | int num_registered_fb; | 60 | int num_registered_fb; |
61 | 61 | ||
@@ -784,7 +784,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) | |||
784 | 784 | ||
785 | event.info = info; | 785 | event.info = info; |
786 | event.data = &mode1; | 786 | event.data = &mode1; |
787 | ret = notifier_call_chain(&fb_notifier_list, | 787 | ret = blocking_notifier_call_chain(&fb_notifier_list, |
788 | FB_EVENT_MODE_DELETE, &event); | 788 | FB_EVENT_MODE_DELETE, &event); |
789 | } | 789 | } |
790 | 790 | ||
@@ -830,8 +830,8 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) | |||
830 | 830 | ||
831 | info->flags &= ~FBINFO_MISC_USEREVENT; | 831 | info->flags &= ~FBINFO_MISC_USEREVENT; |
832 | event.info = info; | 832 | event.info = info; |
833 | notifier_call_chain(&fb_notifier_list, evnt, | 833 | blocking_notifier_call_chain(&fb_notifier_list, |
834 | &event); | 834 | evnt, &event); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | } | 837 | } |
@@ -854,7 +854,8 @@ fb_blank(struct fb_info *info, int blank) | |||
854 | 854 | ||
855 | event.info = info; | 855 | event.info = info; |
856 | event.data = ␣ | 856 | event.data = ␣ |
857 | notifier_call_chain(&fb_notifier_list, FB_EVENT_BLANK, &event); | 857 | blocking_notifier_call_chain(&fb_notifier_list, |
858 | FB_EVENT_BLANK, &event); | ||
858 | } | 859 | } |
859 | 860 | ||
860 | return ret; | 861 | return ret; |
@@ -925,7 +926,7 @@ fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
925 | con2fb.framebuffer = -1; | 926 | con2fb.framebuffer = -1; |
926 | event.info = info; | 927 | event.info = info; |
927 | event.data = &con2fb; | 928 | event.data = &con2fb; |
928 | notifier_call_chain(&fb_notifier_list, | 929 | blocking_notifier_call_chain(&fb_notifier_list, |
929 | FB_EVENT_GET_CONSOLE_MAP, &event); | 930 | FB_EVENT_GET_CONSOLE_MAP, &event); |
930 | return copy_to_user(argp, &con2fb, | 931 | return copy_to_user(argp, &con2fb, |
931 | sizeof(con2fb)) ? -EFAULT : 0; | 932 | sizeof(con2fb)) ? -EFAULT : 0; |
@@ -944,7 +945,7 @@ fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
944 | return -EINVAL; | 945 | return -EINVAL; |
945 | event.info = info; | 946 | event.info = info; |
946 | event.data = &con2fb; | 947 | event.data = &con2fb; |
947 | return notifier_call_chain(&fb_notifier_list, | 948 | return blocking_notifier_call_chain(&fb_notifier_list, |
948 | FB_EVENT_SET_CONSOLE_MAP, | 949 | FB_EVENT_SET_CONSOLE_MAP, |
949 | &event); | 950 | &event); |
950 | case FBIOBLANK: | 951 | case FBIOBLANK: |
@@ -1324,7 +1325,7 @@ register_framebuffer(struct fb_info *fb_info) | |||
1324 | devfs_mk_cdev(MKDEV(FB_MAJOR, i), | 1325 | devfs_mk_cdev(MKDEV(FB_MAJOR, i), |
1325 | S_IFCHR | S_IRUGO | S_IWUGO, "fb/%d", i); | 1326 | S_IFCHR | S_IRUGO | S_IWUGO, "fb/%d", i); |
1326 | event.info = fb_info; | 1327 | event.info = fb_info; |
1327 | notifier_call_chain(&fb_notifier_list, | 1328 | blocking_notifier_call_chain(&fb_notifier_list, |
1328 | FB_EVENT_FB_REGISTERED, &event); | 1329 | FB_EVENT_FB_REGISTERED, &event); |
1329 | return 0; | 1330 | return 0; |
1330 | } | 1331 | } |
@@ -1366,7 +1367,7 @@ unregister_framebuffer(struct fb_info *fb_info) | |||
1366 | */ | 1367 | */ |
1367 | int fb_register_client(struct notifier_block *nb) | 1368 | int fb_register_client(struct notifier_block *nb) |
1368 | { | 1369 | { |
1369 | return notifier_chain_register(&fb_notifier_list, nb); | 1370 | return blocking_notifier_chain_register(&fb_notifier_list, nb); |
1370 | } | 1371 | } |
1371 | 1372 | ||
1372 | /** | 1373 | /** |
@@ -1375,7 +1376,7 @@ int fb_register_client(struct notifier_block *nb) | |||
1375 | */ | 1376 | */ |
1376 | int fb_unregister_client(struct notifier_block *nb) | 1377 | int fb_unregister_client(struct notifier_block *nb) |
1377 | { | 1378 | { |
1378 | return notifier_chain_unregister(&fb_notifier_list, nb); | 1379 | return blocking_notifier_chain_unregister(&fb_notifier_list, nb); |
1379 | } | 1380 | } |
1380 | 1381 | ||
1381 | /** | 1382 | /** |
@@ -1393,11 +1394,13 @@ void fb_set_suspend(struct fb_info *info, int state) | |||
1393 | 1394 | ||
1394 | event.info = info; | 1395 | event.info = info; |
1395 | if (state) { | 1396 | if (state) { |
1396 | notifier_call_chain(&fb_notifier_list, FB_EVENT_SUSPEND, &event); | 1397 | blocking_notifier_call_chain(&fb_notifier_list, |
1398 | FB_EVENT_SUSPEND, &event); | ||
1397 | info->state = FBINFO_STATE_SUSPENDED; | 1399 | info->state = FBINFO_STATE_SUSPENDED; |
1398 | } else { | 1400 | } else { |
1399 | info->state = FBINFO_STATE_RUNNING; | 1401 | info->state = FBINFO_STATE_RUNNING; |
1400 | notifier_call_chain(&fb_notifier_list, FB_EVENT_RESUME, &event); | 1402 | blocking_notifier_call_chain(&fb_notifier_list, |
1403 | FB_EVENT_RESUME, &event); | ||
1401 | } | 1404 | } |
1402 | } | 1405 | } |
1403 | 1406 | ||
@@ -1469,7 +1472,7 @@ int fb_new_modelist(struct fb_info *info) | |||
1469 | 1472 | ||
1470 | if (!list_empty(&info->modelist)) { | 1473 | if (!list_empty(&info->modelist)) { |
1471 | event.info = info; | 1474 | event.info = info; |
1472 | err = notifier_call_chain(&fb_notifier_list, | 1475 | err = blocking_notifier_call_chain(&fb_notifier_list, |
1473 | FB_EVENT_NEW_MODELIST, | 1476 | FB_EVENT_NEW_MODELIST, |
1474 | &event); | 1477 | &event); |
1475 | } | 1478 | } |
@@ -1495,7 +1498,7 @@ int fb_con_duit(struct fb_info *info, int event, void *data) | |||
1495 | evnt.info = info; | 1498 | evnt.info = info; |
1496 | evnt.data = data; | 1499 | evnt.data = data; |
1497 | 1500 | ||
1498 | return notifier_call_chain(&fb_notifier_list, event, &evnt); | 1501 | return blocking_notifier_call_chain(&fb_notifier_list, event, &evnt); |
1499 | } | 1502 | } |
1500 | EXPORT_SYMBOL(fb_con_duit); | 1503 | EXPORT_SYMBOL(fb_con_duit); |
1501 | 1504 | ||