@@ -134,6 +134,26 @@ int __ref register_cpu_notifier(struct notifier_block *nb)
134134 return ret ;
135135}
136136
137+ static int __cpu_notify (unsigned long val , void * v , int nr_to_call ,
138+ int * nr_calls )
139+ {
140+ return __raw_notifier_call_chain (& cpu_chain , val , v , nr_to_call ,
141+ nr_calls );
142+ }
143+
144+ static int cpu_notify (unsigned long val , void * v )
145+ {
146+ return __cpu_notify (val , v , -1 , NULL );
147+ }
148+
149+ static void cpu_notify_nofail (unsigned long val , void * v )
150+ {
151+ int err ;
152+
153+ err = cpu_notify (val , v );
154+ BUG_ON (err == NOTIFY_BAD );
155+ }
156+
137157#ifdef CONFIG_HOTPLUG_CPU
138158
139159EXPORT_SYMBOL (register_cpu_notifier );
@@ -181,8 +201,7 @@ static int __ref take_cpu_down(void *_param)
181201 if (err < 0 )
182202 return err ;
183203
184- raw_notifier_call_chain (& cpu_chain , CPU_DYING | param -> mod ,
185- param -> hcpu );
204+ cpu_notify (CPU_DYING | param -> mod , param -> hcpu );
186205
187206 if (task_cpu (param -> caller ) == cpu )
188207 move_task_off_dead_cpu (cpu , param -> caller );
@@ -212,14 +231,12 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
212231
213232 cpu_hotplug_begin ();
214233 set_cpu_active (cpu , false);
215- err = __raw_notifier_call_chain (& cpu_chain , CPU_DOWN_PREPARE | mod ,
216- hcpu , -1 , & nr_calls );
234+ err = __cpu_notify (CPU_DOWN_PREPARE | mod , hcpu , -1 , & nr_calls );
217235 if (err == NOTIFY_BAD ) {
218236 set_cpu_active (cpu , true);
219237
220238 nr_calls -- ;
221- __raw_notifier_call_chain (& cpu_chain , CPU_DOWN_FAILED | mod ,
222- hcpu , nr_calls , NULL );
239+ __cpu_notify (CPU_DOWN_FAILED | mod , hcpu , nr_calls , NULL );
223240 printk ("%s: attempt to take down CPU %u failed\n" ,
224241 __func__ , cpu );
225242 err = - EINVAL ;
@@ -230,9 +247,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
230247 if (err ) {
231248 set_cpu_active (cpu , true);
232249 /* CPU didn't die: tell everyone. Can't complain. */
233- if (raw_notifier_call_chain (& cpu_chain , CPU_DOWN_FAILED | mod ,
234- hcpu ) == NOTIFY_BAD )
235- BUG ();
250+ cpu_notify_nofail (CPU_DOWN_FAILED | mod , hcpu );
236251
237252 goto out_release ;
238253 }
@@ -246,19 +261,14 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
246261 __cpu_die (cpu );
247262
248263 /* CPU is completely dead: tell everyone. Too late to complain. */
249- if (raw_notifier_call_chain (& cpu_chain , CPU_DEAD | mod ,
250- hcpu ) == NOTIFY_BAD )
251- BUG ();
264+ cpu_notify_nofail (CPU_DEAD | mod , hcpu );
252265
253266 check_for_tasks (cpu );
254267
255268out_release :
256269 cpu_hotplug_done ();
257- if (!err ) {
258- if (raw_notifier_call_chain (& cpu_chain , CPU_POST_DEAD | mod ,
259- hcpu ) == NOTIFY_BAD )
260- BUG ();
261- }
270+ if (!err )
271+ cpu_notify_nofail (CPU_POST_DEAD | mod , hcpu );
262272 return err ;
263273}
264274
@@ -293,8 +303,7 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
293303 return - EINVAL ;
294304
295305 cpu_hotplug_begin ();
296- ret = __raw_notifier_call_chain (& cpu_chain , CPU_UP_PREPARE | mod , hcpu ,
297- -1 , & nr_calls );
306+ ret = __cpu_notify (CPU_UP_PREPARE | mod , hcpu , -1 , & nr_calls );
298307 if (ret == NOTIFY_BAD ) {
299308 nr_calls -- ;
300309 printk ("%s: attempt to bring up CPU %u failed\n" ,
@@ -312,12 +321,11 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
312321 set_cpu_active (cpu , true);
313322
314323 /* Now call notifier in preparation. */
315- raw_notifier_call_chain ( & cpu_chain , CPU_ONLINE | mod , hcpu );
324+ cpu_notify ( CPU_ONLINE | mod , hcpu );
316325
317326out_notify :
318327 if (ret != 0 )
319- __raw_notifier_call_chain (& cpu_chain ,
320- CPU_UP_CANCELED | mod , hcpu , nr_calls , NULL );
328+ __cpu_notify (CPU_UP_CANCELED | mod , hcpu , nr_calls , NULL );
321329 cpu_hotplug_done ();
322330
323331 return ret ;
@@ -481,7 +489,7 @@ void __cpuinit notify_cpu_starting(unsigned int cpu)
481489 if (frozen_cpus != NULL && cpumask_test_cpu (cpu , frozen_cpus ))
482490 val = CPU_STARTING_FROZEN ;
483491#endif /* CONFIG_PM_SLEEP_SMP */
484- raw_notifier_call_chain ( & cpu_chain , val , (void * )(long )cpu );
492+ cpu_notify ( val , (void * )(long )cpu );
485493}
486494
487495#endif /* CONFIG_SMP */
0 commit comments