Skip to content

Commit

Permalink
x86/apic: Fix ugly casting and branching in cpu_mask_to_apicid_and()
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/20120614074954.GF3383@dhcp-26-207.brq.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Alexander Gordeev authored and Ingo Molnar committed Jun 14, 2012
1 parent a5a3915 commit ea3807e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions arch/x86/kernel/apic/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2127,19 +2127,19 @@ int default_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
const struct cpumask *andmask,
unsigned int *apicid)
{
int cpu;
unsigned int cpu;

for_each_cpu_and(cpu, cpumask, andmask) {
if (cpumask_test_cpu(cpu, cpu_online_mask))
break;
}

if (likely((unsigned int)cpu < nr_cpu_ids)) {
if (likely(cpu < nr_cpu_ids)) {
*apicid = per_cpu(x86_cpu_to_apicid, cpu);
return 0;
} else {
return -EINVAL;
}

return -EINVAL;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/apic/es7000_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static inline int
es7000_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id)
{
unsigned int round = 0;
int cpu, uninitialized_var(apicid);
unsigned int cpu, uninitialized_var(apicid);

/*
* The cpus in the mask must all be on the apic cluster.
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/apic/summit_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ static inline int
summit_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id)
{
unsigned int round = 0;
int cpu, apicid = 0;
unsigned int cpu, apicid = 0;

/*
* The cpus in the mask must all be on the apic cluster.
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/kernel/apic/x2apic_uv_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
const struct cpumask *andmask,
unsigned int *apicid)
{
int cpu;
int unsigned cpu;

/*
* We're using fixed IRQ delivery, can only return one phys APIC ID.
Expand All @@ -285,12 +285,12 @@ uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
break;
}

if (likely((unsigned int)cpu < nr_cpu_ids)) {
if (likely(cpu < nr_cpu_ids)) {
*apicid = per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits;
return 0;
} else {
return -EINVAL;
}

return -EINVAL;
}

static unsigned int x2apic_get_apic_id(unsigned long x)
Expand Down

0 comments on commit ea3807e

Please sign in to comment.