Skip to content

Commit

Permalink
kernel/: convert cpu notifier to return encapsulate errno value
Browse files Browse the repository at this point in the history
By the previous modification, the cpu notifier can return encapsulate
errno value.  This converts the cpu notifiers for kernel/*.c

Signed-off-by: Akinobu Mita <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed May 27, 2010
1 parent ad84bb5 commit 80b5184
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions kernel/padata.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ static int padata_cpu_callback(struct notifier_block *nfb,
err = __padata_add_cpu(pinst, cpu);
mutex_unlock(&pinst->lock);
if (err)
return NOTIFY_BAD;
return notifier_from_errno(err);
break;

case CPU_DOWN_PREPARE:
Expand All @@ -670,7 +670,7 @@ static int padata_cpu_callback(struct notifier_block *nfb,
err = __padata_remove_cpu(pinst, cpu);
mutex_unlock(&pinst->lock);
if (err)
return NOTIFY_BAD;
return notifier_from_errno(err);
break;

case CPU_UP_CANCELED:
Expand Down
4 changes: 2 additions & 2 deletions kernel/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static int __cpuinit profile_cpu_callback(struct notifier_block *info,
GFP_KERNEL | __GFP_ZERO,
0);
if (!page)
return NOTIFY_BAD;
return notifier_from_errno(-ENOMEM);
per_cpu(cpu_profile_hits, cpu)[1] = page_address(page);
}
if (!per_cpu(cpu_profile_hits, cpu)[0]) {
Expand All @@ -388,7 +388,7 @@ static int __cpuinit profile_cpu_callback(struct notifier_block *info,
page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
per_cpu(cpu_profile_hits, cpu)[1] = NULL;
__free_page(page);
return NOTIFY_BAD;
return notifier_from_errno(-ENOMEM);
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
if (prof_cpu_mask != NULL)
Expand Down
2 changes: 1 addition & 1 deletion kernel/relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ static int __cpuinit relay_hotcpu_callback(struct notifier_block *nb,
"relay_hotcpu_callback: cpu %d buffer "
"creation failed\n", hotcpu);
mutex_unlock(&relay_channels_mutex);
return NOTIFY_BAD;
return notifier_from_errno(-ENOMEM);
}
}
mutex_unlock(&relay_channels_mutex);
Expand Down
2 changes: 1 addition & 1 deletion kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
case CPU_UP_PREPARE_FROZEN:
if (!zalloc_cpumask_var_node(&cfd->cpumask, GFP_KERNEL,
cpu_to_node(cpu)))
return NOTIFY_BAD;
return notifier_from_errno(-ENOMEM);
break;

#ifdef CONFIG_HOTPLUG_CPU
Expand Down
2 changes: 1 addition & 1 deletion kernel/softirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
p = kthread_create(run_ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
if (IS_ERR(p)) {
printk("ksoftirqd for %i failed\n", hotcpu);
return NOTIFY_BAD;
return notifier_from_errno(PTR_ERR(p));
}
kthread_bind(p, hotcpu);
per_cpu(ksoftirqd, hotcpu) = p;
Expand Down
7 changes: 5 additions & 2 deletions kernel/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1680,11 +1680,14 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
{
long cpu = (long)hcpu;
int err;

switch(action) {
case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN:
if (init_timers_cpu(cpu) < 0)
return NOTIFY_BAD;
err = init_timers_cpu(cpu);
if (err < 0)
return notifier_from_errno(err);
break;
#ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
Expand Down
9 changes: 5 additions & 4 deletions kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
unsigned int cpu = (unsigned long)hcpu;
struct cpu_workqueue_struct *cwq;
struct workqueue_struct *wq;
int ret = NOTIFY_OK;
int err = 0;

action &= ~CPU_TASKS_FROZEN;

Expand All @@ -1124,12 +1124,13 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,

switch (action) {
case CPU_UP_PREPARE:
if (!create_workqueue_thread(cwq, cpu))
err = create_workqueue_thread(cwq, cpu);
if (!err)
break;
printk(KERN_ERR "workqueue [%s] for %i failed\n",
wq->name, cpu);
action = CPU_UP_CANCELED;
ret = NOTIFY_BAD;
err = -ENOMEM;
goto undo;

case CPU_ONLINE:
Expand All @@ -1150,7 +1151,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
cpumask_clear_cpu(cpu, cpu_populated_map);
}

return ret;
return notifier_from_errno(err);
}

#ifdef CONFIG_SMP
Expand Down

0 comments on commit 80b5184

Please sign in to comment.